2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-22 18:19:16 +00:00

add lenient commands to help

This commit is contained in:
Nick80835 2025-06-19 07:43:01 -04:00
parent 6a13085bd4
commit 04227f6628
3 changed files with 11 additions and 7 deletions

View File

@ -347,3 +347,7 @@ class CommandHandler():
def is_blacklisted(self, event: ExtendedNewMessage|ExtendedInlineQuery) -> bool: 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 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

View File

@ -172,7 +172,7 @@ async def dbstat(event):
@ldr.add("usage", owner=True, hide_help=True) @ldr.add("usage", owner=True, hide_help=True)
async def usagestat(event): 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) @ldr.add("shutdown", pattern_extra="(f|)", owner=True, hide_help=True)

View File

@ -27,7 +27,7 @@ async def start_cmd(event):
@ldr.add("help", no_disable=True, pass_nsfw=True) @ldr.add("help", no_disable=True, pass_nsfw=True)
async def help_cmd(event): async def help_cmd(event):
if event.args: 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 not command.hide_help:
if event.args == command.pattern: if event.args == command.pattern:
if command.help: if command.help:
@ -39,7 +39,7 @@ async def help_cmd(event):
help_dict = {} 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 command.hide_help:
if not event.nsfw_disabled or (event.nsfw_disabled and not command.nsfw): if not event.nsfw_disabled or (event.nsfw_disabled and not command.nsfw):
if command.module in help_dict: if command.module in help_dict:
@ -93,7 +93,7 @@ async def set_group_prefix(event):
@ldr.add("sudohelp", sudo=True) @ldr.add("sudohelp", sudo=True)
async def sudohelp(event): async def sudohelp(event):
if event.args: 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 command.hide_help:
if event.args == command.pattern: if event.args == command.pattern:
if command.help: if command.help:
@ -105,7 +105,7 @@ async def sudohelp(event):
help_dict = {} 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.hide_help:
if command.module in help_dict: if command.module in help_dict:
help_dict[command.module].append(command.pattern) 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.") @ldr.add("disable", admin=True, no_private=True, help="Disables commands in the current chat, requires admin.")
async def disable_command(event): async def disable_command(event):
if event.args: 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 event.args == command.pattern:
if command.not_disableable: if command.not_disableable:
await event.reply(f"**{command.pattern}** cannot be disabled!") 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.") @ldr.add("enable", admin=True, no_private=True, help="Enables commands in the current chat, requires admin.")
async def enable_command(event): async def enable_command(event):
if event.args: 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 event.args == command.pattern:
await event.reply(f"Enabling **{command.pattern}** in chat **{event.chat.id}**!") await event.reply(f"Enabling **{command.pattern}** in chat **{event.chat.id}**!")
event.chat_db.enable_command(command.pattern) event.chat_db.enable_command(command.pattern)