python封装钉钉Webhook机器人消息发送逻辑,目前仅支持python2。
安装
pip install dingmsgapi
初始化实例
from ding_msg_api import MsgClient
# Webhook机器人access_token
msgClient = MsgClient("****************")
发送Text消息
from ding_msg_api import TextMsg
# @群里所有人发文本消息
txtMsg = TextMsg()
txtMsg.set_text(txt="text message")
txtMsg.set_at_all(True)
msgClient.send_message(txtMsg)
# @某个人发文本消息
txtMsg = TextMsg()
txtMsg.set_text(txt="text message")
txtMsg.add_at_user(telephone="***********")
msgClient.send_message(txtMsg)
发送Link消息
from ding_msg_api import LinkMsg
linkMsg = LinkMsg()
linkMsg.set_title(title="link message")
linkMsg.set_text(txt="test")
linkMsg.set_picUrl(pic_url="")
linkMsg.set_messageUrl(message_url="")
msgClient.send_message(linkMsg)
发送Markdown消息
from ding_msg_api import MarkdownMsg
markDownMsg = MarkdownMsg()
markDownMsg.set_title(title="markdown message")
markDownMsg.set_text(txt="### test")
msgClient.send_message(markDownMsg)
发送ActionCard消息
from ding_msg_api import ActionCardMsg
actionCardMsg = ActionCardMsg()
actionCardMsg.set_title(title="actioncard message")
actionCardMsg.set_text(txt="test")
actionCardMsg.set_singleTitle(single_title="test")
actionCardMsg.set_singleURL(single_url="")
msgClient.send_message(actionCardMsg)
发送FeedCard消息
from ding_msg_api import FeedCardMsg
feedCardMsg = FeedCardMsg()
for i in range(5):
feedCardMsg.add_feed_link(title="test%d" % i, message_url="messageURL%d" % i, pic_url="picUrl%d" % i)
msgClient.send_message(feedCardMsg)
参考文档
祝您工作愉快!!!
Metadata
Release files for dingmsgapi 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dingmsgapi-0.0.4.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dingmsgapi-0.0.4-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 7.0 kB
Release files / dingmsgapi-0.0.4.tar.gz
| Download URL | dingmsgapi-0.0.4.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56f12881757a090ec9ed7f8606adbc1d37db17a0f38104fd9ac5c6b6f2c178a8
|
|
BLAKE2b-256 checksum How to use checksums |
495b9d53ba878a5b474eae7712670a1086d5606a77d0d295eb2bbff0c62573ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.10
|
Release files / dingmsgapi-0.0.4-py2-none-any.whl
| Download URL | dingmsgapi-0.0.4-py2-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
9642fd5a8ce1b36613292486d3c36d7333aa854df0c17a2aace6a9bf2981d345
|
|
BLAKE2b-256 checksum How to use checksums |
22fb1208ede75143416261b04a1fdf7acdd3a9a58eae673899cb3b9d0b514035
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.10
|