get echo bot running as foundation

This commit is contained in:
missytake 2025-04-04 21:34:38 +02:00
parent 2be428be70
commit 6899223ad3
Signed by: missytake
GPG key ID: 04CC6658320518DF
5 changed files with 30 additions and 6 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ __pycache__/
/.tox/ /.tox/
/build/ /build/
/venv/ /venv/
/accounts/

View file

@ -24,7 +24,7 @@ where = src
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
keyserver-bot = keyserver_bot:main keyserver-bot = keyserver_bot.hooks:main
[tox:tox] [tox:tox]
envlist = lint, py311, py312 envlist = lint, py311, py312

View file

@ -1,2 +0,0 @@
def main() -> None:
print("Hello World")

View file

@ -1,3 +0,0 @@
from . import main
main()

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""Minimal echo bot example.
it will echo back any text send to it, it also will print to console all Delta Chat core events.
Pass --help to the CLI to see available options.
"""
from deltachat_rpc_client import events, run_bot_cli
hooks = events.HookCollection()
@hooks.on(events.RawEvent)
def log_event(event):
print(event)
@hooks.on(events.NewMessage)
def echo(event):
snapshot = event.message_snapshot
snapshot.chat.send_text(snapshot.text)
def main():
run_bot_cli(hooks)
if __name__ == "__main__":
main()