mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 03:24:20 +00:00
✨ #1 Add /man (/help)
This commit is contained in:
parent
bfd31cdb49
commit
caee06f877
3 changed files with 33 additions and 0 deletions
|
@ -57,6 +57,7 @@ register_telegram(commands.fortune, ["fortune"])
|
||||||
register_telegram(commands.pmots, ["pmots"])
|
register_telegram(commands.pmots, ["pmots"])
|
||||||
register_telegram(commands.spell, ["spell"], "(?P<spellname>.+)")
|
register_telegram(commands.spell, ["spell"], "(?P<spellname>.+)")
|
||||||
register_telegram(commands.smecds, ["smecds"])
|
register_telegram(commands.smecds, ["smecds"])
|
||||||
|
register_telegram(commands.man, ["man", "help"], "(?P<commandname>[A-Za-z]+)")
|
||||||
|
|
||||||
|
|
||||||
pda.implementations["telethon.1"].register_conversation(r)
|
pda.implementations["telethon.1"].register_conversation(r)
|
||||||
|
|
|
@ -11,3 +11,4 @@ from .fortune import *
|
||||||
from .pmots import *
|
from .pmots import *
|
||||||
from .spell import *
|
from .spell import *
|
||||||
from .smecds import *
|
from .smecds import *
|
||||||
|
from .man import *
|
||||||
|
|
31
royalpack/commands/man.py
Normal file
31
royalpack/commands/man.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import royalnet.engineer as engi
|
||||||
|
|
||||||
|
|
||||||
|
@engi.TeleportingConversation
|
||||||
|
async def man(*, _msg: engi.Message, _router: engi.Router, commandname: str, **__):
|
||||||
|
"""
|
||||||
|
Visualizza aiuto per un comando.
|
||||||
|
|
||||||
|
Non funziona ancora correttamente per i multicomandi, come /dog: https://github.com/Steffo99/royalnet/issues/11 !
|
||||||
|
"""
|
||||||
|
|
||||||
|
# TODO: Change this when royalnet/#11 is fixed!
|
||||||
|
|
||||||
|
if not (command := _router.by_name.get(commandname)):
|
||||||
|
await _msg.reply(text="⚠️ Il comando che hai specificato non esiste.")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
command = command.__getattribute__("bare_function")
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
msg = [
|
||||||
|
f"ℹ️ Manuale di {commandname}:",
|
||||||
|
f"{command.__doc__}",
|
||||||
|
]
|
||||||
|
|
||||||
|
await _msg.reply(text="\n".join(msg))
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ("man",)
|
Loading…
Reference in a new issue