mirror of
https://gitlab.com/octospacc/WinDog.git
synced 2025-06-05 22:09:20 +02:00
More work on Matrix, move commands to new HTML locales, fix Mastodon
This commit is contained in:
30
ModWinDog/Echo/Echo.py
Normal file → Executable file
30
ModWinDog/Echo/Echo.py
Normal file → Executable file
@ -4,22 +4,20 @@
|
||||
# ==================================== #
|
||||
|
||||
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, OutputMessageData(text=(prefix + text)))
|
||||
else:
|
||||
SendMessage(context, OutputMessageData(text_html=context.endpoint.get_string('empty')))
|
||||
if not (text := ObjGet(data, "command.body")):
|
||||
return SendMessage(context, OutputMessageData(text_html=context.endpoint.get_string("empty", data.user.settings.language)))
|
||||
prefix = f'<a href="{data.message_url}">🗣️</a> '
|
||||
#prefix = f"[🗣️]({context.linker(data).message}) "
|
||||
if len(data.command.tokens) == 2:
|
||||
nonascii = True
|
||||
for char in data.command.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, OutputMessageData(text_html=(prefix + html_escape(text))))
|
||||
|
||||
RegisterModule(name="Echo", endpoints=[
|
||||
SafeNamespace(names=["echo"], handler=cEcho),
|
||||
|
Reference in New Issue
Block a user