def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message if message.text and len(message.text) > 1 and any(message.text.startswith(start) for start in CMD_STARTERS): 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: chat = update.effective_chat user = update.effective_user # disabled, admincmd, user admin if sql.is_command_disabled(chat.id, command[0].lower()): # check if command was disabled is_disabled = command[0] in ADMIN_CMDS and is_user_admin(chat, user.id) if not is_disabled and sql.is_disable_del(chat.id): # disabled and should delete update.effective_message.delete() if not is_disabled: return None else: return args, 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 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: chat = update.effective_chat # disabled, admincmd, user admin if sql.is_command_disabled(chat.id, command[0].lower()): # check if command was disabled is_disabled = command[0] in ADMIN_CMDS and is_user_admin(chat, user.id) if not is_disabled and sql.is_disable_del(chat.id): # disabled and should delete update.effective_message.delete() if not is_disabled: return None else: return args, filter_result return args, filter_result else: return False
def check_update(self, update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] if super().check_update(update): # Should be safe since check_update passed. command = update.effective_message.text_html.split(None, 1)[0][1:].split('@')[0] # disabled, admincmd, user admin if sql.is_command_disabled(chat.id, command.lower()): is_disabled = command in ADMIN_CMDS and is_user_admin(chat, user.id) if not is_disabled and sql.is_disable_del(chat.id): update.effective_message.delete() return is_disabled # not disabled else: return True return False
def disable_del(update, context): msg = update.effective_message chat = update.effective_chat if len(msg.text.split()) >= 2: args = msg.text.split(None, 1)[1] if args == "yes" or args == "on" or args == "ya": sql.disabledel_set(chat.id, True) send_message(update.effective_message, languages.tl(update.effective_message, "Ketika command di nonaktifkan, maka saya *akan menghapus* pesan command tsb."), parse_mode="markdown") return elif args == "no" or args == "off": sql.disabledel_set(chat.id, False) send_message(update.effective_message, languages.tl(update.effective_message, "Saya *tidak akan menghapus* pesan dari command yang di nonaktifkan."), parse_mode="markdown") return else: send_message(update.effective_message, languages.tl(update.effective_message, "Argumen tidak dikenal - harap gunakan 'yes', atau 'no'.")) else: send_message(update.effective_message, languages.tl(update.effective_message, "Opsi disable del saat ini: *{}*").format("Enabled" if sql.is_disable_del(chat.id) else "Disabled"), parse_mode="markdown")