Cleanup Locale system, remove legacy Locale API, add command help handling, misc

This commit is contained in:
2024-08-07 02:27:17 +02:00
parent 6a1a21027c
commit c9895a4bed
37 changed files with 314 additions and 297 deletions

View File

@ -5,16 +5,16 @@
# TODO: implement /help <commandname> feature
def cHelp(context:EventContext, data:InputMessageData) -> None:
module_list = ''
text = (context.endpoint.get_string(lang=data.user.settings.language) or '')
language = data.user.settings.language
for module in Modules:
summary = Modules[module].get_string("summary", language)
endpoints = Modules[module].endpoints
module_list += (f"\n\n{module}" + (f": {summary}" if summary else ''))
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)
module_list += (f"\n* /{', /'.join(endpoint.names)}" + (f": {summary}" if summary else ''))
SendMessage(context, OutputMessageData(text=module_list))
text += (f"\n* /{', /'.join(endpoint.names)}" + (f": {summary}" if summary else ''))
SendMessage(context, {"text_html": text})
RegisterModule(name="Help", group="Basic", endpoints=[
SafeNamespace(names=["help"], handler=cHelp),