def check_and_ban(update, user_id, should_message=True): chat = update.effective_chat message = update.effective_message if spam_watch != None: spam_watch_ban = spam_watch.get_ban(user_id) if spam_watch_ban: spamwatch_reason = spam_watch_ban.reason chat.kick_member(user_id) if should_message: message.reply_text(( chat.id, "<b>This user is detected as a spambot by SpamWatch and has been removed!</b>\n\n<b>Reason</b>: {}" ).format(spamwatch_reason), parse_mode=ParseMode.HTML) return else: return if sql.is_user_gbanned(user_id): chat.kick_member(user_id) if should_message: userr = sql.get_gbanned_user(user_id) usrreason = userr.reason if not usrreason: usrreason = (chat.id, "No reason given") message.reply_text( (chat.id, "*This user is gbanned and has been removed.*\nReason: `{}`" ).format(usrreason), parse_mode=ParseMode.MARKDOWN) return
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