def check_and_ban(update, user_id, should_message=True): try: spmban = spamwtc.get_ban(int(user_id)) if spmban: update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( f"This person has been detected as spambot by @SpamWatch and has been removed!\nReason: <code>{spmban.reason}</code>", parse_mode=ParseMode.HTML) return else: return except: pass if sql.is_user_gbanned(user_id): update.effective_chat.kick_member(user_id) if should_message: usr = sql.get_gbanned_user(user_id) greason = usr.reason if not greason: greason = "No reason given" update.effective_message.reply_text( f"*Alert! this user was GBanned and have been removed!*\n*Reason*: {greason}", parse_mode=ParseMode.MARKDOWN) return
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 AttributeError: sw_ban = None if sw_ban: update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( f"This person has been detected as a spammer by @SpamWatch and has been removed!\nReason: <code>{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>: @YorkTownEagleUnion\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 check_and_ban(update, user_id, should_message=True): chat = update.effective_chat # type: Optional[Chat] try: sw_ban = spamwtc.get_ban(int(user_id)) except AttributeError: 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>:b@spamwatchsupport\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 check_and_ban(update, user_id, should_message=True): chat = update.effective_chat # type: Optional[Chat] if SPB_MODE: try: status = client.raw_output(int(user_id)) try: bl_check = status["results"]["attributes"]["is_blacklisted"] except: bl_check = False if bl_check is True: bl_res = status["results"]["attributes"]["blacklist_reason"] update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( f"This person was blacklisted on @SpamProtectionBot and has been removed!\nReason: <code>{bl_res}</code>", parse_mode=ParseMode.HTML, ) except HostDownError: log.warning("Spam Protection API is unreachable.") try: sw_ban = sw.get_ban(int(user_id)) except AttributeError: sw_ban = None except ( SpamWatchError, Error, UnauthorizedError, NotFoundError, Forbidden, TooManyRequests, ) as e: log.warning(f" SpamWatch Error: {e}") sw_ban = None if sw_ban: update.effective_chat.kick_member(user_id) if should_message: update.effective_message.reply_text( f"This person has been detected as a spammer by @SpamWatch and has been removed!\nReason: <code>{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>: @YorkTownEagleUnion\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 = "Gban edildi: <b>{}</b>" if is_gbanned: text = text.format("Hə") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nSəbəb: {}".format(html.escape(user.reason)) else: text = text.format("Yox") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Küresel olarak yasaklandı: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nNeden: {}".format(html.escape(user.reason)) else: text = text.format("hayır") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(html.escape(user.reason)) else: text = text.format("No") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = get_string("gbans", "USER_INFO", DEFAULT_LANG) # USER_INFO # TODO update this to update if is_gbanned: text = text.format("Yes") # USER_INFO_YES user = sql.get_gbanned_user(user_id) if user.reason: text += get_string("gbans", "USER_INFO_REASON", DEFAULT_LANG).format(html.escape(user.reason)) # USER_INFO_REASON else: text = text.format(get_string("gbans", "USER_INFO_NO", DEFAULT_LANG)) # USER_INFO_NO return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: *{}*" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(escape_markdown(user.reason)) else: text = text.format("No") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globalnie zbanowany: <b>{}</b>" if is_gbanned: text = text.format("Tak") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nPowód: {}".format(html.escape(user.reason)) else: text = text.format("Nie") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Global olarak yasaklandı: <b>{}</b>" if is_gbanned: text = text.format("Evet") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(html.escape(user.reason)) else: text = text.format("Hayır") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Küresel Ban Durumu: <b>{}</b>" if is_gbanned: text = text.format("Evet") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nSebep: {}".format(html.escape(user.reason)) else: text = text.format("Hayır") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\n<b>Reason:</b> {}".format(html.escape(user.reason)) text += "\n<b>Appeal Chat:</b> @OnePunchSupport" 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 is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> {html.escape(user.reason)}" 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 = "Gbanned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> {html.escape(user.reason)}" text += "\n<b>Appeal Chat:</b> @lichtbotsupportgroup " 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 is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> {html.escape(user.reason)}" text += "\n<b>Appeal Chat:</b> [Regress My Gban](https://t.me/ceogrouphelpbot_gbanregress)" 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 is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> {html.escape(user.reason)}" text += "\n<b>Appeal with:</b> @ShaDisNX255" else: text = text.format("No") return text
def __user_info__(user_id): if user_id in (777000, 1087968824): return "" is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: <code>{}</code>".format(html.escape(user.reason)) else: text = text.format("No") return text
def check_and_ban(update, user_id, should_message=True): if sql.is_user_gbanned(user_id): update.effective_chat.kick_member(user_id) if should_message: usr = sql.get_gbanned_user(user_id) greason = usr.reason if not greason: greason = "No reason given" update.effective_message.reply_text( f"*Alert! this user was GBanned and have been removed!*\n*Reason*: {greason}", parse_mode=ParseMode.MARKDOWN, ) return
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 + SUPPORT_USERS: return "" if is_gbanned: text = text.format("Yeah") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(html.escape(user.reason)) else: text = text.format("Na") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) if int(user_id) in SUDO_USERS or int(user_id) in SUPPORT_USERS: text = "Globally banned: <b>No</b> (Immortal)" else: text = "Globally banned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(html.escape(user.reason)) else: text = text.format("No") return text
def __user_info__(user_id): if user_id in (777000, 1087968824): return "" is_gbanned = sql.is_user_gbanned(user_id) text = "Dilarang secara globa: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Alasan:</b> {html.escape(user.reason)}" text += "\n<b>Appeal Chat:</b> PM My Master" else: text = text.format("No") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "<b>Globally banned</b>: {}" if int(user_id) in SUDO_USERS + SUPPORT_USERS: return "" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += "\nReason: {}".format(html.escape(user.reason)) text += "\n\nAppeal at @tg_botbot if you think it's invalid." else: text = text.format("No") return text
def __user_info__(user_id): if user_id in (777000, 1087968824): return "" is_gbanned = sql.is_user_gbanned(user_id) text = "Globally banned: <b>{}</b>" if is_gbanned: text = text.format("Yes") user = sql.get_gbanned_user(user_id) if user.reason: text += f"\n<b>Reason:</b> {html.escape(user.reason)}" text += "\n<b>Appeal Chat:</b> @KaaliSupport" else: text = text.format("No") return text
def __user_info__(user_id): is_gbanned = sql.is_user_gbanned(user_id) text = "Gbanned :: <b>{}</b>" if user_id in [777000, 1087968824]: return "" if user_id == dispatcher.bot.id: return "" if int(user_id) in SUDO_USERS + WHITELIST_USERS: 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
def __user_info__(user_id): if user_id in (777000, 1087968824): return "" is_gbanned = sql.is_user_gbanned(user_id) text = "Gbanned: <b>{}</b>" if user_id in [777000, 1087968824]: return "" if user_id == dispatcher.bot.id: return "" if int(user_id) in SUDO_USERS + SARDEGNA_USERS + WHITELIST_USERS: 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> @YorkTownEagleUnion" else: text = text.format("???") return text