跳转到主要内容

Delta Chat核心JSON-RPC接口的客户端库

项目描述

Delta Chat的Python客户端库

Latest Release CI Code style: black

Delta Chat核心JSON-RPC接口的客户端库

安装

pip install deltachat2

要使用此库,您需要安装deltachat-rpc-server程序,您可以使用以下命令与库一起安装:

pip install deltachat2[full]

用法

使用deltachat2编写的示例echo-bot

from deltachat2 import events, run_bot_cli

hooks = events.HookCollection()

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

@hooks.on(events.NewMessage)
def echo(bot, accid, event):
    msg = event.msg
    bot.rpc.misc_send_text_message(accid, msg.chat_id, msg.text)

if __name__ == "__main__":
    run_bot_cli(hooks)

将以上代码保存到echobot.py文件中,然后用Python运行它

python echobot.py --email bot@example.com --password MyPassword

然后使用您的Delta Chat客户端向bot地址发送消息以测试其是否正常工作。

更快地开发机器人 ⚡

如果您想要开发机器人,您可能应该使用此库与deltabot-cli-py一起使用,它将创建bot CLI的重复性过程移除,让您专注于编写消息处理逻辑。

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

deltachat2-0.6.2.tar.gz (19.7 kB 查看哈希值)

上传于 源代码

构建分发版

deltachat2-0.6.2-py3-none-any.whl (19.9 kB 查看哈希值)

上传于 Python 3

支持