mirror of
https://gitlab.com/octospacc/WinDog.git
synced 2025-06-05 22:09:20 +02:00
Misc updates, improve global API, start work on db and module strings
This commit is contained in:
27
ModWinDog/Echo/Echo.py
Normal file
27
ModWinDog/Echo/Echo.py
Normal 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),
|
||||
])
|
||||
|
Reference in New Issue
Block a user