diff --git a/hikka/modules/help.py b/hikka/modules/help.py index 232ffab..1da3eea 100644 --- a/hikka/modules/help.py +++ b/hikka/modules/help.py @@ -4,6 +4,12 @@ # You can redistribute it and/or modify it under the terms of the GNU AGPLv3 # πŸ”‘ https://www.gnu.org/licenses/agpl-3.0.html +# ©️ Codrago, 2024-2025 +# This file is a part of Heroku Userbot +# 🌐 https://github.com/coddrago/Heroku +# You can redistribute it and/or modify it under the terms of the GNU AGPLv3 +# πŸ”‘ https://www.gnu.org/licenses/agpl-3.0.html + import re import difflib import inspect @@ -159,34 +165,21 @@ class Help(loader.Module): if await self.allmodules.check_security(message, func) } - # Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅: Π£Π½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΈΠ½Π»Π°ΠΉΠ½-Ρ…Π΅Π½Π΄Π»Π΅Ρ€Ρ‹ if hasattr(module, "inline_handlers"): - seen_inline = set() for name, fun in module.inline_handlers.items(): - if name not in seen_inline: - reply += ( - "\nπŸ€–" - " {} {}".format( - f"@{self.inline.bot_username} {name}", - ( - utils.escape_html(inspect.getdoc(fun)) - if fun.__doc__ - else self.strings("undoc") - ), - ) + reply += ( + "\nπŸ€–" + " {} {}".format( + f"@{self.inline.bot_username} {name}", + ( + utils.escape_html(inspect.getdoc(fun)) + if fun.__doc__ + else self.strings("undoc") + ), ) - seen_inline.add(name) + ) - # Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅: Π£Π½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ с алиасами - seen_commands = set() for name, fun in commands.items(): - if name in seen_commands: - continue - - seen_commands.add(name) - aliases = self.find_aliases(name) - seen_commands.update(aliases) - reply += ( f'\n{self.config["command_emoji"]}' " {}{}{} {}".format( @@ -199,10 +192,10 @@ class Help(loader.Module): utils.escape_html(self.get_prefix()), alias, ) - for alias in aliases + for alias in self.find_aliases(name) ) ) - if aliases + if self.find_aliases(name) else "" ), ( @@ -256,13 +249,7 @@ class Help(loader.Module): core_ = [] no_commands_ = [] - # Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅: Π£Π½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΌΠΎΠ΄ΡƒΠ»ΠΈ - processed_modules = set() for mod in self.allmodules.modules: - if mod.__class__.__name__ in processed_modules: - continue - processed_modules.add(mod.__class__.__name__) - if not hasattr(mod, "commands"): logger.debug("Module %s is not inited yet", mod.__class__.__name__) continue @@ -293,15 +280,20 @@ class Help(loader.Module): ) first = True - # Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅: Π£Π½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ - commands = list({ + commands = [ name for name, func in mod.commands.items() if await self.allmodules.check_security(message, func) or force - }) + ] - # Π˜ΡΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅: Π£Π½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹Π΅ ΠΈΠ½Π»Π°ΠΉΠ½ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ - icommands = list({ + for cmd in commands: + if first: + tmp += f": ( {cmd}" + first = False + else: + tmp += f" | {cmd}" + + icommands = [ name for name, func in mod.inline_handlers.items() if await self.inline.check_inline_security( @@ -309,16 +301,14 @@ class Help(loader.Module): user=message.sender_id, ) or force - }) + ] - for cmd in commands + icommands: + for cmd in icommands: if first: - prefix = "πŸ€– " if cmd in icommands else "" - tmp += f": ( {prefix}{cmd}" + tmp += f": ( πŸ€– {cmd}" first = False else: - prefix = "πŸ€– " if cmd in icommands else "" - tmp += f" | {prefix}{cmd}" + tmp += f" | πŸ€– {cmd}" if commands or icommands: tmp += " )" @@ -367,4 +357,4 @@ class Help(loader.Module): else "πŸͺ" ) ), - ) \ No newline at end of file + )