Misc updates, improve global API, start work on db and module strings

This commit is contained in:
2024-06-25 02:08:49 +02:00
parent 7d426e9497
commit 8f1b80ab14
26 changed files with 389 additions and 210 deletions

27
ModWinDog/Echo/Echo.py Normal file
View File

@@ -0,0 +1,27 @@
# ==================================== #
# WinDog multi-purpose chatbot #
# Licensed under AGPLv3 by OctoSpacc #
# ==================================== #
def cEcho(context:EventContext, data:InputMessageData) -> None:
text = ObjGet(data, "command.body")
if text:
prefix = "🗣️ "
#prefix = f"[🗣️]({context.linker(data).message}) "
if len(data.Tokens) == 2:
nonascii = True
for char in data.Tokens[1]:
if ord(char) < 256:
nonascii = False
break
if nonascii:
# text is not ascii, probably an emoji (altough not necessarily), so just pass as is (useful for Telegram emojis)
prefix = ''
SendMessage(context, {"Text": (prefix + text)})
else:
SendMessage(context, {"Text": choice(Locale.__('echo.empty'))}) #context.endpoint.get_string('empty')
RegisterModule(name="Echo", endpoints=[
SafeNamespace(names=["echo"], handler=cEcho),
])