More work on Matrix, move commands to new HTML locales, fix Mastodon

This commit is contained in:
2024-06-28 01:57:42 +02:00
parent 2c73846554
commit 4afb5f3275
28 changed files with 307 additions and 271 deletions

30
ModWinDog/Echo/Echo.py Normal file → Executable file
View 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),