pull/136/head
Who? 2025-04-30 20:23:42 +07:00 committed by GitHub
parent 9c5b5cd7ee
commit 2355a7dba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 43 deletions

View File

@ -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<emoji document_id=5372981976804366741>🤖</emoji>"
" <code>{}</code> {}".format(
f"@{self.inline.bot_username} {name}",
(
utils.escape_html(inspect.getdoc(fun))
if fun.__doc__
else self.strings("undoc")
),
)
reply += (
"\n<emoji document_id=5372981976804366741>🤖</emoji>"
" <code>{}</code> {}".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"]}'
" <code>{}{}</code>{} {}".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 "🪐"
)
),
)
)