Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장수창
/
COVID19_Information_Chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
장수창
2020-06-19 22:25:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
44b55f43c354ce3f2ed2f540cd76b87624f60a28
44b55f43
1 parent
31acb319
added news reply
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
6 deletions
nodejs/app.js
nodejs/app.js
View file @
44b55f4
...
...
@@ -44,7 +44,11 @@ app.post('/hook', function (req, res) {
var
sub_hello
=
"어떻게"
if
(
message
.
text
==
"야"
||
message
.
text
==
"도움말"
||
message
.
text
.
indexOf
(
sub_hello
)
!==
-
1
){
hello
(
eventObj
)
hello
(
eventObj
);
}
if
(
message
.
text
.
indexOf
(
"뉴스"
)
!==
-
1
){
replyNews
(
eventObj
);
}
res
.
sendStatus
(
200
);
...
...
@@ -117,6 +121,10 @@ function hello(eventObj) {
"text"
:
"국내 현황은 '국내'를 타이핑 해주세요."
},
{
"type"
:
"text"
,
"text"
:
"코로나 19 관련 뉴스는 '뉴스'를 타이핑 해주세요."
},
{
"type"
:
"sticker"
,
"packageId"
:
"11539"
,
"stickerId"
:
"52114110"
...
...
@@ -167,11 +175,11 @@ function broadcast(){
// "messages":[
// {
// "type":"text",
// "text":"
Hello, user
"
// "text":"
용인시
"
// },
// {
// "type":"text",
// "text":"
May I help you?
"
// "text":"
용인시
"
// }
// ]
// }
...
...
@@ -179,10 +187,11 @@ function broadcast(){
// console.log(body)
// });
function
news_Crawling
()
{
//reply news
function
replyNews
(
eventObj
)
{
var
news_Title
=
[
'title1'
,
'title2'
,
'title3'
,
'title4'
,
'title5'
]
var
news_Link
=
[
'link1'
,
'link2'
,
'link3'
,
'link4'
,
'link5'
]
var
news_Title
=
[
'title1'
,
'title2'
,
'title3'
,
'title4'
,
'title5'
]
;
var
news_Link
=
[
'link1'
,
'link2'
,
'link3'
,
'link4'
,
'link5'
]
;
request
.
get
({
url
:
'https://openapi.naver.com/v1/search/news'
,
qs
:
{
...
...
@@ -202,6 +211,42 @@ function news_Crawling() {
news_Title
[
i
]
=
json
.
items
[
i
].
title
.
replace
(
'<b>'
,
''
).
replace
(
'</b>'
,
''
).
replace
(
'"'
,
''
).
replace
(
'"'
,
''
);
news_Link
[
i
]
=
json
.
items
[
i
].
link
;
}
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
news_Title
[
0
]
+
'\n'
+
news_Link
[
0
]
},
{
"type"
:
"text"
,
"text"
:
news_Title
[
1
]
+
'\n'
+
news_Link
[
1
]
},
{
"type"
:
"text"
,
"text"
:
news_Title
[
2
]
+
'\n'
+
news_Link
[
2
]
},
{
"type"
:
"text"
,
"text"
:
news_Title
[
3
]
+
'\n'
+
news_Link
[
3
]
},
{
"type"
:
"text"
,
"text"
:
news_Title
[
4
]
+
'\n'
+
news_Link
[
4
]
}
]
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
})
}
...
...
Please
register
or
login
to post a comment