def check_and_ban(update, user_id, should_message=True): chat = update.effective_chat # type: Optional[Chat] try: sw_ban = sw.get_ban(int(user_id)) except: sw_ban = None if sw_ban: update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( f"<b>Alert</b>: this user is globally banned.\n" f"<code>*bans them from here*</code>.\n" f"<b>Appeal chat</b>: {SPAMWATCH_SUPPORT_CHAT}\n" f"<b>User ID</b>: <code>{sw_ban.id}</code>\n" f"<b>Ban Reason</b>: <code>{html.escape(sw_ban.reason)}</code>", parse_mode=ParseMode.HTML) return if sql.is_user_gbanned(user_id): update.effective_chat.kick_member(user_id) if should_message: text = f"<b>Alert</b>: this user is globally banned.\n" \ f"<code>*bans them from here*</code>.\n" \ f"<b>Appeal chat</b>: @{SUPPORT_CHAT}\n" \ f"<b>User ID</b>: <code>{user_id}</code>" user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Ban Reason:</b> <code>{html.escape(user.reason)}</code>" update.effective_message.reply_text(text, parse_mode=ParseMode.HTML)
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_USERS: text = text.format("???") return text if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> <code>{html.escape(user.reason)}</code>" text += f"\n<b>Appeal Chat:</b> {SUPPORT_CHAT}" else: text = text.format("No") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if user_id in [777000, 1087968824]: return "" if user_id == dispatcher.bot.id: return "" if int(user_id) in DRAGONS + WOLVES: return "" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> <code>{html.escape(user.reason)}</code>" text += f"\n<b>Appeal Chat:</b> @{SUPPORT_CHAT}" else: text = text.format("No") return text