deltachat-bot / deltachat-bot/echo

Example echobot.py is broken (ImportError: cannot import name 'MsgData' from 'deltachat2')

Open Beginner friendly
#89 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
25
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Following the steps from this repository resulted in the following error message:

```
$ python ./echobot.py init DCACCOUNT:https://nine.testrun.org/new

Traceback (most recent call last):
File "/root/deltachat-bot/./echobot.py", line 5, in
from deltachat2 import MsgData, events
ImportError: cannot import name 'MsgData' from 'deltachat2' (/root/user/.venv/lib/python3.13/site-packages/deltachat2/__init__.py)
```

Looking into the repository of the [Python library](https://github.com/deltachat-bot/deltabot-cli-py/tree/main) shows that the code has to be changed:

Working version of echobot.py:
```python3
#!/usr/bin/env python3
from deltachat2 import MessageData, events
from deltabot_cli import BotCli

cli = BotCli("echobot")

@cli.on(events.RawEvent)
def log_event(bot, accid, event):
bot.logger.info(event)

@cli.on(events.NewMessage)
def echo(bot, accid, event):
msg = event.msg
bot.rpc.send_msg(accid, msg.chat_id, MessageData(text=msg.text))

if __name__ == "__main__":
cli.start()
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Open echobot.py and compare its deltachat2 imports and message construction with the current Python library API referenced in the issue. Run the documented python ./echobot.py init command afterward to verify that the example starts without the ImportError and retains its echo behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.