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

@@ -4,10 +4,13 @@
# ==================================== #
def mPercenter(context:EventContext, data:InputMessageData) -> None:
SendMessage(context, {"Text": choice(Locale.__(f'{data.command.name}.{"done" if data.command.body else "empty"}')).format(
Cmd=data.command.tokens[0], Percent=RandPercent(), Thing=data.command.body)})
SendMessage(context, {"text_html": (context.endpoint.get_string(
("done" if data.command.body else "empty"),
data.user.settings.language
) or context.endpoint.help_text(data.user.settings.language)
).format(RandPercent(), data.command.body)})
RegisterModule(name="Percenter", endpoints=[
SafeNamespace(names=["wish", "level"], handler=mPercenter),
SafeNamespace(names=["wish", "level"], handler=mPercenter, body=True),
])

27
ModWinDog/Percenter/Percenter.yaml Normal file → Executable file
View File

@@ -1,3 +1,30 @@
summary:
en: Provides fun trough percentage-based toys.
endpoints:
wish:
empty:
en: |
<b>You wished for nothing! ✨</b>
<i>Nothing happens...</i>
it: |
<b>Non hai desiderato nulla! ✨</b>
<i>Non succede niente...</i>
done:
en: |
<b>Your wish has been cast! ✨</b>
<i>Chance of success: <b>{0}%</b>.</i>
it: |
<b>Il tuo desiderio è stato espresso! ✨</b>
<i>Probabilità che si avveri: <b>{0}%</b>.</i>
level:
summary:
en: Check what's your level of something.
it: Controlla il tuo livello di qualcosa.
done:
en: <i>Your level of <b>{1}</b> is... <b>{0}%</b>.</i>
it: <i>Il tuo livello di <b>{1}</b> è... <b>{0}%</b>.</i>