From 2254f10b9877e4dfc845091c578f8d13ee888825 Mon Sep 17 00:00:00 2001 From: yukimura1227 Date: Fri, 6 Sep 2019 01:35:37 +0900 Subject: [PATCH 01/16] =?UTF-8?q?feat:=20timeline=E3=81=A8=E6=97=A5?= =?UTF-8?q?=E5=A0=B1=E3=81=AE=E6=A9=9F=E8=83=BD=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 8da4fa0..cf6b963 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ const Botkit = require('botkit'); +const request = require('request') if (!process.env.TOKEN) { console.log('Error: Specify TOKEN in environment'); @@ -34,7 +35,6 @@ controller.hears('hi', hearing_event_mention, function(bot,message) { controller.hears('', hearing_event_all, function(bot,message) { // console.log(bot); - console.log(message); var id = message.client_msg_id; var slack_team = process.env.SLACK_TEAM; var channel_id = message.channel; @@ -42,14 +42,38 @@ controller.hears('', hearing_event_all, function(bot,message) { event_ts = event_ts.replace('.','') var url_parameter = `?thread_ts=${message.thread_ts}&cid=${channel_id}` var post_link = `https://${slack_team}.slack.com/archives/${channel_id}/p${event_ts}` - var channel_from_id + var URL = `https://slack.com/api/channels.info?token=${process.env.TOKEN}&channel=${channel_id}` + request(URL, (error, response, body) => { + if (!error && response.statusCode == 200) { + let channel_info = JSON.parse(body); + // console.log(channel_info); + var channel_name = channel_info.channel.name; + + if(channel_name.match('^times_.+')) { + repost_to('#timeline', bot, post_link, message); + } + + if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { + repost_to('#日報_all', bot, post_link, message); + } + + if (channel_name.match('^日報_(.*)_.+')) { + matcher = channel_name.match('^日報_(.*)_.+'); + repost_to(`#日報_${matcher[1]}`, bot, post_link, message); + repost_to('#日報_all', bot, post_link, message); + } + } + }); +}); + +function repost_to(channel, bot, post_link, message) { + console.log(message); bot.api.chat.postMessage({ text: `${post_link}`, - channel: '#random', - as_user: false, - username: bot.identity.name, + channel: channel, + as_user: true, unfurl_links: true }, function(err, message){ if(err) { console.log("err: ", err); return; } }); -}); +} From 2786a9f79e39c61c2d8eb47dc238093373964fe6 Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Thu, 19 Sep 2019 09:46:52 +0900 Subject: [PATCH 02/16] =?UTF-8?q?feat:trello=E3=81=AEui=5Fnote=E3=81=AB?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=81=99=E3=82=8Bbot=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 59 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index cf6b963..926c4b9 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,7 @@ controller.hears('hi', hearing_event_mention, function(bot,message) { controller.hears('', hearing_event_all, function(bot,message) { // console.log(bot); + console.log(message); var id = message.client_msg_id; var slack_team = process.env.SLACK_TEAM; var channel_id = message.channel; @@ -49,23 +50,59 @@ controller.hears('', hearing_event_all, function(bot,message) { // console.log(channel_info); var channel_name = channel_info.channel.name; - if(channel_name.match('^times_.+')) { - repost_to('#timeline', bot, post_link, message); - } + // if(channel_name.match('^times_.+')) { + // repost_to('#timeline', bot, post_link, message); + // } + + // if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { + // repost_to('#日報_all', bot, post_link, message); + // } + + // if (channel_name.match('^日報_(.*)_.+')) { + // matcher = channel_name.match('^日報_(.*)_.+'); + // repost_to(`#日報_${matcher[1]}`, bot, post_link, message); + // repost_to('#日報_all', bot, post_link, message); + // } + + - if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { - repost_to('#日報_all', bot, post_link, message); - } + const key = "7baa756dc6314bb4a1b7e3019602d0dc"; + const token="e4528b014c42038225b7324a5af99f508b1f4f5cdb1972462dcc2651323032a7"; + const ui_note="5d6e1bd5bf1ddb7a6ac7814c"; + const list_new_id="5d6e3b0cbdc0466c9eb05c85"; + const bot_room = '西口bot実験室' + const key_word_matcher = '^title:.*' + const title_matcher = '^title:([^\n]*)' + var msg = message["text"]; - if (channel_name.match('^日報_(.*)_.+')) { - matcher = channel_name.match('^日報_(.*)_.+'); - repost_to(`#日報_${matcher[1]}`, bot, post_link, message); - repost_to('#日報_all', bot, post_link, message); - } + + if (channel_name.match(bot_room)){ + if(msg.match(key_word_matcher)){ + if(message["files"]==null){ + var img_url = "" + }else{ + var img_url = message["files"][0]["url_private"]; + }; + var title = encodeURIComponent(msg.match(title_matcher)[1]); + var desc = encodeURIComponent(msg+'\n'+img_url); + var url = `https://trello.com/1/cards?key=${key}&token=${token}&idList=${list_new_id}&name=${title}&desc=${desc}`; + var webclient = require("request"); + webclient.post({ + url: url, + headers: { + "content-type": "application/json" + } + }, function (error, response, body){}); + + bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。") + + }; + }; } }); }); + function repost_to(channel, bot, post_link, message) { console.log(message); bot.api.chat.postMessage({ From 86d9e9d0d755436576e556be4bd5a9377abb8d4e Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Thu, 19 Sep 2019 13:36:28 +0900 Subject: [PATCH 03/16] =?UTF-8?q?feat:slack=E3=81=AEui=5Fnote=E3=81=A8trel?= =?UTF-8?q?lo=E3=81=AEui=5Fnote=E3=81=AE=E9=80=A3=E6=90=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 926c4b9..580d93d 100644 --- a/index.js +++ b/index.js @@ -50,27 +50,25 @@ controller.hears('', hearing_event_all, function(bot,message) { // console.log(channel_info); var channel_name = channel_info.channel.name; - // if(channel_name.match('^times_.+')) { - // repost_to('#timeline', bot, post_link, message); - // } - - // if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { - // repost_to('#日報_all', bot, post_link, message); - // } - - // if (channel_name.match('^日報_(.*)_.+')) { - // matcher = channel_name.match('^日報_(.*)_.+'); - // repost_to(`#日報_${matcher[1]}`, bot, post_link, message); - // repost_to('#日報_all', bot, post_link, message); - // } - - - - const key = "7baa756dc6314bb4a1b7e3019602d0dc"; - const token="e4528b014c42038225b7324a5af99f508b1f4f5cdb1972462dcc2651323032a7"; - const ui_note="5d6e1bd5bf1ddb7a6ac7814c"; - const list_new_id="5d6e3b0cbdc0466c9eb05c85"; - const bot_room = '西口bot実験室' + if(channel_name.match('^times_.+')) { + repost_to('#timeline', bot, post_link, message); + } + + if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { + repost_to('#日報_all', bot, post_link, message); + } + + if (channel_name.match('^日報_(.*)_.+')) { + matcher = channel_name.match('^日報_(.*)_.+'); + repost_to(`#日報_${matcher[1]}`, bot, post_link, message); + repost_to('#日報_all', bot, post_link, message); + } + + const key = process.env.TRELLO_KEY; + const token=process.env.TRELLO_TOKEN; + const ui_note=process.env.TRELLO_UI_NOTE; + const list_new_id=process.env.TRELLO_LIST_NEW_ID; + const bot_room = 'ui_notes' const key_word_matcher = '^title:.*' const title_matcher = '^title:([^\n]*)' var msg = message["text"]; From 8e4defc5a31eabcd9c15beaa8afe4db629ad7d67 Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Thu, 19 Sep 2019 14:52:36 +0900 Subject: [PATCH 04/16] doc: README_update --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ed80534..3a5d78f 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ heroku login heroku create servant-botkit heroku config:set SLACK_TEAM=[your team name] heroku config:set TOKEN=[your token] +heroku config:set TRELLO_KEY=[your token] +heroku config:set TRELLO_TOKEN=[your token] +heroku config:set TRELLO_UI_NOTE=[your token] +heroku config:set TRELLO_LIST_NEW_ID=[your token] ``` ### heroku config From 65b76d91145b1825e9122bc97caa3539fa6f3656 Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Mon, 30 Sep 2019 11:28:41 +0900 Subject: [PATCH 05/16] feat:add_link --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 580d93d..7dda15f 100644 --- a/index.js +++ b/index.js @@ -92,7 +92,7 @@ controller.hears('', hearing_event_all, function(bot,message) { } }, function (error, response, body){}); - bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。") + bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。\n https://trello.com/b/jrmkblAB/uinotes") }; }; From 8bbb0264bff91b6b45a1df030149fadca0b5b61d Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Tue, 1 Oct 2019 11:22:42 +0900 Subject: [PATCH 06/16] feat:add_link --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7dda15f..72d2068 100644 --- a/index.js +++ b/index.js @@ -92,7 +92,7 @@ controller.hears('', hearing_event_all, function(bot,message) { } }, function (error, response, body){}); - bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。\n https://trello.com/b/jrmkblAB/uinotes") + bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。" +'\n' + "https://trello.com/b/jrmkblAB/uinotes") }; }; From badb600f9b589a78ad90fd572954f471afe9b19e Mon Sep 17 00:00:00 2001 From: yukimura1227 Date: Mon, 7 Oct 2019 12:48:32 +0900 Subject: [PATCH 07/16] feat: post_message_for_remote_work --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 72d2068..816e9dc 100644 --- a/index.js +++ b/index.js @@ -33,6 +33,10 @@ controller.hears('hi', hearing_event_mention, function(bot,message) { bot.reply(message,'hi'); }); +controller.hears('remote', ['direct_mention'], function(bot, message) { + bot.reply(message, " 本日リモートありなので、*今日やろうと思っていること*と、*実際にやったこと*を、このメッセージのスレッドに返信する形で共有しませう"); +}); + controller.hears('', hearing_event_all, function(bot,message) { // console.log(bot); console.log(message); From c5ef0a32e7e4aac57d6e381540f1aeabdceaf238 Mon Sep 17 00:00:00 2001 From: shoichinishiguchi Date: Mon, 7 Oct 2019 14:49:37 +0900 Subject: [PATCH 08/16] feat:lint --- .DS_Store | Bin 0 -> 6148 bytes index.js | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3b9d5be82f200f390d6e24034d466b6b5c00da3f GIT binary patch literal 6148 zcmeHKOG*Pl5Pcm3PS8bmx}2q}fNM8nOcntZF$d6mR5W8oA_3ja#yfZgPvc=cfWE43 zg43hhAW{WguRm4QU9Vw!3V`b_r~5z~K*A>2Xi@zjvM#MAjW8pNPGSu5VlvK)F~<_n zech|%e1txfm?(cwWd!H(rNP=6;X?ukybZ}R*e~aulaf|_u(8no;=vSk=oydBd zu?vlUfqU&Ok#n!;RPLqb_ka;kKcl{(y`GHz^Ju@1$S=Ve7Mk}p^Wsib`^G4;Z{eJo z9HNI4Vuxp(Mjr1qk7u4~!Mr+*FAUGB9uS6KzcI|Ai7{Xd7z1lyfN!=)vgOgVF<=ZB z11kpP`;f8;W&ul&`stw35`fs`vrYH&f|vy?J#vQPyerYWx=>=cP&qj7&h;$V zmma-4obJpxVP_XA6c-8)m#R5j=Fzk;I~gjf??f;9oJ|n!RDK z%ap>~T1!se+LY~*O+@TUk1H2;^eLvTJjJ_gDx6QHL(Bq}9yvp?9|5JolrgYY2EG7O CrFP~3 literal 0 HcmV?d00001 diff --git a/index.js b/index.js index 72d2068..feb11c6 100644 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ controller.hears('', hearing_event_all, function(bot,message) { const ui_note=process.env.TRELLO_UI_NOTE; const list_new_id=process.env.TRELLO_LIST_NEW_ID; const bot_room = 'ui_notes' - const key_word_matcher = '^title:.*' + const key_word_matcher = '^title:.*' const title_matcher = '^title:([^\n]*)' var msg = message["text"]; @@ -77,7 +77,7 @@ controller.hears('', hearing_event_all, function(bot,message) { if (channel_name.match(bot_room)){ if(msg.match(key_word_matcher)){ if(message["files"]==null){ - var img_url = "" + var img_url = "" }else{ var img_url = message["files"][0]["url_private"]; }; From 7c73bb4a13ded660d3f5f066d5b634a88fbde465 Mon Sep 17 00:00:00 2001 From: yukimura1227 Date: Mon, 20 Jul 2020 14:27:26 +0900 Subject: [PATCH 09/16] =?UTF-8?q?feat:=20exception=E3=82=92=E3=81=96?= =?UTF-8?q?=E3=81=A3=E3=81=8F=E3=82=8A=E3=81=A8=E3=81=97=E3=82=8F=E3=81=91?= =?UTF-8?q?=E3=82=8B=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/index.js b/index.js index 17af456..dfb7576 100644 --- a/index.js +++ b/index.js @@ -58,6 +58,10 @@ controller.hears('', hearing_event_all, function(bot,message) { repost_to('#timeline', bot, post_link, message); } + if(channel_name.match('^exceptions$')) { + sort_exception_into_appropriate_channel(bot, post_link, message) + } + if (channel_name.match('^日報_(.*)$') && channel_name.match('_').length === 1/* && username !== 'slackbot'*/) { repost_to('#日報_all', bot, post_link, message); } @@ -116,3 +120,25 @@ function repost_to(channel, bot, post_link, message) { if(err) { console.log("err: ", err); return; } }); } + +function sort_exception_into_appropriate_channel(bot, post_link, message) { + matcher = message.match('\/'); + repost_to_target_channel_postfix = 'others' + if ( message.match(/\/manage\//)) { + repost_to_target_channel_postfix = 'manage' + } else if ( message.match(/\/business\//)) { + repost_to_target_channel_postfix = 'business' + } else if ( message.match(/\/for_team_manage\//)) { + repost_to_target_channel_postfix = 'for_team_manage' + } else if ( message.match(/\/works\//)) { + repost_to_target_channel_postfix = 'works' + } else if ( message.match(/\/cgc\//)) { + repost_to_target_channel_postfix = 'games' + } else if ( message.match(/\/poh\//)) { + repost_to_target_channel_postfix = 'games' + } else if ( message.match(/\/codechronicle\//)) { + repost_to_target_channel_postfix = 'games' + } + repost_to(`#exceptions_${repost_to_target_channel_postfix}`, bot, post_link, message); +} + From fec555e15e820a2281b827d430fed5ad80a48e32 Mon Sep 17 00:00:00 2001 From: yukimura1227 Date: Mon, 20 Jul 2020 14:56:58 +0900 Subject: [PATCH 10/16] =?UTF-8?q?fix:=20=E3=83=A1=E3=83=83=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E6=96=87=E8=A8=80=E3=81=A7=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=81=E3=83=B3=E3=82=B0=E3=81=8B=E3=81=91=E3=82=8B?= =?UTF-8?q?=E3=81=B9=E3=81=8D=E3=81=A8=E3=81=93=E3=82=8D=E3=81=8C=E8=AA=A4?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=84=E3=81=A6=E3=80=81=E8=90=BD=E3=81=A1?= =?UTF-8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E6=98=AF=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index dfb7576..ab50f93 100644 --- a/index.js +++ b/index.js @@ -122,21 +122,20 @@ function repost_to(channel, bot, post_link, message) { } function sort_exception_into_appropriate_channel(bot, post_link, message) { - matcher = message.match('\/'); repost_to_target_channel_postfix = 'others' - if ( message.match(/\/manage\//)) { + if ( message.text.match(/\/manage\//)) { repost_to_target_channel_postfix = 'manage' - } else if ( message.match(/\/business\//)) { + } else if ( message.text.match(/\/business\//)) { repost_to_target_channel_postfix = 'business' - } else if ( message.match(/\/for_team_manage\//)) { + } else if ( message.text.match(/\/for_team_manage\//)) { repost_to_target_channel_postfix = 'for_team_manage' - } else if ( message.match(/\/works\//)) { + } else if ( message.text.match(/\/works\//)) { repost_to_target_channel_postfix = 'works' - } else if ( message.match(/\/cgc\//)) { + } else if ( message.text.match(/\/cgc\//)) { repost_to_target_channel_postfix = 'games' - } else if ( message.match(/\/poh\//)) { + } else if ( message.text.match(/\/poh\//)) { repost_to_target_channel_postfix = 'games' - } else if ( message.match(/\/codechronicle\//)) { + } else if ( message.text.match(/\/codechronicle\//)) { repost_to_target_channel_postfix = 'games' } repost_to(`#exceptions_${repost_to_target_channel_postfix}`, bot, post_link, message); From b4b5b302f050becca1f98bcfbaa31e120ecf9489 Mon Sep 17 00:00:00 2001 From: puriso Date: Mon, 3 Aug 2020 19:55:22 +0900 Subject: [PATCH 11/16] feat: yarn add date-utils --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 65bbb64..38067ed 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "author": "yukimura1227 ", "license": "MIT", "dependencies": { - "botkit": "0.7.4" + "botkit": "0.7.4", + "date-utils": "^1.2.21" } } diff --git a/yarn.lock b/yarn.lock index ed2e961..3334464 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1027,6 +1027,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +date-utils@^1.2.21: + version "1.2.21" + resolved "https://registry.yarnpkg.com/date-utils/-/date-utils-1.2.21.tgz#61fb16cdc1274b3c9acaaffe9fc69df8720a2b64" + integrity sha1-YfsWzcEnSzyayq/+n8ad+HIKK2Q= + debug@2.6.9, debug@^2.2, debug@^2.2.0: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" From a211e48914e9049f39c404ef1c34931aac08e933 Mon Sep 17 00:00:00 2001 From: puriso Date: Mon, 3 Aug 2020 19:55:33 +0900 Subject: [PATCH 12/16] =?UTF-8?q?feat:=20trello=E3=81=AE=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=AB=E3=83=BC=E3=83=89=E3=81=AE=E6=A6=82?= =?UTF-8?q?=E8=A6=81=E3=81=ABsalck=20url=E3=82=84=E6=8A=95=E7=A8=BF?= =?UTF-8?q?=E6=97=A5=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82=E3=83=86=E3=83=B3?= =?UTF-8?q?=E3=83=97=E3=83=AC=E3=82=82=E3=82=A2=E3=83=83=E3=83=97=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 下記のようにアプデした --------------------------------- 概要 XXXXXXXXXXXXX Slack URL https://paiza.slack.com/archives/C8RRSA2CS/XXXXXXXXXXXX 投稿日 2020/08/03/ 19:53 画像URL https://files.slack.com/files-pri/XXXXXXXXXXXXXXXXX --------------------------------- --- index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index ab50f93..31c26db 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const Botkit = require('botkit'); -const request = require('request') +const request = require('request'); +const dateutils = require('date-utils'); if (!process.env.TOKEN) { console.log('Error: Specify TOKEN in environment'); @@ -79,20 +80,24 @@ controller.hears('', hearing_event_all, function(bot,message) { const bot_room = 'ui_notes' const key_word_matcher = '^title:.*' const title_matcher = '^title:([^\n]*)' - var msg = message["text"]; - - + const dt = new Date(); + const posted_at = '### 投稿日\n'+dt.toFormat("YYYY/MM/DD/ HH24:MI")+'\n'; + const msg_url = '### Slack URL\nhttps://paiza.slack.com/archives/C8RRSA2CS/p'+message['event_ts']+'\n' + const msg = message["text"] + const trello_body = '###概要\n'+message["text"].replace( /^title:/g, '')+'\n'; + var img_url = '' + + var desc = encodeURIComponent(msg+msg_url+posted_at+img_url); if (channel_name.match(bot_room)){ if(msg.match(key_word_matcher)){ - if(message["files"]==null){ - var img_url = "" - }else{ - var img_url = message["files"][0]["url_private"]; - }; + if(message["files"]){ + img_url = '### 画像URL\n' + message["files"][0]["url_private"]+'\n' + } var title = encodeURIComponent(msg.match(title_matcher)[1]); - var desc = encodeURIComponent(msg+'\n'+img_url); + var desc = encodeURIComponent(trello_body+msg_url+posted_at+img_url); var url = `https://trello.com/1/cards?key=${key}&token=${token}&idList=${list_new_id}&name=${title}&desc=${desc}`; var webclient = require("request"); + webclient.post({ url: url, headers: { @@ -101,7 +106,6 @@ controller.hears('', hearing_event_all, function(bot,message) { }, function (error, response, body){}); bot.reply(message,"uiチームのタスクに登録されました。随時取り掛かります。" +'\n' + "https://trello.com/b/jrmkblAB/uinotes") - }; }; } From 2361d7377e52ca90b73a6993e3c63bccb3cb22ed Mon Sep 17 00:00:00 2001 From: puriso Date: Mon, 3 Aug 2020 20:02:45 +0900 Subject: [PATCH 13/16] refact: refact --- index.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 31c26db..e5dbd88 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ -const Botkit = require('botkit'); -const request = require('request'); -const dateutils = require('date-utils'); +const Botkit = require('botkit'); +const request = require('request'); +const require('date-utils'); if (!process.env.TOKEN) { console.log('Error: Specify TOKEN in environment'); @@ -73,19 +73,19 @@ controller.hears('', hearing_event_all, function(bot,message) { repost_to('#日報_all', bot, post_link, message); } - const key = process.env.TRELLO_KEY; - const token=process.env.TRELLO_TOKEN; - const ui_note=process.env.TRELLO_UI_NOTE; - const list_new_id=process.env.TRELLO_LIST_NEW_ID; - const bot_room = 'ui_notes' + const key = process.env.TRELLO_KEY; + const token = process.env.TRELLO_TOKEN; + const ui_note = process.env.TRELLO_UI_NOTE; + const list_new_id = process.env.TRELLO_LIST_NEW_ID; + const bot_room = 'ui_notes' const key_word_matcher = '^title:.*' - const title_matcher = '^title:([^\n]*)' - const dt = new Date(); - const posted_at = '### 投稿日\n'+dt.toFormat("YYYY/MM/DD/ HH24:MI")+'\n'; - const msg_url = '### Slack URL\nhttps://paiza.slack.com/archives/C8RRSA2CS/p'+message['event_ts']+'\n' - const msg = message["text"] - const trello_body = '###概要\n'+message["text"].replace( /^title:/g, '')+'\n'; - var img_url = '' + const title_matcher = '^title:([^\n]*)' + const dt = new Date(); + const posted_at = '### 投稿日\n'+dt.toFormat("YYYY/MM/DD/ HH24:MI")+'\n'; + const msg_url = '### Slack URL\nhttps://paiza.slack.com/archives/C8RRSA2CS/p'+message['event_ts']+'\n' + const msg = message["text"] + const trello_body = '###概要\n'+message["text"].replace( /^title:/g, '')+'\n'; + var img_url = '' var desc = encodeURIComponent(msg+msg_url+posted_at+img_url); if (channel_name.match(bot_room)){ @@ -93,9 +93,9 @@ controller.hears('', hearing_event_all, function(bot,message) { if(message["files"]){ img_url = '### 画像URL\n' + message["files"][0]["url_private"]+'\n' } - var title = encodeURIComponent(msg.match(title_matcher)[1]); - var desc = encodeURIComponent(trello_body+msg_url+posted_at+img_url); - var url = `https://trello.com/1/cards?key=${key}&token=${token}&idList=${list_new_id}&name=${title}&desc=${desc}`; + var title = encodeURIComponent(msg.match(title_matcher)[1]); + var desc = encodeURIComponent(trello_body+msg_url+posted_at+img_url); + var url = `https://trello.com/1/cards?key=${key}&token=${token}&idList=${list_new_id}&name=${title}&desc=${desc}`; var webclient = require("request"); webclient.post({ From 4a79f80590821dd05b7568be7d84167a8c1f81ec Mon Sep 17 00:00:00 2001 From: puriso Date: Tue, 4 Aug 2020 14:58:38 +0900 Subject: [PATCH 14/16] fix: fix --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e5dbd88..fcdf7e3 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const Botkit = require('botkit'); const request = require('request'); -const require('date-utils'); +require('date-utils'); if (!process.env.TOKEN) { console.log('Error: Specify TOKEN in environment'); From ffe230174780c3e52b45a636a402787f956fbb3c Mon Sep 17 00:00:00 2001 From: puriso Date: Thu, 24 Sep 2020 15:57:45 +0900 Subject: [PATCH 15/16] =?UTF-8?q?feat:=20=E5=A0=B1=E5=91=8A=E6=9C=88?= =?UTF-8?q?=E3=82=92hashtag=E3=81=A8=E3=81=97=E3=81=A6=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index fcdf7e3..27e1ebd 100644 --- a/index.js +++ b/index.js @@ -93,7 +93,8 @@ controller.hears('', hearing_event_all, function(bot,message) { if(message["files"]){ img_url = '### 画像URL\n' + message["files"][0]["url_private"]+'\n' } - var title = encodeURIComponent(msg.match(title_matcher)[1]); + var hashtag = '#' + dt.toFormat("YYYY年MM月") + '報告分'; + var title = encodeURIComponent(msg.match(title_matcher)[1] + hashtag); var desc = encodeURIComponent(trello_body+msg_url+posted_at+img_url); var url = `https://trello.com/1/cards?key=${key}&token=${token}&idList=${list_new_id}&name=${title}&desc=${desc}`; var webclient = require("request"); From e93fd6f02e11b807c14fe9f18edcc868c3530cd9 Mon Sep 17 00:00:00 2001 From: shoichinishiguchi <48884623+shoichinishiguchi@users.noreply.github.com> Date: Thu, 25 Feb 2021 17:40:13 +0900 Subject: [PATCH 16/16] =?UTF-8?q?fix:=20=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=81=8C=E6=96=B0=E3=81=97=E3=81=8F=E3=81=AA=E3=82=8A?= =?UTF-8?q?=E3=80=81=E5=8F=A4=E3=81=84=E3=82=82=E3=81=AE=E3=81=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 27e1ebd..de668a2 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ controller.hears('', hearing_event_all, function(bot,message) { event_ts = event_ts.replace('.','') var url_parameter = `?thread_ts=${message.thread_ts}&cid=${channel_id}` var post_link = `https://${slack_team}.slack.com/archives/${channel_id}/p${event_ts}` - var URL = `https://slack.com/api/channels.info?token=${process.env.TOKEN}&channel=${channel_id}` + var URL = `https://slack.com/api/conversations.info?token=${process.env.TOKEN}&channel=${channel_id}` request(URL, (error, response, body) => { if (!error && response.statusCode == 200) { let channel_info = JSON.parse(body);