项目作者: a9

项目描述 :
The work wechat (wework) chat group webhooks api
高级语言: TypeScript
项目地址: git://github.com/a9/wework.git
创建时间: 2019-07-05T06:23:02Z
项目社区:https://github.com/a9/wework

开源协议:MIT License

下载


WeWork Incoming Webhooks

Installation

  1. $ npm install wework

Usage


Initialize the webhook

The package exports a IncomingWebhook class. You’ll need to initialize it with the URL you received from WeWork group, see the webhooks docs.

  1. import { IncomingWebhook } from 'wework';
  2. // Read a url from the environment variables
  3. const url = process.env.WEWORK_WEBHOOK_URL;
  4. // Initialize
  5. const webhook = new IncomingWebhook(url);

Send a Message

Something interesting just happened in your app, so its time to send the message! Just call the
.sendText(message) method on the webhook. The message parameter is an string.

  1. import { IncomingWebhook } from 'wework';
  2. const url = process.env.WEWORK_WEBHOOK_URL;
  3. const webhook = new IncomingWebhook(url);
  4. // Send the message
  5. (async () => {
  6. // send text message
  7. await webhook.sendText('Some text message');
  8. // send markdown message
  9. await webhook.sendMarkdown(`Some markdown message`)
  10. // send news articles
  11. await webhook.sendNews([
  12. {
  13. title: 'The title',
  14. description: 'The description',
  15. url: 'The link',
  16. picurl: 'The image url'
  17. }
  18. ])
  19. })();