Merge branch 'dev-test' of https://github.com/coddrago/Heroku into dev-test

pull/171/head
ZetGo | Aleksej K. 2025-08-24 12:56:54 +03:00
commit 3105a9c36c
2 changed files with 9 additions and 8 deletions

View File

@ -923,13 +923,13 @@ class Modules:
return next(
(
(cmd, self.commands[cmd.lower()])
(cmd, self.commands[cmd.split()[0].lower()])
for cmd in [
_command,
self.aliases.get(_command.lower()),
self.find_alias(_command),
]
if cmd and cmd.lower() in self.commands
if cmd and cmd.split()[0].lower() in self.commands
),
(_command, None),
)
@ -1165,12 +1165,12 @@ class Modules:
handler.id,
)
def add_alias(self, alias: str, cmd: str) -> bool:
def add_alias(self, alias: str, cmd: str, args: str = None) -> bool:
"""Make an alias"""
if cmd not in self.commands:
return False
self.aliases[alias.lower().strip()] = cmd
self.aliases[alias.lower().strip()] = f"{cmd} {args}" if args else cmd
return True
def remove_alias(self, alias: str) -> bool:

View File

@ -240,17 +240,18 @@ class CoreMod(loader.Module):
@loader.command()
async def addalias(self, message: Message):
if len(args := utils.get_args(message)) != 2:
if len(args := utils.get_args(message)) < 2:
await utils.answer(message, self.strings("alias_args"))
return
alias, cmd = args
if self.allmodules.add_alias(alias, cmd):
alias, cmd, *rest = args
rest = " ".join(rest) if rest else None
if self.allmodules.add_alias(alias, cmd, rest):
self.set(
"aliases",
{
**self.get("aliases", {}),
alias: cmd,
alias: f"{cmd} {rest}" if rest else cmd,
},
)
await utils.answer(