diff --git a/ubot/command_handler.py b/ubot/command_handler.py index 037d3ac..b8f9fdd 100644 --- a/ubot/command_handler.py +++ b/ubot/command_handler.py @@ -347,3 +347,7 @@ class CommandHandler(): def is_blacklisted(self, event: ExtendedNewMessage|ExtendedInlineQuery) -> bool: return event.query.user_id if isinstance(event, ExtendedInlineQuery) else event.sender_id in self.db.blacklisted_users + + @property + def all_incoming_commands(self) -> list[Command]: + return self.incoming_commands + self.incoming_lenient_commands diff --git a/ubot/modules/_sudo.py b/ubot/modules/_sudo.py index fb0ee91..d59fd73 100644 --- a/ubot/modules/_sudo.py +++ b/ubot/modules/_sudo.py @@ -172,7 +172,7 @@ async def dbstat(event): @ldr.add("usage", owner=True, hide_help=True) async def usagestat(event): - await event.reply("\n".join(f"{command.pattern}: {command.uses}" for command in ldr.command_handler.incoming_commands if command.uses and not command.owner and not command.sudo)) + await event.reply("\n".join(f"{command.pattern}: {command.uses}" for command in ldr.command_handler.all_incoming_commands if command.uses and not command.owner and not command.sudo)) @ldr.add("shutdown", pattern_extra="(f|)", owner=True, hide_help=True) diff --git a/ubot/modules/system.py b/ubot/modules/system.py index 9505219..beea8b6 100644 --- a/ubot/modules/system.py +++ b/ubot/modules/system.py @@ -27,7 +27,7 @@ async def start_cmd(event): @ldr.add("help", no_disable=True, pass_nsfw=True) async def help_cmd(event): if event.args: - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if not command.hide_help: if event.args == command.pattern: if command.help: @@ -39,7 +39,7 @@ async def help_cmd(event): help_dict = {} - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if not command.hide_help: if not event.nsfw_disabled or (event.nsfw_disabled and not command.nsfw): if command.module in help_dict: @@ -93,7 +93,7 @@ async def set_group_prefix(event): @ldr.add("sudohelp", sudo=True) async def sudohelp(event): if event.args: - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if command.hide_help: if event.args == command.pattern: if command.help: @@ -105,7 +105,7 @@ async def sudohelp(event): help_dict = {} - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if command.hide_help: if command.module in help_dict: help_dict[command.module].append(command.pattern) @@ -133,7 +133,7 @@ async def bot_repo(event): @ldr.add("disable", admin=True, no_private=True, help="Disables commands in the current chat, requires admin.") async def disable_command(event): if event.args: - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if event.args == command.pattern: if command.not_disableable: await event.reply(f"**{command.pattern}** cannot be disabled!") @@ -151,7 +151,7 @@ async def disable_command(event): @ldr.add("enable", admin=True, no_private=True, help="Enables commands in the current chat, requires admin.") async def enable_command(event): if event.args: - for command in ldr.command_handler.incoming_commands: + for command in ldr.command_handler.all_incoming_commands: if event.args == command.pattern: await event.reply(f"Enabling **{command.pattern}** in chat **{event.chat.id}**!") event.chat_db.enable_command(command.pattern)