Skip to content

Commit

Permalink
update advanced example
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Apr 6, 2024
1 parent bf529da commit 42e218a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions examples/echobot_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def log_event(bot, accid, event):
bot.logger.warning(event.msg)
elif event.kind == EventType.ERROR:
bot.logger.error(event.msg)
elif event.kind == EventType.MSG_DELIVERED:
bot.rpc.delete_messages(accid, [event.msg_id])
elif event.kind == EventType.SECUREJOIN_INVITER_PROGRESS:
if event.progress == 1000 and not bot.rpc.get_contact(accid, event.contact_id).is_bot:
# bot's QR scanned by an user, send introduction message
Expand All @@ -41,18 +43,25 @@ def log_event(bot, accid, event):
bot.rpc.send_msg(accid, chatid, reply)


@cli.on(events.NewMessage(is_info=True))
def delete_info_msgs(bot, accid, event):
bot.rpc.delete_messages(accid, [event.msg.id])


@cli.on(events.NewMessage(is_info=False))
def echo(bot, accid, event):
if bot.has_command(event.command):
return
msg = event.msg
bot.rpc.send_msg(accid, msg.chat_id, MsgData(text=msg.text))
bot.rpc.delete_messages(accid, [msg.id])


@cli.on(events.NewMessage(command="/help"))
def _help(bot, accid, event):
msg = event.msg
bot.rpc.send_msg(accid, msg.chat_id, MsgData(text="I will repeat anything you say to me"))
bot.rpc.delete_messages(accid, [msg.id])


def test(_cli, bot, args):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
]
dependencies = [
"deltachat2[full]",
"deltachat2[full]>0.4.0",
"appdirs>=1.4.4",
"rich>=12.6.0",
"qrcode>=7.4.2",
Expand Down

0 comments on commit 42e218a

Please sign in to comment.