송용우

Init Slack Webhook

This diff is collapsed. Click to expand it.
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
21 "koa-router": "^9.0.1", 21 "koa-router": "^9.0.1",
22 "mongoose": "^5.9.17", 22 "mongoose": "^5.9.17",
23 "morgan": "^1.10.0", 23 "morgan": "^1.10.0",
24 + "node-schedule": "^1.3.2",
24 "path": "^0.12.7", 25 "path": "^0.12.7",
26 + "slack-client": "^2.0.6",
25 "slack-node": "^0.1.8", 27 "slack-node": "^0.1.8",
26 "voca": "^1.4.0" 28 "voca": "^1.4.0"
27 }, 29 },
......
1 +const Slack = require("slack-node"); // 슬랙 모듈 사용
2 +
1 const webhookUri = 3 const webhookUri =
2 - 'https://hooks.slack.com/services/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'; 4 + "https://hooks.slack.com/services/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"; // Webhook URL
3 5
4 const slack = new Slack(); 6 const slack = new Slack();
5 slack.setWebhook(webhookUri); 7 slack.setWebhook(webhookUri);
8 +
6 const send = async (message) => { 9 const send = async (message) => {
7 slack.webhook( 10 slack.webhook(
8 { 11 {
9 - channel: '#general', // 전송될 슬랙 채널
10 - username: 'webhookbot', //슬랙에 표시될 이름
11 text: message, 12 text: message,
12 }, 13 },
13 function (err, response) { 14 function (err, response) {
14 console.log(response); 15 console.log(response);
15 - }, 16 + }
16 ); 17 );
17 }; 18 };
18 19
19 -send('안녕'); 20 +send("hello");
......