zhuifengshen / dingtalkchatbot Goto Github PK
View Code? Open in Web Editor NEW钉钉群自定义机器人消息Python封装
Home Page: https://pypi.org/project/DingtalkChatbot/
License: MIT License
钉钉群自定义机器人消息Python封装
Home Page: https://pypi.org/project/DingtalkChatbot/
License: MIT License
Outgoing 怎么调用???
能接收消息吗?
通过outgoing能够获取到@方的dingtalkid ,无法获取手机号码,不能直接通过at_mobiles
但是通过 at_dingtalk_ids 好像不起作用.
因为消息艾特通知强度不大。。唉
请问默认fail_notice=False不通知这个参数在可以在自己编写的代码中定义吗?在哪里定义呢?
xiaoding = DingtalkChatbot(webhook=webhook, secret=secret)
提示错误
xiaoding = DingtalkChatbot(webhook=webhook, secret=secret)
TypeError: init() got an unexpected keyword argument 'secret'
不知如何正常显示内网图片呢
cardItem = CardItem(title=title_list[element],
url=link_list[element],
pic_url=pic_list[element])
USE:
send_feed_card(cards)
ERROR:
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\site-packages\dingtalkchatbot\chatbot.py", line 267, in send_feed_card
link['messageURL'] = self.msg_open_type(link['messageURL'])
python version 3.8.0
lib version 1.5.3
it all works fine until today, perhaps dingtalk offical did some changes?
request library is missing in setup.py
只开一个进程,结果今天发现钉钉机器人报错
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='oapi.dingtalk.com', port=443): Max retries exceeded with url: /robot/send?access_token=XX(token隐藏) (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000017F89A71C70>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
是钉钉更改了链接数了么?之前没问题的
ERROR:root:消息发送失败,自动通知:{'msgtype': 'text', 'text': {'content': '钉钉机器人消息发送失败,原因:keywords not in content'}, 'at': {'isAtAll': True}}
No package 'libffi' found
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
[root@localhost DingtalkChatbot-master]# yum install python-devel
想把prometheus的alertmanager发到这边做告警
同问题,谢谢~
定时执行方案有没有推荐一个
创建的机器人没有outgoing功能,如何去开通?
这个模块相当好,但还需要再封装成一个通用的模块。代码dingRobotDev.py如下:直接运行此文件python3 dingRobotDev.py 即可运行demo的text模式,发送如果失败,有三次机会发送。不足之处请指正。
#!/usr/env/python3
#encoding=utf-8
from enum import Enum
import time
from dingtalkchatbot.chatbot import DingtalkChatbot
from contextlib import contextmanager
from contextlib import closing
class sendkind(Enum):
text = 't'
link = 'l'
image = 'i'
markdown = 'm'
action_card = 'a'
feed_card = 'f'
class dingRobot(object):
def init(self,webhook='YOURWEBHOOK',secret=None,pc_slide=None,kind=sendkind.text,
msgargs={'msg':'我就是小丁,小丁就是我!','is_at_all':True},retry=3,flag=True):
self.webhook=webhook
self.secret=secret
self.pc_slide=pc_slide
self.kind=kind
print(self.kind)
print(self.kind.value)
print(self.kind.name)
self.msgargs=msgargs
self.retry=retry
self.flag=flag
self.kw = {'secret':self.secret,'pc_slide':self.pc_slide}
#self.xiaoding = None
self.xiaoding = DingtalkChatbot(self.webhook,**self.kw)
def pushMsg(self):
kindsendfunc = 'self.xiaoding.send_%s'%self.kind.name
yield eval('%s(**self.msgargs)'%kindsendfunc)
def demo(self):
for t in range(self.retry):
time.sleep(4**t)
with closing(self.pushMsg()) as push:
print(push)
for i in push:
print('in for',i)
print(i)
if i['errcode']==0 and i['errmsg']=='ok':
break
if name == 'main':
dingRobot().demo()
经过检查代码,应该是self.webhook的问题,由于sign和timestamp的存在,导致每次post消息后,并没有把self.webhook恢复到原来的webhook,而是带上了上一次的timestamp和sign。最终多次发送消息后,导致url过长,钉钉拒绝接受消息。
希望大佬可以换个变量名,稍微改改。
按照 https://github.com/zhuifengshen/DingtalkChatbot 里的example,为什么会报错?
sz@air:/mnt/d/coding$ python dd.py
Traceback (most recent call last):
File "dd.py", line 65, in <module>
card1 = CardItem(title="氧气美女", url="https://www.dingtalk.com/", pic_url="https://unzippedtv.com/wp-content/uploads/sites/28/2016/02/asian.jpg")
NameError: name 'CardItem' is not defined
有谁能指点下不?
突然间就报错:SSL: CERTIFICATE_VERIFY_FAILED
在requests.post加了verify=False绕过去了,是否要把这个参数暴露出来?提升兼容性?还有更好的解决方案吗?
老哥好,我在尝试使用这个机器人发送图片。我发现如果使用本机图片路径好像不支持。我最近尝试先发送一个地址,15分钟后再上传图片好像不支持,消息都显示不出来图片。请问怎么解决这个问题呢?
(●─●)。翻遍所有文档没看到相关内容。首先我不是企业管理员。我只想在群组里收到 at 的时候自动 回复 "收到,我已在处理中"。
如题
如题, 期望支持代理功能
非常感谢分享
但在使用过程当中发现每次发完消息之后代码都卡住好久了,然后才发现原来是代码没用异步,
因此建议下大佬可以试试async
执行pip install DingtalkChatbot
该命令后报错如下:
ERROR: Could not find a version that satisfies the requirement DingtalkChatbot ERROR: No matching distribution found for DingtalkChatbot
相关版本:
Python 3.6.8
Django 1.11.4
如果图片无法发送,请把链接转为 url编码的格式,昨天晚上开始钉钉无法推送图片,改成url编码就好了
不知道怎么报错
python3.5 Env:
NameError: name 'DtalkChatbot' is not defined
code:
from dingtalkchatbot.chatbot import DingtalkChatbot
webhook = 'https://oapi.dingtalk.com/robot/send?access_token=xxx'
xiaoding = DtalkChatbot(webhook)
xiaoding.send_text(msg='我就是小丁,小丁就是我!', is_at_all=True)
我得到了钉钉机器人的webhook地址, 我需要在远程服务器上通过钉钉机器人向钉钉群发送消息,但是我发现并不能建立和钉钉机器人的连接,例如send_text()方法一直没有反应,最终提示connection time error.请问一下有解决方法吗
楼主,请问钉钉群里不让加那个 webhook 的机器人,要如何获取你说的那个地址呢?
我的需求是:
在自己的服务器给某个钉钉群发一个图文消息或图片消息
用接口获取到文本信息后,在控制台是中文的,推送到企业微信是utf8编码而非中文,企业微信用的是utf8编码
我想用来 收到某个发件人的邮件,然后把这邮件标题 发件人 收件人 通过钉钉机器人发到群里提醒
其实我是用来做一个 订单提醒功能, 由于我的订单消息都是通过邮件接收,我员工是用ERP系统,同步不及时,所以希望用邮件 转发信息到钉钉 . 提醒 .
请教使用方法
hi,你好可以帮忙看看这个问题嘛,
HTTPSConnectionPool(host='oapi.dingtalk.com', port=443): Max retries exceeded with url: /robot/send?access_token=xxxxxxxxxxx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))"
我在本地电脑上执行发送没问题,放在服务器上执行就报错了,可以帮忙看看嘛
HTTPSConnectionPool(host='oapi.dingtalk.com', port=443): Max retries exceeded with url: /robot/send?access_token=xxxxxxxxxxxxxx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))"
我在本地电脑上执行发送没问题,放在服务器上执行就报错了,可以帮忙看看嘛
大佬你好,我最近在使用 DingtalkChatbot,目前在研究 Markdown 的方式来发消息
本来发送的好好的,也能艾特所有人,但是我看了一下参数,有个 is_auto_at 这个参数,我手欠给设置成了 False
之后再取消掉这个参数,即便设置了 at_mobiles 也不是蓝色的艾特,系统也不会弹窗提示。把 is_auto_at 参数设置成 True 后,依旧不会蓝字,钉钉界面里有提示自己被艾特了,但是依旧不会弹窗提示
想问一下这该怎么解决???
我看例子都是群机器人。
谢谢🙏
换公司,换成了企业微信,可否支持这个?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.