1
Fork 0
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:
Steffo 2021-04-18 17:47:44 +02:00
parent bfd31cdb49
commit caee06f877
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 33 additions and 0 deletions

View file

@ -57,6 +57,7 @@ register_telegram(commands.fortune, ["fortune"])
register_telegram(commands.pmots, ["pmots"])
register_telegram(commands.spell, ["spell"], "(?P<spellname>.+)")
register_telegram(commands.smecds, ["smecds"])
register_telegram(commands.man, ["man", "help"], "(?P<commandname>[A-Za-z]+)")
pda.implementations["telethon.1"].register_conversation(r)

View file

@ -11,3 +11,4 @@ from .fortune import *
from .pmots import *
from .spell import *
from .smecds import *
from .man import *

31
royalpack/commands/man.py Normal file
View 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",)