钉钉机器人发送图片 python_python封装钉钉Webhook机器人消息发送逻辑
python封裝釘釘Webhook機(jī)器人消息發(fā)送邏輯,目前僅支持python2。
安裝
pip install dingmsgapi
初始化實(shí)例
from ding_msg_api import MsgClient
# Webhook機(jī)器人access_token
msgClient = MsgClient("****************")
發(fā)送Text消息
from ding_msg_api import TextMsg
# @群里所有人發(fā)文本消息
txtMsg = TextMsg()
txtMsg.set_text(txt="text message")
txtMsg.set_at_all(True)
msgClient.send_message(txtMsg)
# @某個(gè)人發(fā)文本消息
txtMsg = TextMsg()
txtMsg.set_text(txt="text message")
txtMsg.add_at_user(telephone="***********")
msgClient.send_message(txtMsg)
發(fā)送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)
發(fā)送Markdown消息
from ding_msg_api import MarkdownMsg
markDownMsg = MarkdownMsg()
markDownMsg.set_title(title="markdown message")
markDownMsg.set_text(txt="### test")
msgClient.send_message(markDownMsg)
發(fā)送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)
發(fā)送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)
參考文檔
祝您工作愉快!!!
總結(jié)
以上是生活随笔為你收集整理的钉钉机器人发送图片 python_python封装钉钉Webhook机器人消息发送逻辑的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python羊车门问题_「羊车门」经典概
- 下一篇: python histo 改变 bins