A plugin for sending messages in WeCom (Enterprise WeChat) groups. Through a bot, it can push messages to designated groups.
robot: String Required. The Webhook address of the WeCom bot, or the key parameter from the Webhook addressmsgType: String Optional. Message type. Options: text|markdown|markdown_v2|image|file|message|template_card. Default: markdowncontent: String Optional. Message content.
Valid when msgType is text, markdown, or markdown_v2. Choose between content and fromFile, with content taking priorityfromFile: String Optional. Relative path to the file containing message content.
Valid when msgType is text, markdown, markdown_v2, or template_card. Choose between content and fromFile, with content taking priorityfilePath: String Optional. Relative path to the file to be sent. Size should be ≤ 20 MBlayouts: String Optional. Message content or path to message content file in JSON format. Required when msgType is messagechatId: String Optional. WeCom conversation ID. Multiple IDs can be separated by |visibleToUser: String Optional. Specifies group members who can see this message, separated by | or ,postId: String Optional. Only effective when chatid specifies a bulletin boardlastMsg: String Optional. WeCom has a message length limit (2048 bytes). If exceeded, this will add a prompt line at the endattachments: String Optional. JSON string (object format). Defines additional message information. See detailed description of attachments below.mentioned_list: String Optional. Specifies group members mentioned in this message, separated by | or ,. Valid when msgType is text.skip_on_wip: Boolean Optional. Default: true. Whether to skip WIP status PRs. true to skip, false not to skip.For message length and file size limits, refer to WeCom API
Defines additional message information, currently only supporting button type. attachments can be passed when msgType is markdown.
callback_id: String Required. Callback ID for attachments, which will be passed through by WeCom during callbackactions: String Required. Array of objects format, attachment actions. A maximum of 20 actions are supported per attachment.
type: String Required. Action type, currently only supporting buttonsname: String Required. Action name, which will be passed through by WeCom during callback, max 64 bytes.
To distinguish different buttons, developers should ensure name uniquenesstext: String Required. Text to display, max 128 bytesborder_color: String Optional. Button border colortext_color: String Optional. Button text colorvalue: String Required. Action value, which will be passed through by WeCom during callback, max 128 bytesreplace_text: String Required. Text to replace after button click, max 128 bytes# .cnb.yml
main:
pull_request:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: markdown
# Relative path to file containing message content. Choose between fromFile and content, with content taking priority
# fromFile: ./message.txt
content: |
Code review time
${CNB_PULL_REQUEST_TITLE}
[${CNB_EVENT_URL}](${CNB_EVENT_URL})
from ${CNB_BUILD_USER}
main:
push:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: markdown
# Custom buttons
attachments: |
[
{
"callback_id": "button_two_row",
"actions": [
{
"name": "button_1",
"text": "S",
"type": "button",
"value": "S",
"replace_text": "You have selected S",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_2",
"text": "M",
"type": "button",
"value": "M",
"replace_text": "You have selected M",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_3",
"text": "L",
"type": "button",
"value": "L",
"replace_text": "You have selected L",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_4",
"text": "Not sure",
"type": "button",
"value": "Not sure",
"replace_text": "You have selected Not sure",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_5",
"text": "Not attending",
"type": "button",
"value": "Not attending",
"replace_text": "You have selected Not attending",
"border_color": "2EAB49",
"text_color": "2EAB49"
}
]
}
]
# .cnb.yml
main:
push:
- stages:
- name: send message
image: tencentcom/wecom-message:dev
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: template_card
# Relative path to file containing message content. Choose between fromFile and content, with content taking priority
# fromFile: ./message.txt
content: |
{
"card_type":"text_notice",
"source":{
"icon_url":"https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
"desc":"Enterprise WeChat",
"desc_color":0
},
"main_title":{
"title":"Welcome to Enterprise WeChat",
"desc":"Your friend is inviting you to join Enterprise WeChat"
},
"emphasis_content":{
"title":"100",
"desc":"Data meaning"
},
"quote_area":{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi",
"appid":"APPID",
"pagepath":"PAGEPATH",
"title":"Reference text title",
"quote_text":"Jack: Enterprise WeChat is really easy to use~\nBalian: It's a super great software!"
},
"sub_title_text":"Download Enterprise WeChat to grab red envelopes!",
"jump_list":[
{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi",
"title":"Enterprise WeChat Official Website"
}
],
"card_action":{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi"
}
}
main:
push:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: message
layouts: layouts.json
layouts.json
[
{
"type": "column_layout",
"components": [
{
"type": "plain_text",
"text": "Checkbox",
"style": "title"
},
{
"type": "checkbox",
"key": "checkbox_3",
"options": [
{
"id": "1",
"text": "Option 1",
"checked": true
},
{
"id": "2",
"text": "Option 2",
"checked": false
}
]
}
]
}
]