Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신승미
/
weatherClothing
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Seungmi
2020-12-10 02:08:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
67c5eb09d4221cff556e01cf8ed5cd1b543dc3ae
67c5eb09
1 parent
a563ab44
python 추가
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
11 deletions
app.js
app.js
View file @
67c5eb0
...
...
@@ -11,9 +11,10 @@ const bodyParser = require('body-parser');
var
app
=
express
();
const
{
info
}
=
require
(
'console'
);
var
PythonShell
=
require
(
'python-shell'
);
var
{
PythonShell
}
=
require
(
'python-shell'
);
var
pyshell
=
new
PythonShell
(
'weather_chat.py'
);
var
options
=
{
let
options
=
{
mode
:
'text'
,
pythonPath
:
''
,
pythonOptions
:
[
'-u'
],
...
...
@@ -41,11 +42,8 @@ app.post('/hook', function (req, res) {
else
if
(
eventObj
.
message
.
text
==
"이용방법"
)
{
chatUse
(
eventObj
.
replyToken
);
}
else
if
(
eventObj
.
message
.
text
==
"오늘의 날씨는"
)
{
PythonShell
.
run
(
'weather_chat.py'
,
options
,
function
(
err
,
results
)
{
if
(
err
)
throw
err
;
console
.
log
(
'results: %j'
,
results
);
});
else
if
(
eventObj
.
message
.
text
==
"오늘의 날씨는?"
)
{
chatWeather
(
eventObj
.
replyToken
);
}
else
{
chatWrong
(
eventObj
.
replyToken
);
...
...
@@ -66,7 +64,7 @@ function chatInfo(replyToken){
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"서울 지역의 날씨와 기온에 따른 옷차림새를 추천해줍니다."
"text"
:
"서울 지역의
오늘의
날씨와 기온에 따른 옷차림새를 추천해줍니다."
}
]
}
...
...
@@ -87,7 +85,7 @@ function chatUse(replyToken){
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"오늘의 날씨는? 을 똑같이\n
입력해주시면 작동합니다."
"text"
:
"오늘의 날씨는? 을 똑같이\n입력해주시면 작동합니다."
}
]
}
...
...
@@ -96,7 +94,15 @@ function chatUse(replyToken){
});
}
function
chatWrong
(
replyToken
){
function
chatWeather
(
replyToken
){
var
PM
=
" "
;
pyshell
.
send
(
'request'
)
pyshell
.
on
(
'message'
,
function
(
data
){
console
.
log
(
data
);
PM
=
data
;
});
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -108,7 +114,7 @@ function chatWrong(replyToken){
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"잘못된 입력입니다.\n '이용방법' 혹은 '오늘의 날씨는?'을 입력해주세요."
"text"
:
PM
}
]
}
...
...
@@ -117,6 +123,27 @@ function chatWrong(replyToken){
});
}
function
chatWrong
(
replyToken
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"잘못된 입력입니다.\n'설명', '이용방법', '오늘의 날씨는?' \n중 하나를 입력해주세요."
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
...
...
Please
register
or
login
to post a comment