logo
1
0
Login

wecom-message

A plugin for sending messages in WeCom (WeChat Work) groups. Through robots, messages can be pushed to specific groups.

Input

  • robot: String Required, the WeCom robot Webhook URL or the key parameter from the Webhook URL
  • msgType: String Optional, message type. text|markdown|image|file|message, default: markdown
  • content: String Optional, message content. Valid when msgType is text or markdown or markdown_v2. Choose either content or fromFile, content takes precedence
  • fromFile: String Optional, relative path to the file containing message content. Valid when msgType is text or markdown or markdown_v2. Choose either content or fromFile, content takes precedence
  • filePath: String Optional, relative path to the file to be sent. Size should be less than or equal to 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, supports multiple IDs separated by |
  • visibleToUser: String Optional, specify group members who can see this message, separated by | or ,
  • postId: String Optional, only effective when chatid specifies one blackboard
  • lastMsg: String Optional, WeCom has a message length limit (2048 bytes), used to add a line of prompt at the end if exceeded
  • attachments: String Optional, JSON string (object format). Define message additional information. See attachments details below
  • mentioned_list: String Optional, specify group members to mention, separated by | or ,. Valid when msgType is text
  • skip_on_wip: Boolean Optional, default: true. Whether to skip WIP status PR, true skips, false does not skip.

For message length and file size limitations, please refer to WeCom API

attachments

Define additional message information, currently only supports button type. attachments can be passed when msgType is markdown.

  • callback_id: String Required, callback ID for attachments, WeCom will pass this value in callbacks
  • actions: String Required, array of objects format, attachment actions, maximum 20 actions per attachment.
    • type: String Required, action type, currently only supports buttons
    • name: String Required, action name, passed in callbacks, max 64 bytes. Developers should ensure name uniqueness to distinguish different buttons
    • 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, passed in callbacks, max 128 bytes
    • replace_text: String Required, text to replace after clicking the button, max 128 bytes

Examples

PR Notification to Group

On Cloud Native Build

# .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 message content file, choose either fromFile or content, content takes precedence # 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": "Uncertain", "type": "button", "value": "Uncertain", "replace_text": "You have selected Uncertain", "border_color": "2EAB49", "text_color": "2EAB49" }, { "name": "button_5", "text": "Not participating", "type": "button", "value": "Not participating", "replace_text": "You have selected Not participating", "border_color": "2EAB49", "text_color": "2EAB49" } ] } ]

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 Name 1", "checked": true }, { "id": "2", "text": "Option Name 2", "checked": false } ] } ] } ]

About

wecom-message

672.00 KiB
1 forks0 stars2 branches2 TagREADMEMIT license
Language
TypeScript96.5%
Dockerfile2%
JavaScript0.9%
Shell0.6%