장수창

modified app

...@@ -7,9 +7,9 @@ const yongin_url = 'http://www.yongin.go.kr/health/ictsd/INC_selectIctsdPatntLis ...@@ -7,9 +7,9 @@ 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 = '' 10 +const TOKEN = 'input your token'
11 -const NAVER_NEWS_ID = '' 11 +const NAVER_NEWS_ID = 'input your id'
12 -const NAVER_NEWS_SECRET = '' 12 +const NAVER_NEWS_SECRET = 'input 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');
...@@ -19,9 +19,10 @@ const bodyParser = require('body-parser'); ...@@ -19,9 +19,10 @@ const bodyParser = require('body-parser');
19 var app = express(); 19 var app = express();
20 20
21 21
22 -// broadcast route 22 +// broadcast route yongin
23 var period_broadcast = 100000; 23 var period_broadcast = 100000;
24 var count_broadcast = 0; 24 var count_broadcast = 0;
25 +
25 setInterval(function(){ 26 setInterval(function(){
26 broadcast(); 27 broadcast();
27 }, period_broadcast); 28 }, period_broadcast);
...@@ -44,21 +45,21 @@ app.post('/hook', function (req, res) { ...@@ -44,21 +45,21 @@ app.post('/hook', function (req, res) {
44 var sub_nationwide = "국내"; 45 var sub_nationwide = "국내";
45 if(isNationWide.indexOf(sub_nationwide) !== -1){ 46 if(isNationWide.indexOf(sub_nationwide) !== -1){
46 replyNationWide(eventObj); 47 replyNationWide(eventObj);
47 - } 48 + } else if(message.text == "야" || message.text == "도움말" || message.text.indexOf("어떻게") !== -1){
48 - 49 + console.log('[request hello]')
49 - var sub_hello = "어떻게" 50 + replyHello(eventObj);
50 - if(message.text == "야" || message.text == "도움말" || message.text.indexOf(sub_hello) !== -1){ 51 + } else if(message.text.indexOf("뉴스") !== -1){
51 - hello(eventObj); 52 + console.log('[request news]')
52 - }
53 -
54 - if(message.text.indexOf("뉴스") !== -1){
55 replyNews(eventObj); 53 replyNews(eventObj);
54 + } else{
55 + console.log('[request way]')
56 + replyWay(eventObj);
56 } 57 }
57 58
58 res.sendStatus(200); 59 res.sendStatus(200);
59 }); 60 });
60 61
61 -//reply 62 +//reply status
62 function replyNationWide(eventObj) { 63 function replyNationWide(eventObj) {
63 //read status 64 //read status
64 request.post(ncov_url, function (err, res, body) { 65 request.post(ncov_url, function (err, res, body) {
...@@ -117,7 +118,7 @@ function replyNationWide(eventObj) { ...@@ -117,7 +118,7 @@ function replyNationWide(eventObj) {
117 } 118 }
118 119
119 //hello 120 //hello
120 -function hello(eventObj) { 121 +function replyHello(eventObj) {
121 122
122 request.post( 123 request.post(
123 { 124 {
...@@ -134,21 +135,55 @@ function hello(eventObj) { ...@@ -134,21 +135,55 @@ function hello(eventObj) {
134 }, 135 },
135 { 136 {
136 "type":"text", 137 "type":"text",
137 - "text":"국내 현황은 '국내'를 타이핑 해주세요." 138 + "text":"1. 국내 현황은 '국내'를 타이핑 해주세요." + "\n" + "\n" + "2. 코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요." + "\n" + "\n" + "3. 새로운 확진자의 동선이 공개되면 알려드리겠습니다."
138 }, 139 },
139 { 140 {
140 "type":"text", 141 "type":"text",
141 - "text":"코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요." 142 + "text":"감사합니다."
143 + },
144 + {
145 + "type": "sticker",
146 + "packageId": "11539",
147 + "stickerId": "52114110"
148 + }
149 +
150 + ]
151 + }
152 + },(error, response, body) => {
153 + console.log(body)
154 + });
155 +}
156 +
157 +// else
158 +function replyWay(eventObj) {
159 +
160 + request.post(
161 + {
162 + url: TARGET_URL,
163 + headers: {
164 + 'Authorization': `Bearer ${TOKEN}`
165 + },
166 + json: {
167 + "replyToken":eventObj.replyToken,
168 + "messages":[
169 + {
170 + "type":"text",
171 + "text":"대답할 수 없는 입력입니다."
142 }, 172 },
143 { 173 {
144 "type":"text", 174 "type":"text",
145 - "text":"감사합니다." 175 + "text":"사용 방법은 '도움말'을 입력해주세요."
146 }, 176 },
147 { 177 {
148 "type": "sticker", 178 "type": "sticker",
149 "packageId": "11539", 179 "packageId": "11539",
150 - "stickerId": "52114110" 180 + "stickerId": "52114129"
181 + },
182 + {
183 + "type":"text",
184 + "text":"감사합니다."
151 } 185 }
186 +
152 187
153 ] 188 ]
154 } 189 }
......
This diff is collapsed. Click to expand it.
1 { 1 {
2 - "name": "push",
3 - "version": "1.0.0",
4 - "description": "",
5 - "main": "app.js",
6 - "scripts": {
7 - "test": "echo \"Error: no test specified\" && exit 1"
8 - },
9 - "author": "",
10 - "license": "ISC",
11 - "dependencies": {
12 - "python-shell": "^2.0.1",
13 - "request": "^2.88.2"
14 - }
15 - }
...\ No newline at end of file ...\ No newline at end of file
2 + "name": "reply",
3 + "version": "1.0.0",
4 + "description": "",
5 + "main": "app.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "author": "",
10 + "license": "ISC",
11 + "dependencies": {
12 + "axios": "^0.19.2",
13 + "body-parser": "^1.19.0",
14 + "cheerio": "^1.0.0-rc.3",
15 + "express": "^4.17.1",
16 + "request": "^2.88.2"
17 + }
18 +}
...\ No newline at end of file ...\ No newline at end of file
......
1 <!-- PROJECT TITLE --> 1 <!-- PROJECT TITLE -->
2 -# Covid-19 Information Chatbot 2 +# Covid-19 Information Chatbot <br>
3 - ### 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇 3 +
4 +### 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇
5 +
4 <img src="image/name.png" width="320" height="280"> 6 <img src="image/name.png" width="320" height="280">
5 7
6 8
...@@ -20,7 +22,7 @@ ...@@ -20,7 +22,7 @@
20 22
21 <!-- About The Project --> 23 <!-- About The Project -->
22 ## About The Project 24 ## About The Project
23 - * Line messaging API 기반 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇입니다. 25 + * Line messaging API 기반 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇입니다. <br>
24 주 기능은 확진환자의 역학조사가 끝나거나 신규 확진자 발생 시 알림 메세지 전송입니다. 26 주 기능은 확진환자의 역학조사가 끝나거나 신규 확진자 발생 시 알림 메세지 전송입니다.
25 27
26 28
...@@ -32,20 +34,20 @@ ...@@ -32,20 +34,20 @@
32 34
33 <!-- GETTING STARTED --> 35 <!-- GETTING STARTED -->
34 ## Getting Started 36 ## Getting Started
35 - 1. [LINE](https://line.me/ko/) 설치<br/> 37 + 1. [LINE](https://line.me/ko/) 설치 <br>
36 38
37 2. 친구 추가<br/> 39 2. 친구 추가<br/>
38 * QR code<br/> 40 * QR code<br/>
39 -<img src="image/QRcode.PNG" width="200" height="200"> <br/> 41 +<img src="image/qrcode.png" width="200" height="200"> <br>
40 42
41 - 상단의 QR code를 통해 친구추가를 할 수 있습니다.<br/> 43 + 상단의 QR code를 통해 친구추가를 할 수 있습니다. <br>
42 44
43 - * ID <br/> 45 + * ID <br>
44 - 아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br/> 46 + 아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br>
45 -<br/> 47 +<br>
46 48
47 - 3. 정보제공동의<br/> 49 + 3. 정보제공동의 <br>
48 - 코로나알리미와의 채팅창에서 정보 제공 동의 진행을 해야합니다. <br/> 50 + 코로나알리미와의 채팅창에서 정보 제공 동의 진행을 해야합니다. <br>
49 51
50 52
51 ### Installation 53 ### Installation
...@@ -54,6 +56,7 @@ ...@@ -54,6 +56,7 @@
54 ``` 56 ```
55 git clone http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git 57 git clone http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git
56 ``` 58 ```
59 +
57 2. Install NPM 60 2. Install NPM
58 ``` 61 ```
59 npm install request 62 npm install request
...@@ -61,6 +64,7 @@ ...@@ -61,6 +64,7 @@
61 npm install axios 64 npm install axios
62 npm install cheerio 65 npm install cheerio
63 ``` 66 ```
67 +
64 3. Enter your information 68 3. Enter your information
65 ``` 69 ```
66 const TOKEN = 'Your Token' 70 const TOKEN = 'Your Token'
...@@ -72,19 +76,19 @@ ...@@ -72,19 +76,19 @@
72 76
73 <!-- USAGE EXAMPLES --> 77 <!-- USAGE EXAMPLES -->
74 ## Usage 78 ## Usage
75 - * 코로나 알리미에게 사용 방법에 대해 물어보세요. 키워드는 '어떻게'입니다. <br/> 79 + * 코로나 알리미에게 사용 방법에 대해 물어보세요. 키워드는 '어떻게'입니다. <br>
76 - 80 +<br>
77 - * 국내 현황 <br/> 81 + * 국내 현황 <br>
78 - 코로나 알리미에게 COVID-19 국내 현황에 대해 물어보세요. 키워드는 '국내'입니다.<br/> 82 + 코로나 알리미에게 COVID-19 국내 현황에 대해 물어보세요. 키워드는 '국내'입니다.<br>
79 -<br/> 83 +<br>
80 84
81 85
82 - * 관련 뉴스 <br/> 86 + * 관련 뉴스 <br>
83 - 코로나 알리미에게 COVID-19 관련 뉴스에 대해 물어보세요. 키워드는 '뉴스'입니다.<br/> 87 + 코로나 알리미에게 COVID-19 관련 뉴스에 대해 물어보세요. 키워드는 '뉴스'입니다.<br>
84 - <br/> 88 + <br>
85 89
86 - * 확진자 동선 알림 (용인시) <br/> 90 + * 확진자 동선 알림 (용인시) <br>
87 - 코로나 알리미가 새로운 확진자의 동선이 사이트에 올라오면 이를 실시간으로 알려줍니다. <br/> 91 + 코로나 알리미가 새로운 확진자의 동선이 사이트에 올라오면 이를 실시간으로 알려줍니다. <br>
88 92
89 93
90 <!-- CONTRIBUTING --> 94 <!-- CONTRIBUTING -->
...@@ -100,6 +104,6 @@ ...@@ -100,6 +104,6 @@
100 <!-- CONTACT --> 104 <!-- CONTACT -->
101 ## Contact 105 ## Contact
102 106
103 -Suchang Jang - sudori1024@khu.ac.kr <br/> 107 +Suchang Jang - sudori1024@khu.ac.kr <br>
104 108
105 Project Link: [http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git](http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git) 109 Project Link: [http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git](http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git)
...\ No newline at end of file ...\ No newline at end of file
......