Install
openclaw skills install qywx-send-skill严格按照企业微信文档规范,支持文本、markdown、markdown_v2、图片、图文等多种消息类型的发送技能。
openclaw skills install qywx-send-skill这个技能严格按照企业微信文档规范,支持以下消息类型:
注意: 本技能专注于消息发送功能,不包含告警消息和每日报告的发送功能。
使用qywx-send-skill发送文本消息 [消息内容]
超长内容处理: 当内容超过2048字节时,会自动分片发送
使用qywx-send-skill发送markdown消息 [消息内容]
超长内容处理: 当内容超过4096字节时,会自动分片发送
使用qywx-send-skill发送markdown_v2消息 [消息内容]
超长内容处理: 当内容超过4096字节时,会自动分片发送
使用qywx-send-skill发送图片消息 [图片路径或URL]
使用qywx-send-skill发送图文消息 [标题] [描述] [图片URL] [跳转URL]
使用qywx-send-skill发送[消息类型] [消息内容],Webhook地址: [your-webhook-url]
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=you-key{
"msgtype": "text",
"text": {
"content": "消息内容",
"mentioned_list": ["@all"],
"mentioned_mobile_list": ["@all"]
}
}
字段说明:
content: 消息内容,最长2048字节mentioned_list: 需要@的成员,["@all"]表示@所有人mentioned_mobile_list: 需要@的成员手机号{
"msgtype": "markdown",
"markdown": {
"content": "**标题**\n\n内容"
}
}
字段说明:
content: Markdown格式内容,最长4096字节支持的Markdown语法:
# 标题**加粗***斜体*[链接](url)- 列表项> 引用内容{
"msgtype": "markdown_v2",
"markdown_v2": {
"content": "**标题**\n\n内容",
"template_id": "template_id",
"template_data": {
"key1": "value1",
"key2": "value2"
}
}
}
字段说明:
content: Markdown V2格式内容template_id: 模板ID(可选)template_data: 模板数据(可选){
"msgtype": "image",
"image": {
"base64": "base64编码的图片内容",
"md5": "图片的MD5值"
}
}
字段说明:
base64: 图片的base64编码md5: 图片的MD5值{
"msgtype": "news",
"news": {
"articles": [
{
"title": "标题",
"description": "描述",
"url": "跳转链接",
"picurl": "图片链接"
}
]
}
}
字段说明:
articles: 图文消息列表title: 标题,最长128字节description: 描述,最长512字节url: 跳转链接picurl: 图片链接使用qywx-send-skill发送文本消息 服务器监控:CPU使用率正常
使用qywx-send-skill发送markdown消息 **📊 系统状态**\n\n- CPU使用率:65%\n- 内存使用率:72%\n- 磁盘使用率:45%
使用qywx-send-skill发送文本消息 [超过2048字节的长文本内容]
处理: 自动拆分成多个消息发送,每个分片包含分片编号
使用qywx-send-skill发送markdown消息 **📊 长报告**\n\n[超过4096字节的详细内容]
处理: 自动拆分成多个消息发送,每个分片包含分片编号
使用qywx-send-skill发送图片消息 /path/to/image.png
使用qywx-send-skill发送图文消息 "系统更新通知" "系统将于今晚进行更新维护" "https://example.com/image.png" "https://example.com/detail"
使用qywx-send-skill发送文本消息 测试消息,Webhook地址: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your-key
from skills.qywx_send_skill.scripts.send_message import send_wechat_message
# 发送文本消息
result = send_wechat_message("服务器监控:CPU使用率正常", msg_type="text")
print(result)
# 发送markdown消息
markdown_content = "**📊 系统状态**\n\n- CPU使用率:65%\n- 内存使用率:72%"
result = send_wechat_message(markdown_content, msg_type="markdown")
print(result)
# 发送长文本消息(自动分片)
long_text = "长文本内容..." * 1000 # 超过2048字节
result = send_wechat_message(long_text, msg_type="text")
print(f"分片发送结果: {result.get('chunk_count', 1)}片")
# 发送长Markdown消息(自动分片)
long_markdown = "**📊 长报告**\n\n" + "详细内容..." * 1000 # 超过4096字节
result = send_wechat_message(long_markdown, msg_type="markdown")
print(f"分片发送结果: {result.get('chunk_count', 1)}片")
# 发送图片消息
result = send_wechat_message("/path/to/image.png", msg_type="image")
print(result)
# 发送图文消息
articles = [
{
"title": "系统更新通知",
"description": "系统将于今晚进行更新维护",
"url": "https://example.com/detail",
"picurl": "https://example.com/image.png"
}
]
result = send_wechat_message(articles, msg_type="news")
print(result)
# 使用自定义Webhook
result = send_wechat_message("测试消息", msg_type="text", webhook_url="https://your-webhook-url")
print(result)
# 禁用分片发送(强制单条发送,可能失败)
result = send_wechat_message(long_text, msg_type="text", enable_chunking=False)
print(result)
{
"errcode": 0,
"errmsg": "ok"
}
{
"errcode": 40014,
"errmsg": "invalid webhook"
}
urllib.request: HTTP请求发送json: 数据格式处理ssl: HTTPS连接支持base64: 图片编码处理hashlib: MD5计算