Skip to main content

A Python library for sending messages to DingTalk chatbot, which supports http prxoy for websocket

Project description

DingTalk Stream Mode 介绍

Python SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk chatbot

钉钉支持 Stream 模式接入事件推送、机器人收消息以及卡片回调,该 SDK 实现了 Stream 模式。相比 Webhook 模式,Stream 模式可以更简单的接入各类事件和回调。

特别说明

注意:

  • 因拼写错误,从旧版本升级到 v0.13.0 时候,需要将 register_callback_hanlder 修改为 register_callback_handler

快速开始

准备工作

快速开始指南

1、安装 dingtalk-stream

pip3 install dingtalk-stream

2、创建企业内部应用

进入钉钉开发者后台,创建企业内部应用,获取ClientID(即 AppKey)和ClientSecret( 即AppSecret)。

发布应用:在开发者后台左侧导航中,点击“版本管理与发布”,点击“确认发布”,并在接下来的可见范围设置中,选择“全部员工”,或者按需选择部分员工。

3、Stream 模式的机器人(可选)

如果不需要使用机器人功能的话,可以不用创建。

在应用管理的左侧导航中,选择“消息推送”,打开机器人能力,设置机器人基本信息。

注意:消息接收模式中,选择 “Stream 模式”

Stream 模式

点击“点击调试”按钮,可以创建测试群进行测试。

项目中提供了两个关于机器人的测试案例:

3.1 CalcBot

将用户输入的内容进行数学表达式计算,并以文本消息的方式返回计算结果。

启动服务:

cd examples/calcbot
python3 calcbot.py --client_id "put-your-client-id-here" --client_secret "put-your-client-secret-here"

测试效果: calcbot

3.2 CardBot

接收用户输入,返回一张互动卡片,随后更新卡片的文本和图片内容。

启动服务:

cd examples/cardbot
python3 cardbot.py --client_id "put-your-client-id-here" --client_secret "put-your-client-secret-here"

测试效果: cardbot

事件订阅切换到 Stream 模式(可选)

进入钉钉开发者后台,选择企业内部应用,在应用管理的左侧导航中,选择“事件与回调”。 “订阅管理”中,“推送方式”选项中,选择 “Stream 模式”,并保存

技术支持

点击链接,加入Stream模式共创群交流

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dingtalk-stream-wsproxy-0.15.5.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dingtalk_stream_wsproxy-0.15.5-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file dingtalk-stream-wsproxy-0.15.5.tar.gz.

File metadata

  • Download URL: dingtalk-stream-wsproxy-0.15.5.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for dingtalk-stream-wsproxy-0.15.5.tar.gz
Algorithm Hash digest
SHA256 4111c59da1c3cc348ea23713c1dbf6f0fc23c71f717c16197c8062b03514bf0e
MD5 c6fc36fd7f8464ed17a166ae841d0806
BLAKE2b-256 e5ea2e4ae8c2256095b1edfcd3fd499ba23ceb3847a46241a5eec52a9770bafe

See more details on using hashes here.

File details

Details for the file dingtalk_stream_wsproxy-0.15.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dingtalk_stream_wsproxy-0.15.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2b49b6b900b241aab5e5832566d31653995472bfe4b51059e0a010628b3a1efa
MD5 c496567fdf2020e1712b8d90a143fc30
BLAKE2b-256 7ee4eedd0924593806a1337b90315d396fd90d52015a680b3008c944524c46a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page