logo
2
0
WeChat Login

wecom-message

A plugin for sending messages in WeCom (Enterprise WeChat) groups. Through a bot, it can push messages to designated groups.

Input Parameters

  • robot: String Required. The Webhook address of the WeCom bot, or the key parameter from the Webhook address
  • msgType: String Optional. Message type. Options: text|markdown|markdown_v2|image|file|message|template_card. Default: markdown
  • content: String Optional. Message content. Valid when msgType is text, markdown, or markdown_v2. Choose between content and fromFile, with content taking priority
  • fromFile: 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 priority
  • filePath: String Optional. Relative path to the file to be sent. Size should be ≤ 20 MB
  • layouts: String Optional. Message content or path to message content file in JSON format. Required when msgType is message
  • chatId: 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 board
  • lastMsg: String Optional. WeCom has a message length limit (2048 bytes). If exceeded, this will add a prompt line at the end
  • attachments: 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

attachments

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 callback
  • actions: 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 buttons
    • name: String Required. Action name, which will be passed through by WeCom during callback, max 64 bytes. To distinguish different buttons, developers should ensure name uniqueness
    • text: String Required. Text to display, max 128 bytes
    • border_color: String Optional. Button border color
    • text_color: String Optional. Button text color
    • value: String Required. Action value, which will be passed through by WeCom during callback, max 128 bytes
    • replace_text: String Required. Text to replace after button click, max 128 bytes

Usage in Cloud Native Build

markdown

# .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}

Custom Buttons

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" } ] } ]

Card

# .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" } }

layouts

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 } ] } ] } ]

About

wecom-message

800.00 KiB
2 forks0 stars2 branches3 TagREADMEMIT license
Language
TypeScript96.5%
Dockerfile2%
JavaScript0.9%
Shell0.6%