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,23 +4,22 @@
# ================================== #
def mMultifun(context:EventContext, data:InputMessageData) -> None:
cmdkey = data.command.name
replyToId = None
reply_to = None
fun_strings = {}
for key in ("empty", "bot", "self", "others"):
fun_strings[key] = context.endpoint.get_string(key, data.user.settings.language)
if data.quoted:
replyFromUid = data.quoted.user.id
# TODO work on all platforms for the bot id
if replyFromUid.split(':')[1] == TelegramToken.split(':')[0] and 'bot' in Locale.__(cmdkey):
Text = choice(Locale.__(f'{cmdkey}.bot'))
elif replyFromUid == data.user.id and 'self' in Locale.__(cmdkey):
Text = choice(Locale.__(f'{cmdkey}.self')).format(data.user.name)
else:
if 'others' in Locale.__(cmdkey):
Text = choice(Locale.__(f'{cmdkey}.others')).format(data.user.name, data.quoted.user.name)
replyToId = data.quoted.message_id
if fun_strings["bot"] and (data.quoted.user.id == Platforms[context.platform].agent_info.id):
text = choice(fun_strings["bot"])
elif fun_strings["self"] and (data.quoted.user.id == data.user.id):
text = choice(fun_strings["self"]).format(data.user.name)
elif fun_strings["others"]:
text = choice(fun_strings["others"]).format(data.user.name, data.quoted.user.name)
reply_to = data.quoted.message_id
else:
if 'empty' in Locale.__(cmdkey):
Text = choice(Locale.__(f'{cmdkey}.empty'))
SendMessage(context, {"Text": Text, "ReplyTo": replyToId})
if fun_strings["empty"]:
text = choice(fun_strings["empty"])
SendMessage(context, {"text_html": text, "ReplyTo": reply_to})
RegisterModule(name="Multifun", endpoints=[
SafeNamespace(names=["hug", "pat", "poke", "cuddle", "hands", "floor", "sessocto"], handler=mMultifun),

116
ModWinDog/Multifun/Multifun.yaml Normal file → Executable file
View File

@@ -1,3 +1,119 @@
summary:
en: Provides fun trough preprogrammed text-based toys.
endpoints:
hug:
empty:
en:
- <b>Hug? You haven't replied to anyone...</b>
it:
- <b>Chi vuoi abbracciare? Rispondi a qualcuno.</b>
- <b>Un abbraccio a chi? Non hai risposto a nessuno...</b>
bot:
it:
- <b>...Grazie uwu <3</b>
- <b>Non puoi abbracciarmi ☁️ :/</b>
self:
it:
- <b>{0} allunga le braccia attorno a sè, si stringe forte, e si sente ora meno triste.</b>
others:
en:
- <b>{0} hugs {1} tightly... :3</b>
it:
- <b>{0} abbraccia {1} forte forte... :3</b>
- <b>{0} ti ha dato un abbraccio!</b>
pat:
empty:
it:
- <b>Chi vuoi accarezzare? Rispondi a qualcuno.</b>
- <b>Una carezza a chi? Non hai risposto a nessuno...</b>
bot:
it:
- <b>Rawrrr xDDdd</b>
- <b>Come vuoi accarezzarmi? Vivo nel cloud... :(</b>
self:
it:
- <b>{0} allunga goffamente la mano dietro di sè per accarezzarsi in testa 🙃</b>
others:
it:
- <b>{0} fa patpat a {1} ^.^</b>
- <b>{0} ti accarezza con dolcezza.</b>
poke:
empty:
it:
- <b>Chi vuoi punzecchiare? Rispondi a qualcuno.</b>
- <b>Punzecchiare chi? Non hai risposto a nessuno...</b>
bot:
it:
- <b>&gt;_&lt; perché?</b>
- <b>heh ☁️😌</b>
self:
it:
- <b>{0} si punzecchia :o</b>
others:
it:
- <b>{0} punzecchia {1} 👀*</b>
- <b>{0} ti punzecchia con impertinenza 👉</b>
cuddle:
empty:
it:
- <b>A chi vuoi fare le coccole? Rispondi a qualcuno.</b>
- <b>Le coccole? A chi? Non hai risposto a nessuno...</b>
bot:
it:
- <b>Aww.. grazie :3</b>
- <b>Vorrei anche io le coccole ma... ☁️😔</b>
self:
it:
- <b>{0} si stende sul letto e prova a farsi le coccole, per sentirsi meglio.</b>
others:
it:
- <b>{0} fa le coccole a {1} 🥰</b>
- <b>{0} ti fa le coccole! 🤗️</b>
floor:
empty:
it:
- <b>Il pavimento?</b>
- <b>Il pavimentowo?</b>
- <b>Vuoi mettere qualcuno sul pavimento? Rispondi ad un suo messaggio.</b>
bot:
it:
- <b>Sono già sul pavimento.. sono sempre sul pavimento.</b>
self:
it:
- <b>{0} si mette sul pavimento.</b>
others:
it:
- <b>{0} solleva {1} dal pavimento.</b>
- <b>{0} ti prende in braccio e ti appoggia con delicatezza sul pavimento.</b>
hands:
empty:
it:
- <b>Le t.me/manineuwu? 😳️</b>
- <b>A chi vuoi dare le manine? Rispondi a qualcuno.</b>
bot:
it:
- <b>Io non le ho le manine,.,. 😭️</b>
self:
it:
- <b>{0} fa handholding in solitudine... 😶️</b>
- <b>{0} non ha nessuno a cui dare la mano 😐️</b>
others:
it:
- <b>{0} prende le mani di {1} 😳️❤️</b>
- <b>{0} vuole darti la sua manina 🥺👉️👈️</b>
sessocto:
empty:
it:
- <b>Sessocto?!?! 😳️</b>
- <b>Vuoi fare sessocto con qualcuno? Rispondi ad un suo messaggio.</b>
bot:
it:
- <b>Vorrei anche io sessocto ma non ho un corpo... 😥️</b>
self:
it:
- <b>{0} fa sessocto in singleplayer 😳️</b>
others:
it:
- <b>{0} vuole fare sessocto con te... 👀️</b>
- <b>{0} e {1} fanno sessocto insieme 💑️</b>