장수창

modified app

......@@ -7,9 +7,9 @@ const yongin_url = 'http://www.yongin.go.kr/health/ictsd/INC_selectIctsdPatntLis
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast'
const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast'
const TOKEN = ''
const NAVER_NEWS_ID = ''
const NAVER_NEWS_SECRET = ''
const TOKEN = 'input your token'
const NAVER_NEWS_ID = 'input your id'
const NAVER_NEWS_SECRET = 'input your secret'
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
......@@ -19,9 +19,10 @@ const bodyParser = require('body-parser');
var app = express();
// broadcast route
// broadcast route yongin
var period_broadcast = 100000;
var count_broadcast = 0;
setInterval(function(){
broadcast();
}, period_broadcast);
......@@ -44,21 +45,21 @@ app.post('/hook', function (req, res) {
var sub_nationwide = "국내";
if(isNationWide.indexOf(sub_nationwide) !== -1){
replyNationWide(eventObj);
}
var sub_hello = "어떻게"
if(message.text == "야" || message.text == "도움말" || message.text.indexOf(sub_hello) !== -1){
hello(eventObj);
}
if(message.text.indexOf("뉴스") !== -1){
} else if(message.text == "야" || message.text == "도움말" || message.text.indexOf("어떻게") !== -1){
console.log('[request hello]')
replyHello(eventObj);
} else if(message.text.indexOf("뉴스") !== -1){
console.log('[request news]')
replyNews(eventObj);
} else{
console.log('[request way]')
replyWay(eventObj);
}
res.sendStatus(200);
});
//reply
//reply status
function replyNationWide(eventObj) {
//read status
request.post(ncov_url, function (err, res, body) {
......@@ -117,7 +118,7 @@ function replyNationWide(eventObj) {
}
//hello
function hello(eventObj) {
function replyHello(eventObj) {
request.post(
{
......@@ -134,22 +135,56 @@ function hello(eventObj) {
},
{
"type":"text",
"text":"국내 현황은 '국내'를 타이핑 해주세요."
"text":"1. 국내 현황은 '국내'를 타이핑 해주세요." + "\n" + "\n" + "2. 코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요." + "\n" + "\n" + "3. 새로운 확진자의 동선이 공개되면 알려드리겠습니다."
},
{
"type":"text",
"text":"코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요."
"text":"감사합니다."
},
{
"type": "sticker",
"packageId": "11539",
"stickerId": "52114110"
}
]
}
},(error, response, body) => {
console.log(body)
});
}
// else
function replyWay(eventObj) {
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":"감사합니다."
"text":"대답할 수 없는 입력입니다."
},
{
"type":"text",
"text":"사용 방법은 '도움말'을 입력해주세요."
},
{
"type": "sticker",
"packageId": "11539",
"stickerId": "52114110"
"stickerId": "52114129"
},
{
"type":"text",
"text":"감사합니다."
}
]
}
},(error, response, body) => {
......
This diff is collapsed. Click to expand it.
{
"name": "push",
"name": "reply",
"version": "1.0.0",
"description": "",
"main": "app.js",
......@@ -9,7 +9,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"python-shell": "^2.0.1",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.3",
"express": "^4.17.1",
"request": "^2.88.2"
}
}
\ No newline at end of file
}
\ No newline at end of file
......
<!-- PROJECT TITLE -->
# Covid-19 Information Chatbot
### 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇
# Covid-19 Information Chatbot <br>
### 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇
<img src="image/name.png" width="320" height="280">
......@@ -20,7 +22,7 @@
<!-- About The Project -->
## About The Project
* Line messaging API 기반 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇입니다.
* Line messaging API 기반 코로나 바이러스 감염증-19(COVID-19) 관련 정보 챗봇입니다. <br>
주 기능은 확진환자의 역학조사가 끝나거나 신규 확진자 발생 시 알림 메세지 전송입니다.
......@@ -32,20 +34,20 @@
<!-- GETTING STARTED -->
## Getting Started
1. [LINE](https://line.me/ko/) 설치<br/>
1. [LINE](https://line.me/ko/) 설치 <br>
2. 친구 추가<br/>
* QR code<br/>
<img src="image/QRcode.PNG" width="200" height="200"> <br/>
<img src="image/qrcode.png" width="200" height="200"> <br>
상단의 QR code를 통해 친구추가를 할 수 있습니다.<br/>
상단의 QR code를 통해 친구추가를 할 수 있습니다. <br>
* ID <br/>
아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br/>
<br/>
* ID <br>
아이디를 통해 친구추가를 할 수 있습니다. 아이디는 '@453hriym' 입니다. <br>
<br>
3. 정보제공동의<br/>
코로나알리미와의 채팅창에서 정보 제공 동의 진행을 해야합니다. <br/>
3. 정보제공동의 <br>
코로나알리미와의 채팅창에서 정보 제공 동의 진행을 해야합니다. <br>
### Installation
......@@ -54,6 +56,7 @@
```
git clone http://khuhub.khu.ac.kr/2015104213/oss_Termproject_chatbot.git
```
2. Install NPM
```
npm install request
......@@ -61,6 +64,7 @@
npm install axios
npm install cheerio
```
3. Enter your information
```
const TOKEN = 'Your Token'
......@@ -72,19 +76,19 @@
<!-- USAGE EXAMPLES -->
## Usage
* 코로나 알리미에게 사용 방법에 대해 물어보세요. 키워드는 '어떻게'입니다. <br/>
* 국내 현황 <br/>
코로나 알리미에게 COVID-19 국내 현황에 대해 물어보세요. 키워드는 '국내'입니다.<br/>
<br/>
* 코로나 알리미에게 사용 방법에 대해 물어보세요. 키워드는 '어떻게'입니다. <br>
<br>
* 국내 현황 <br>
코로나 알리미에게 COVID-19 국내 현황에 대해 물어보세요. 키워드는 '국내'입니다.<br>
<br>
* 관련 뉴스 <br/>
코로나 알리미에게 COVID-19 관련 뉴스에 대해 물어보세요. 키워드는 '뉴스'입니다.<br/>
<br/>
* 관련 뉴스 <br>
코로나 알리미에게 COVID-19 관련 뉴스에 대해 물어보세요. 키워드는 '뉴스'입니다.<br>
<br>
* 확진자 동선 알림 (용인시) <br/>
코로나 알리미가 새로운 확진자의 동선이 사이트에 올라오면 이를 실시간으로 알려줍니다. <br/>
* 확진자 동선 알림 (용인시) <br>
코로나 알리미가 새로운 확진자의 동선이 사이트에 올라오면 이를 실시간으로 알려줍니다. <br>
<!-- CONTRIBUTING -->
......@@ -100,6 +104,6 @@
<!-- CONTACT -->
## Contact
Suchang Jang - sudori1024@khu.ac.kr <br/>
Suchang Jang - sudori1024@khu.ac.kr <br>
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
......