def user_demote_fed(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] fed_id = sql.get_fed_id(chat.id) if is_user_fed_owner(fed_id, user.id) == False: update.effective_message.reply_text( tld(chat.id, "Only fed owner can do this!")) return msg = update.effective_message # type: Optional[Message] user_id = extract_user(msg, args) if user_id: user = bot.get_chat(user_id) elif not msg.reply_to_message and not args: user = msg.from_user elif not msg.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities([MessageEntity.TEXT_MENTION]))): msg.reply_text(tld(chat.id, "I can't extract a user from this.")) return #else: # return if user_id == bot.id: update.effective_message.reply_text( tld( chat.id, "What are you trying to do? Demoting me from your federation?") ) return if sql.search_user_in_fed(fed_id, user_id) == False: update.effective_message.reply_text( tld( chat.id, "I can't demote user which is not a fed admin! If you wanna bring him to tears, promote him first!" )) return res = sql.user_demote_fed(fed_id, user_id) if res == True: update.effective_message.reply_text(tld(chat.id, "Get out of here!")) else: update.effective_message.reply_text( tld(chat.id, "I can not remove him, I am powerless!"))
def user_demote_fed(bot: Bot, update: Update, args: List[str]): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text("Spammer detected! Ignoring user.") chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] fed_id = sql.get_fed_id(chat.id) if is_user_fed_owner(fed_id, user.id): msg = update.effective_message # type: Optional[Message] user_id = extract_user(msg, args) if user_id: user = bot.get_chat(user_id) elif not msg.reply_to_message and not args: user = msg.from_user elif not msg.reply_to_message and (not args or ( len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities( [MessageEntity.TEXT_MENTION]))): msg.reply_text("I cannot extract users from this message") return else: LOGGER.warning('error') if user_id == bot.id: update.effective_message.reply_text("Are you trying to demote me as a federation admin? Do you think I am stupid?") return if sql.search_user_in_fed(fed_id, user_id) == False: update.effective_message.reply_text("I cannot demote people who are not federation admins!") return res = sql.user_demote_fed(fed_id, user_id) if res == True: update.effective_message.reply_text("Get out of here!") else: update.effective_message.reply_text("Demotion failed!") else: update.effective_message.reply_text("Only federation owners can do this!") return
def user_demote_fed(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] fed_id = sql.get_fed_id(chat.id) if is_user_fed_owner(fed_id, user.id): msg = update.effective_message # type: Optional[Message] user_id = extract_user(msg, args) if user_id: user = bot.get_chat(user_id) elif not msg.reply_to_message and not args: user = msg.from_user elif not msg.reply_to_message and (not args or ( len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not msg.parse_entities( [MessageEntity.TEXT_MENTION]))): msg.reply_text("I cannot extract users from this message.") return else: LOGGER.warning('error') if user_id == bot.id: update.effective_message.reply_text("Boi, what are you even trying to do?") return if sql.search_user_in_fed(fed_id, user_id) == False: update.effective_message.reply_text("This user isn't even a federation admin!") return res = sql.user_demote_fed(fed_id, user_id) if res == True: update.effective_message.reply_text("Get out of here!") else: update.effective_message.reply_text("Failed to demote!") else: update.effective_message.reply_text("Only federation owners can do this!") return