-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webhook功能中添加钉钉机器人的webhook支持 #1184
Comments
我看错了,钉钉的话暂未支持,虽然很像也不能用。 但你可以根据文档提供的示例写一个把bgi webhook包装成合法webhook的转发器就可以用。 |
整挺好,这不是能用了( 我突然好奇别的开源项目怎么为大几十种不同app的webhook/通知做适配了 |
主要是平时不用飞书,这个飞书还是昨天刚刚下来到公司电脑的。所以还是想要一个钉钉的适配 |
为什么你程序截图是钉钉,效果截图是飞书。到底整没整出来 |
支持简单的,但是我希望能有社区的人贡献下 😂 |
没有做出来钉钉的。钉钉的是我平时用的函数。我只是用来举例一下,钉钉群聊机器人钉钉并不验证加签,并且只需要按照格式post就行了 至于飞书的截图,只是我展示一下 自定义关键词没有设置出错。造成的误解非常抱歉 |
你用fastapi或者别的什么接受POST就能做到很简单的转发了,让AI生成代码它们肯定会 |
感谢思路! |
贴一下我的代码吧,万一有人会有和我一样的奇葩需求呢 from fastapi import FastAPI, Request
# import httpx
import requests
import json
app = FastAPI()
#发送钉钉消息
def send_dingtalk_message_markdown(
title: str,#消息标题
webhook_url: str,#钉钉Webhook URL
content_text2: str,#消息内容
mobiles: list[str],#不使用""
user_id: list[str],#使用""包裹每一个元素
is_at_all: bool#True,False是否@所有人
):
message = {
"msgtype": "markdown",
"markdown": { # 修改为markdown格式
"title": title, # 添加标题
"text": content_text2, # 消息内容
},
"at": {
"atMobiles": mobiles, # @的手机号码
"atUserIds": user_id,
"isAtAll": is_at_all, # 是否@所有人
},
}
# 设置请求头
headers = {
"Content-Type": "application/json", # 请求内容类型
"Charset": "UTF-8", # 字符集
}
try:
# 发送POST请求到钉钉Webhook
response = requests.post(
url=webhook_url, data=json.dumps(message), headers=headers
)
except Exception as e:
pass
@app.post("/forward")
async def forward_request(request: Request):
# 获取客户端发送的 JSON 数据
data = await request.json()
# print(data)
webhook_bgi = "你的钉钉webhook"
#解析data,获取message的内容
message = data['message']
send_dingtalk_message_markdown("BGI通知",webhook_bgi,message,None,None,False)
# 运行 FastAPI 应用
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=35896) |
希望在webhook功能中添加对钉钉机器人的webhook支持
钉钉自定义机器人发送群聊消息文档
看了下飞书的webhook感觉和钉钉没有太多区别。
希望能够在未来见到,谢谢
The text was updated successfully, but these errors were encountered: