def check_update(self, update): if isinstance(update, Update) and ( update.message or update.edited_message and self.allow_edited): message = update.message or update.edited_message if sql.is_user_blacklisted(update.effective_user.id): return False if message.text and len(message.text) > 1: fst_word = message.text_html.split(None, 1)[0] if len(fst_word) > 1 and any( fst_word.startswith(start) for start in CMD_STARTERS): command = fst_word[1:].split('@') command.append( message.bot.username ) # in case the command was sent without a username if self.filters is None: res = True elif isinstance(self.filters, list): res = any(func(message) for func in self.filters) else: res = self.filters(message) return res and (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()) return False
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 "" 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 message.reply_text("I am not ignoring them at all though!") return ""
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 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 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 __user_info__(user_id): is_blacklisted = sql.is_user_blacklisted(user_id) text = "Blacklisted: <b>{}</b>" 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 int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_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 __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 DRAGONS + TIGERS + WOLVES: 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( "Bunun bir istifadəçi olduğuna şübhə ilə yanaşıram.") return "" if user_id == bot.id: message.reply_text( "hmm deməli özümü blacklist-dən çıxardım. Nə vaxt blacklist-də oldumki?😐" ) return "" try: target_user = bot.get_chat(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("İstifadəçini tapa bilmədim.") return "" else: raise if sql.is_user_blacklisted(user_id): sql.unblacklist_user(user_id) message.reply_text("Yaxşı artıq məndən istifadə edə bilər😏") 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("Onsuzda onları heç görməzdən gəlmirəm!") return ""
def unbl_user(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user user_id = extract_user(message, args) if not user_id: message.reply_text("Bunun bir kullanıcı olduğundan şüpheliyim.") return "" if user_id == bot.id: message.reply_text("Kendimi hep farkettim.") return "" try: target_user = bot.get_chat(user_id) except BadRequest as excp: if excp.message == "Kullanıcı Bulunamadı": message.reply_text("Bu kullanıcıyı bulamıyorum.") 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, user.first_name)}\n" f"<b>User:</b> {mention_html(target_user.id, target_user.first_name)}" ) return log_message else: message.reply_text("Yine de onları görmezden gelmiyorum!") return ""