mirror of
https://gitlab.com/octospacc/WinDog.git
synced 2025-06-05 22:09:20 +02:00
Legacy removals, code restructuring, add send_... functions and better help
This commit is contained in:
@ -1,23 +1,32 @@
|
||||
# ================================== #
|
||||
# WinDog multi-purpose chatbot #
|
||||
# Licensed under AGPLv3 by OctoSpacc #
|
||||
# ================================== #
|
||||
# ==================================== #
|
||||
# WinDog multi-purpose chatbot #
|
||||
# Licensed under AGPLv3 by OctoSpacc #
|
||||
# ==================================== #
|
||||
|
||||
# TODO: implement /help <commandname> feature
|
||||
def cHelp(context:EventContext, data:InputMessageData) -> None:
|
||||
text = (context.endpoint.get_string(lang=data.user.settings.language) or '').strip()
|
||||
language = data.user.settings.language
|
||||
for module in Modules:
|
||||
summary = Modules[module].get_string("summary", language)
|
||||
endpoints = Modules[module].endpoints
|
||||
text += (f"\n\n{module}" + (f": {summary}" if summary else ''))
|
||||
for endpoint in endpoints:
|
||||
summary = Modules[module].get_string(f"endpoints.{endpoint.names[0]}.summary", language)
|
||||
text += (f"\n* /{', /'.join(endpoint.names)}" + (f": {summary}" if summary else ''))
|
||||
text = text.strip()
|
||||
SendMessage(context, {"text_html": text})
|
||||
prefix = data.command.prefix
|
||||
if (endpoint := data.command.arguments.endpoint):
|
||||
if endpoint[0] in CommandPrefixes:
|
||||
endpoint = endpoint[1:]
|
||||
if endpoint in Endpoints:
|
||||
return send_message(context, {"text_html": get_help_text(endpoint, language, prefix)})
|
||||
text = (context.endpoint.get_string(lang=data.user.settings.language) or '').strip()
|
||||
for group in ModuleGroups:
|
||||
text += f"\n\n[ {group} ]"
|
||||
for module in ModuleGroups[group]:
|
||||
summary = Modules[module].get_string("summary", language)
|
||||
endpoints = Modules[module].endpoints
|
||||
text += (f"\n\n{module}" + (f": {summary}" if summary else ''))
|
||||
for endpoint in endpoints:
|
||||
summary = Modules[module].get_string(f"endpoints.{endpoint.names[0]}.summary", language)
|
||||
text += (f"\n* {prefix}{', {prefix}'.join(endpoint.names)}" + (f": {summary}" if summary else ''))
|
||||
text = text.strip()
|
||||
return send_message(context, {"text_html": text})
|
||||
|
||||
RegisterModule(name="Help", group="Basic", endpoints=[
|
||||
SafeNamespace(names=["help"], handler=cHelp),
|
||||
SafeNamespace(names=["help"], handler=cHelp, arguments={
|
||||
"endpoint": False,
|
||||
}),
|
||||
])
|
||||
|
||||
|
Reference in New Issue
Block a user