Toggle navigation
Toggle navigation
This project
Loading...
Sign in
임승현
/
Multiplex_Ticketing_Platform
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
이혜인
2022-06-06 22:46:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a104d8b8a40d9e8e44efa8fc103255dc3f440d07
a104d8b8
1 parent
2659eacd
add link
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
8 deletions
Chatbot/app.js
Chatbot/app.js
View file @
a104d8b
...
...
@@ -31,6 +31,7 @@ exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL;
let
MEGA_flag
=
0
;
function
SendMessage
(
eventObj
,
text1
,
text2
=
""
){
request
.
post
(
{
...
...
@@ -81,6 +82,113 @@ request.post(
});
}
function
PusbuttonhMessage
(
final_URL
){
request
.
post
(
{
url
:
PUSH_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"to"
:
`
${
USER_ID
}
`
,
"type"
:
"template"
,
"altText"
:
"this is a carousel template"
,
"template"
:
{
"type"
:
"carousel"
,
"columns"
:
[
{
"thumbnailImageUrl"
:
"https://megabox.co.kr/SharedImg/2022/05/16/WApIttC9CrStYU7j7jzFRlc2HsIXBQtY_150.jpg"
,
"imageBackgroundColor"
:
"#FFFFFF"
,
"title"
:
"this is menu"
,
"text"
:
"description"
,
"defaultAction"
:
{
"type"
:
"uri"
,
"label"
:
"View detail"
,
"uri"
:
"https://megabox.co.kr/"
},
"actions"
:
[
{
"type"
:
"message"
,
"label"
:
"Yes"
,
"text"
:
"Yes"
},
{
"type"
:
"message"
,
"label"
:
"Yes"
,
"text"
:
"Yes"
},
{
"type"
:
"uri"
,
"label"
:
"View detail"
,
"uri"
:
"https://megabox.co.kr/"
}
]
},
{
"thumbnailImageUrl"
:
"https://example.com/bot/images/item2.jpg"
,
"imageBackgroundColor"
:
"#000000"
,
"title"
:
"this is menu"
,
"text"
:
"description"
,
"defaultAction"
:
{
"type"
:
"uri"
,
"label"
:
"View detail"
,
"uri"
:
"http://example.com/page/222"
},
"actions"
:
[
{
"type"
:
"message"
,
"label"
:
"Yes"
,
"text"
:
"Yes"
},
{
"type"
:
"message"
,
"label"
:
"Yes"
,
"text"
:
"Yes"
},
{
"type"
:
"uri"
,
"label"
:
"View detail"
,
"uri"
:
"https://megabox.co.kr/"
}
]
}
],
"imageAspectRatio"
:
"rectangle"
,
"imageSize"
:
"cover"
}
}
// {
// "type": "template",
// //"altText": "This is a buttons template",
// "template": {
// "type": "buttons",
// "thumbnailImageUrl": "https://megabox.co.kr/SharedImg/2022/05/16/WApIttC9CrStYU7j7jzFRlc2HsIXBQtY_150.jpg",
// "imageAspectRatio": "rectangle",
// "imageSize": "cover",
// "imageBackgroundColor": "#FFFFFF",
// "title": "Menu",
// "text": "Please select",
// "actions": [
// {
// "type": "message",
// "label": "Yes",
// "text": "yes"
// },
// {
// "type": "uri",
// "label": "View detail",
// "uri": final_URL
// }
// ]
// }
//}
}
)}
app
.
post
(
'/hook'
,
(
req
,
res
)
=>
{
var
eventObj
=
req
.
body
.
events
[
0
];
...
...
@@ -93,11 +201,13 @@ app.post('/hook', (req, res) => {
console
.
log
(
'[request source] '
,
eventObj
.
source
);
console
.
log
(
'[request message]'
,
eventObj
.
message
);
if
(
eventObj
.
message
.
text
==
3
&&
MEGA_flag
===
0
){
const
text1
=
"영화관 위치를 입력해주세요"
;
const
text2
=
"ex1)강남"
;
SendMessage
(
eventObj
,
text1
,
text2
);
MEGA_flag
++
;
PusbuttonhMessage
(
"https://developers.line.biz/en/reference/messaging-api/#message-common-properties"
);
console
.
log
(
MEGA_flag
)
}
...
...
@@ -138,22 +248,24 @@ app.post('/hook', (req, res) => {
}
if
(
MEGA_flag
===
4
){
let
index
=
0
;
let
obj
=
{};
let
n
;
let
PlayingMovie
=
"-현재 상영작-\n\n"
;
const
text1
=
"현재상영작을 가져오는 중입니다."
;
const
text2
=
"잠시만 기다려주세요."
;
PushMessage
(
eventObj
,
text1
,
text2
);
setTimeout
(
function
()
{
let
movietitle
;
console
.
log
(
megabox
.
movie_data
);
for
(
n
=
0
;
n
<
Object
.
keys
(
megabox
.
movie_data
).
length
;
n
++
){
if
(
megabox
.
movie_data
[
n
].
running
===
'Y'
){
console
.
log
(
megabox
.
movie_data
[
n
]);
MEGA_PlayingMovieList
[
index
++
]
=
megabox
.
movie_data
[
n
].
title
;
movietitle
=
megabox
.
movie_data
[
n
].
title
;
MEGA_PlayingMovieList
[
movietitle
]
=
megabox
.
movie_data
[
n
].
movie_num
;
}
n
++
;
}
console
.
log
(
MEGA_PlayingMovieList
);
if
(
MEGA_PlayingMovieList
.
length
==
0
){
SendMessage
(
eventObj
,
"현재상영작이 없습니다."
,
""
);
...
...
@@ -162,10 +274,10 @@ app.post('/hook', (req, res) => {
SendMessage
(
eventObj
,
MEGA_PlayingMovieList
[
0
],
""
);
}
else
{
index
=
0
;
for
(
let
playingmovie
=
0
;
playingmovie
<
MEGA_PlayingMovieList
.
length
;
playingmovie
++
)
let
index
=
0
;
for
(
let
playingmovie
=
0
;
playingmovie
<
Object
.
keys
(
MEGA_PlayingMovieList
)
.
length
;
playingmovie
++
)
{
PlayingMovie
+=
(
playingmovie
+
1
).
toString
()
+
'. '
+
MEGA_PlayingMovieList
[
playingmovie
];
PlayingMovie
+=
(
playingmovie
+
1
).
toString
()
+
'. '
+
Object
.
keys
(
MEGA_PlayingMovieList
)[
index
++
];
PlayingMovie
+=
"\n"
;
}
...
...
@@ -179,7 +291,13 @@ app.post('/hook', (req, res) => {
}
if
(
MEGA_flag
===
5
){
const
index
=
parseInt
(
message
.
text
)
-
1
;
//MEGA_title =
MEGA_title
=
MEGA_PlayingMovieList
[
Object
.
keys
(
MEGA_PlayingMovieList
)[
index
]]
const
final_URL
=
"https://www.megabox.co.kr/booking?rpstMovieNo="
+
MEGA_title
+
"&brchNo1="
+
MEGA_TheaterLocation
+
'&playDe='
+
MEGA_date
;
console
.
log
(
final_URL
)
PushMessage
(
eventObj
,
final_URL
,
"예매창으로 바로 이동합니다."
);
}
...
...
Please
register
or
login
to post a comment