From ef7c9ec13c0adaa70bf0b1a391c6da359d0b78ae Mon Sep 17 00:00:00 2001 From: lijiarui Date: Thu, 26 Mar 2020 19:41:58 +0800 Subject: [PATCH 1/6] add wx-work bot template --- src/issue-handlers.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/issue-handlers.ts b/src/issue-handlers.ts index 6b14cdf..f97c879 100644 --- a/src/issue-handlers.ts +++ b/src/issue-handlers.ts @@ -183,6 +183,11 @@ async function manageIssue ( 'issue card for chatops', ) + if (owner === 'juzibot' && repository === 'Juzi-WeChat-Work-Tasks') { + const wxBotUrl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=974db6af-6b24-41aa-8da6-5ed634d24fcf' + require(wxBotUrl) + } + const roomList = getRoomList(owner, repository) if (roomList.length <= 0) { return From cb844be6a03d8c16f1f3bd15f22bc996b7793fa5 Mon Sep 17 00:00:00 2001 From: lijiarui Date: Thu, 26 Mar 2020 21:05:13 +0800 Subject: [PATCH 2/6] fix request error --- src/issue-handlers.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/issue-handlers.ts b/src/issue-handlers.ts index f97c879..ede66c6 100644 --- a/src/issue-handlers.ts +++ b/src/issue-handlers.ts @@ -184,8 +184,26 @@ async function manageIssue ( ) if (owner === 'juzibot' && repository === 'Juzi-WeChat-Work-Tasks') { - const wxBotUrl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=974db6af-6b24-41aa-8da6-5ed634d24fcf' - require(wxBotUrl) + const wxBotUrl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send' + const key = '974db6af-6b24-41aa-8da6-5ed634d24fcf' + + const options = { method: 'POST', + url: wxBotUrl, + qs: { key: key }, + headers: { 'content-type': 'application/json' }, + body: { + msgtype: 'markdown', + markdown: { + content: `[${urlLinkPayload.title}](${urlLinkPayload.url}) \n ${urlLinkPayload.description}`, + }, + }, + json: true, + } + + request(options, function (error) { + if (error) throw new Error(error) + }) + } const roomList = getRoomList(owner, repository) From c58b2118cc5d61979348e1114d775486f0b87bc5 Mon Sep 17 00:00:00 2001 From: lijiarui Date: Thu, 26 Mar 2020 21:34:20 +0800 Subject: [PATCH 3/6] make ci happy --- src/issue-handlers.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/issue-handlers.ts b/src/issue-handlers.ts index ede66c6..1920577 100644 --- a/src/issue-handlers.ts +++ b/src/issue-handlers.ts @@ -187,17 +187,18 @@ async function manageIssue ( const wxBotUrl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send' const key = '974db6af-6b24-41aa-8da6-5ed634d24fcf' - const options = { method: 'POST', - url: wxBotUrl, - qs: { key: key }, - headers: { 'content-type': 'application/json' }, + const options = { body: { - msgtype: 'markdown', markdown: { content: `[${urlLinkPayload.title}](${urlLinkPayload.url}) \n ${urlLinkPayload.description}`, }, + msgtype: 'markdown', }, + headers: { 'content-type': 'application/json' }, json: true, + method: 'POST', + qs: { key: key }, + url: wxBotUrl, } request(options, function (error) { From 17c69f0065af185995f53a652e8333172b45e85c Mon Sep 17 00:00:00 2001 From: lijiarui Date: Wed, 1 Apr 2020 15:46:38 +0800 Subject: [PATCH 4/6] import request --- src/issue-handlers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/issue-handlers.ts b/src/issue-handlers.ts index 1920577..c693ab7 100644 --- a/src/issue-handlers.ts +++ b/src/issue-handlers.ts @@ -13,6 +13,8 @@ import { getWechaty } from './get-wechaty' import { Chatops } from './chatops' +import request from 'request' + import { managedRepoConfig, log, From a36a3be0410c43e390a5f8cafe56af65846d1f78 Mon Sep 17 00:00:00 2001 From: lijiarui Date: Wed, 1 Apr 2020 15:56:39 +0800 Subject: [PATCH 5/6] add request pacakge --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 24a2466..1adfabc 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "homepage": "https://github.com/kaiyuanshe/OSSChat#readme", "dependencies": { + "@types/request": "^2.48.4", "brolog": "^1.6.5", "commander": "^4.0.1", "finis": "^0.4.3", @@ -34,6 +35,7 @@ "node-cache": "^5.1.0", "probot": "^9.8.1", "qrcode-terminal": "^0.12.0", + "request": "^2.88.2", "smee-client": "^1.1.0", "wechaty": "^0.33.4", "wechaty-puppet-padplus": "^0.5.19" From d6e5dcd0bfd4c4889ae0667169930aaccdb72950 Mon Sep 17 00:00:00 2001 From: lijiarui Date: Wed, 1 Apr 2020 16:07:32 +0800 Subject: [PATCH 6/6] code clean --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aaefac1..67c753a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ }, "homepage": "https://github.com/kaiyuanshe/OSSChat#readme", "dependencies": { - "@types/request": "^2.48.4", "@reduxjs/toolkit": "^1.3.2", "array-flatten": "^3.0.0", "brolog": "^1.6.5", @@ -54,6 +53,7 @@ "@types/micromatch": "^4.0.1", "@types/raven": "^2.5.1", "@types/read-pkg-up": "^6.0.0", + "@types/request": "^2.48.4", "eslint": "^6.8.0", "express": "^4.17.1", "shx": "^0.3.2",