Move all new strings to YAML, basic working Matrix backend with text messages

This commit is contained in:
2024-06-29 01:52:53 +02:00
parent 4afb5f3275
commit 6d2f51f02c
23 changed files with 153 additions and 81 deletions

View File

@ -1,7 +1,7 @@
# ==================================== #
# WinDog multi-purpose chatbot #
# Licensed under AGPLv3 by OctoSpacc #
# ==================================== #
# ================================== #
# WinDog multi-purpose chatbot #
# Licensed under AGPLv3 by OctoSpacc #
# ================================== #
def cSource(context:EventContext, data:InputMessageData) -> None:
SendMessage(context, {"TextPlain": ("""\
@ -28,7 +28,10 @@ def cConfig(context:EventContext, data:InputMessageData) -> None:
# ... userdata: import, export, delete
def cPing(context:EventContext, data:InputMessageData) -> None:
SendMessage(context, {"Text": "*Pong!*"})
# nice experiment, but it won't work with Telegram since time is not to milliseconds (?)
#time_diff = (time_now := int(time.time())) - (time_sent := data.datetime)
#SendMessage(context, OutputMessageData(text_html=f"<b>Pong!</b>\n\n{time_sent} → {time_now} = {time_diff}"))
SendMessage(context, OutputMessageData(text_html="<b>Pong!</b>"))
#def cTime(update:Update, context:CallbackContext) -> None:
# update.message.reply_markdown_v2(
@ -39,12 +42,12 @@ def cEval(context:EventContext, data:InputMessageData) -> None:
SendMessage(context, {"Text": choice(Locale.__('eval'))})
RegisterModule(name="Base", endpoints=[
SafeNamespace(names=["source"], summary="Provides a copy of the bot source codes and/or instructions on how to get it.", handler=cSource),
SafeNamespace(names=["source"], handler=cSource),
SafeNamespace(names=["config"], handler=cConfig, arguments={
"get": True,
}),
#SafeNamespace(names=["gdpr"], summary="Operations for european citizens regarding your personal data.", handler=cGdpr),
SafeNamespace(names=["ping"], summary="Responds pong, useful for testing messaging latency.", handler=cPing),
SafeNamespace(names=["ping"], handler=cPing),
#SafeNamespace(names=["eval"], summary="Execute a Python command (or safe literal operation) in the current context. Currently not implemented.", handler=cEval),
#SafeNamespace(names=["format"], summary="Reformat text using an handful of rules. Not yet implemented.", handler=cFormat),
#SafeNamespace(names=["frame"], summary="Frame someone's message into a platform-styled image. Not yet implemented.", handler=cFrame),