get echo bot running as foundation
This commit is contained in:
parent
2be428be70
commit
6899223ad3
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ __pycache__/
|
||||||
/.tox/
|
/.tox/
|
||||||
/build/
|
/build/
|
||||||
/venv/
|
/venv/
|
||||||
|
/accounts/
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
def main() -> None:
|
|
||||||
print("Hello World")
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
from . import main
|
|
||||||
|
|
||||||
main()
|
|
||||||
28
src/keyserver_bot/hooks.py
Normal file
28
src/keyserver_bot/hooks.py
Normal 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()
|
||||||
Loading…
Reference in a new issue