def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message try: user_id = update.effective_user.id except: user_id = None if user_id: if sql.is_user_blacklisted(user_id): return False if message.text and len(message.text) > 1: fst_word = message.text.split(None, 1)[0] if len(fst_word) > 1 and any( fst_word.startswith(start) for start in CMD_STARTERS): args = message.text.split()[1:] command = fst_word[1:].split("@") command.append(message.bot.username) if user_id == 1087968824: user_id = update.effective_chat.id if not (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()): return None if SpamChecker.check_user(user_id): return None filter_result = self.filters(update) if filter_result: return args, filter_result else: return False
def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message try: user_id = update.effective_user.id except: user_id = None if user_id: if sql.is_user_blacklisted(user_id): return False if (message.entities and message.entities[0].type == MessageEntity.BOT_COMMAND and message.entities[0].offset == 0): command = message.text[1:message.entities[0].length] args = message.text.split()[1:] command = command.split('@') command.append(message.bot.username) if not (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()): return None filter_result = self.filters(update) if filter_result: return args, filter_result else: return False
def __user_info__(user_id): is_blacklisted = sql.is_user_blacklisted(user_id) text = "Blacklisted: <b>{}</b>" if int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_USERS: text = text.format("???") return text if is_blacklisted: text = text.format("Yes") reason = sql.get_reason(user_id) if reason: text += f"\nReason: <code>{reason}</code>" else: text = text.format("No") return text
def __user_info__(user_id): is_blacklisted = sql.is_user_blacklisted(user_id) text = "Blacklisted: <b>{}</b>" if user_id in [777000, 1087968824]: return "" if user_id == dispatcher.bot.id: return "" if int(user_id) in SUDO_USERS: return "" if is_blacklisted: text = text.format("Yes") reason = sql.get_reason(user_id) if reason: text += f"\nReason: <code>{reason}</code>" else: text = text.format("No") return text
def unbl_user(update: Update, context: CallbackContext) -> str: message = update.effective_message user = update.effective_user bot, args = context.bot, context.args user_id = extract_user(message, args) if not user_id: message.reply_text("I doubt that's a user.") return "" if user_id == bot.id: message.reply_text("I always notice myself.") return "" try: target_user = bot.get_chat(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("I can't seem to find this user.") return "" else: raise if sql.is_user_blacklisted(user_id): sql.unblacklist_user(user_id) message.reply_text("*notices user*") log_message = ( f"#UNBLACKLIST\n" f"<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n" f"<b>User:</b> {mention_html(target_user.id, html.escape(target_user.first_name))}" ) return log_message else: message.reply_text("I am not ignoring them at all though!") return ""