Showing
3 changed files
with
77 additions
and
14 deletions
... | @@ -7,13 +7,13 @@ const yongin_url = 'http://www.yongin.go.kr/health/ictsd/INC_selectIctsdPatntLis | ... | @@ -7,13 +7,13 @@ const yongin_url = 'http://www.yongin.go.kr/health/ictsd/INC_selectIctsdPatntLis |
7 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 7 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
8 | const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | 8 | const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' |
9 | const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | 9 | const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' |
10 | -const TOKEN = 'input your token' | 10 | +const TOKEN = 'YOUR TOKEN' |
11 | -const NAVER_NEWS_ID = 'input your id' | 11 | +const NAVER_NEWS_ID = 'YOUR ID' |
12 | -const NAVER_NEWS_SECRET = 'input your secret' | 12 | +const NAVER_NEWS_SECRET = 'YOUR SECRET' |
13 | const fs = require('fs'); | 13 | const fs = require('fs'); |
14 | const path = require('path'); | 14 | const path = require('path'); |
15 | const HTTPS = require('https'); | 15 | const HTTPS = require('https'); |
16 | -const domain = "www.osschatbot2020.tk" | 16 | +const domain = "YOUR DOMAIN" |
17 | const sslport = 23023; | 17 | const sslport = 23023; |
18 | const bodyParser = require('body-parser'); | 18 | const bodyParser = require('body-parser'); |
19 | var app = express(); | 19 | var app = express(); |
... | @@ -45,13 +45,20 @@ app.post('/hook', function (req, res) { | ... | @@ -45,13 +45,20 @@ app.post('/hook', function (req, res) { |
45 | var sub_nationwide = "국내"; | 45 | var sub_nationwide = "국내"; |
46 | if(isNationWide.indexOf(sub_nationwide) !== -1){ | 46 | if(isNationWide.indexOf(sub_nationwide) !== -1){ |
47 | replyNationWide(eventObj); | 47 | replyNationWide(eventObj); |
48 | - } else if(message.text == "야" || message.text == "도움말" || message.text.indexOf("어떻게") !== -1){ | 48 | + } |
49 | + else if(message.text == "야" || message.text == "도움말" || message.text.indexOf("어떻게") !== -1){ | ||
49 | console.log('[request hello]') | 50 | console.log('[request hello]') |
50 | replyHello(eventObj); | 51 | replyHello(eventObj); |
51 | - } else if(message.text.indexOf("뉴스") !== -1){ | 52 | + } |
53 | + else if(message.text.indexOf("뉴스") !== -1){ | ||
52 | console.log('[request news]') | 54 | console.log('[request news]') |
53 | replyNews(eventObj); | 55 | replyNews(eventObj); |
54 | - } else{ | 56 | + } |
57 | + else if(message.text.indexOf("동선") !== -1){ | ||
58 | + console.log('[request route]') | ||
59 | + replyRoute(eventObj); | ||
60 | + } | ||
61 | + else{ | ||
55 | console.log('[request way]') | 62 | console.log('[request way]') |
56 | replyWay(eventObj); | 63 | replyWay(eventObj); |
57 | } | 64 | } |
... | @@ -135,7 +142,7 @@ function replyHello(eventObj) { | ... | @@ -135,7 +142,7 @@ function replyHello(eventObj) { |
135 | }, | 142 | }, |
136 | { | 143 | { |
137 | "type":"text", | 144 | "type":"text", |
138 | - "text":"1. 국내 현황은 '국내'를 타이핑 해주세요." + "\n" + "\n" + "2. 코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요." + "\n" + "\n" + "3. 새로운 확진자의 동선이 공개되면 알려드리겠습니다." | 145 | + "text":"1. 국내 현황은 '국내'를 타이핑 해주세요." + "\n" + "\n" + "2. 코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요." + "\n" + "\n" + "3. 용인시 확진자의 동선은 '동선'을 입력해주세요." + "\n" + "\n" + "* 새로운 확진자의 동선이 공개되면 알려드리겠습니다." |
139 | }, | 146 | }, |
140 | { | 147 | { |
141 | "type":"text", | 148 | "type":"text", |
... | @@ -192,6 +199,60 @@ function replyWay(eventObj) { | ... | @@ -192,6 +199,60 @@ function replyWay(eventObj) { |
192 | }); | 199 | }); |
193 | } | 200 | } |
194 | 201 | ||
202 | +// reply route yongin | ||
203 | +function replyRoute(eventObj) { | ||
204 | + | ||
205 | + var array = fs.readFileSync('yongin.txt').toString().split("\n"); | ||
206 | + real_Text = "" | ||
207 | + for (i in array) { | ||
208 | + if (array[i] == "[인적사항]" || array[i] == "[환자 현황]" || array[i] == "[확진자 현황]") { | ||
209 | + if (i == 0) { | ||
210 | + real_Text += array[i]; | ||
211 | + } else { | ||
212 | + array[i] = '\n' + '\n' + "[인적사항]"; | ||
213 | + real_Text += array[i]; | ||
214 | + } | ||
215 | + | ||
216 | + } | ||
217 | + else if(array[i].indexOf("○") !== -1){ | ||
218 | + array[i] = array[i] + '\n'; | ||
219 | + real_Text += array[i] | ||
220 | + } | ||
221 | + else { | ||
222 | + real_Text += array[i] | ||
223 | + } | ||
224 | + real_Text += '\n' | ||
225 | + } | ||
226 | + | ||
227 | + request.post( | ||
228 | + { | ||
229 | + url: TARGET_URL, | ||
230 | + headers: { | ||
231 | + 'Authorization': `Bearer ${TOKEN}` | ||
232 | + }, | ||
233 | + json: { | ||
234 | + "replyToken":eventObj.replyToken, | ||
235 | + "messages":[ | ||
236 | + { | ||
237 | + "type":"text", | ||
238 | + "text":"최근 확진자의 정보입니다. 감사합니다." | ||
239 | + }, | ||
240 | + { | ||
241 | + "type":"text", | ||
242 | + "text":real_Text | ||
243 | + }, | ||
244 | + { | ||
245 | + "type": "sticker", | ||
246 | + "packageId": "11539", | ||
247 | + "stickerId": "52114110" | ||
248 | + } | ||
249 | + ] | ||
250 | + } | ||
251 | + },(error, response, body) => { | ||
252 | + console.log(body) | ||
253 | + }); | ||
254 | +} | ||
255 | + | ||
195 | // Broadcast yongin | 256 | // Broadcast yongin |
196 | function broadcast(){ | 257 | function broadcast(){ |
197 | 258 | ... | ... |
image/hello.jpg
0 → 100644

66.8 KB
... | @@ -36,18 +36,20 @@ | ... | @@ -36,18 +36,20 @@ |
36 | ## Getting Started | 36 | ## Getting Started |
37 | 1. [LINE](https://line.me/ko/) 설치 <br> | 37 | 1. [LINE](https://line.me/ko/) 설치 <br> |
38 | 38 | ||
39 | - 2. 친구 추가<br/> | 39 | + 2. 친구 추가<br> |
40 | - * QR code<br/> | 40 | + * QR code<br> |
41 | + 하단의 QR code를 통해 친구추가를 할 수 있습니다. <br> | ||
42 | + | ||
41 | <img src="image/qrcode.png" width="200" height="200"> <br> | 43 | <img src="image/qrcode.png" width="200" height="200"> <br> |
42 | - | 44 | +<br> |
43 | - 상단의 QR code를 통해 친구추가를 할 수 있습니다. <br> | ||
44 | 45 | ||
45 | * ID <br> | 46 | * ID <br> |
46 | 아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br> | 47 | 아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br> |
47 | <br> | 48 | <br> |
48 | 49 | ||
49 | - 3. 정보제공동의 <br> | 50 | + |
50 | - 코로나알리미와의 채팅창에서 정보 제공 동의 진행을 해야합니다. <br> | 51 | + * 정보제공동의 <br> |
52 | + 코로나알리미와의 채팅창에서 정보 제공 동의를 진행해야 합니다. <br> | ||
51 | 53 | ||
52 | 54 | ||
53 | ### Installation | 55 | ### Installation | ... | ... |
-
Please register or login to post a comment