def disable_module(update: Update, context: CallbackContext): args = context.args chat = update.effective_chat if len(args) >= 1: disable_module = "SaitamaRobot.modules." + args[0].rsplit(".", 1)[0] try: module = importlib.import_module(disable_module) except: update.effective_message.reply_text( "Does that module even exist?") return try: command_list = module.__command_list__ except: update.effective_message.reply_text( "Module does not contain command list!") return disabled_cmds = [] failed_disabled_cmds = [] for disable_cmd in command_list: if disable_cmd.startswith(CMD_STARTERS): disable_cmd = disable_cmd[1:] if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER): sql.disable_command(chat.id, str(disable_cmd).lower()) disabled_cmds.append(disable_cmd) else: failed_disabled_cmds.append(disable_cmd) if disabled_cmds: disabled_cmds_string = ", ".join(disabled_cmds) update.effective_message.reply_text( f"Disabled the uses of `{disabled_cmds_string}`", parse_mode=ParseMode.MARKDOWN) if failed_disabled_cmds: failed_disabled_cmds_string = ", ".join(failed_disabled_cmds) update.effective_message.reply_text( f"Commands `{failed_disabled_cmds_string}` can't be disabled", parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text("What should I disable?")
def disable(update: Update, context: CallbackContext): args = context.args chat = update.effective_chat if len(args) >= 1: disable_cmd = args[0] if disable_cmd.startswith(CMD_STARTERS): disable_cmd = disable_cmd[1:] if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER): sql.disable_command(chat.id, str(disable_cmd).lower()) update.effective_message.reply_text( f"Disabled the use of `{disable_cmd}`", parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( "That command can't be disabled") else: update.effective_message.reply_text("What should I disable?")