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 03:23:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2659eacd66f2877059121535dc5579101accd0f5
2659eacd
1 parent
3ade4b92
replying movie to play
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
60 deletions
Chatbot/Megabox.js
Chatbot/app.js
Chatbot/Megabox.js
View file @
2659eac
...
...
@@ -66,6 +66,7 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
//Using getAttribute to get the data
movie_data
[
r
++
]
=
{
'rank'
:
r
,
'title'
:
await
item
.
getAttribute
(
"movie-nm"
),
'movie_num'
:
await
item
.
getAttribute
(
"movie-no"
),
}
...
...
@@ -100,7 +101,7 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
movie_data
[
r
++
][
'rate'
]
=
'예매율 0%'
;
}
}
console
.
log
(
"completed"
)
browser
.
close
();
},
...
...
@@ -120,54 +121,10 @@ exports.geting_PlayingMovie= async() => {
for
(
item
of
movie_list
)
{
movie_data
[
n
++
][
'running'
]
=
await
item
.
getAttribute
(
'form-at'
)
}
console
.
log
(
"completed"
)
}
// let userData = {
// 'Date': '',
// 'location':''
// };
// // const _sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
// app.get('/Megabox', (req, res) => {
// res.send(movie_data);
// })
// app.post('/Megabox', (req, res) => {//사용자에게 Date와 location(영화관 장소) 받아옴
// let PlayingMovieURL;
// userData['Date'] = req.body.Date;
// for(i of location_data){
// if(i['LocationName'] == req.body.location){
// userData['location']=i['LocationNUm'];
// break;
// }
// }
// PlayingMovieURL = booking_url + '?brchNo1='+userData['location']+'&playDe='+userData['Date'];//사용자 정보 바탕으로 해당 일자 영화관 영화 상영 여부 확인
// appdriver.get(PlayingMovieURL);
// appdriver.switchTo().frame(0)//frameBokdMBooking 프레임 가져옴
// res.send(movie_data);
// })
// app.post('/Megabox', (req, res) => {//사용자에게 Date와 location(영화관 장소) 받아옴
// userData['Date'] = req.body.Date;
// for(i of location_data){
// if(i['LocationName'] == req.body.location){
// userData['location']=i['LocationNUm'];
// break;
// }
// }
// let PlayingMovieURL = booking_url + '?brchNo1='+userData['location']+'&playDe='+userData['Date'];//사용자 정보 바탕으로 해당 일자 영화관 영화 상영 여부 확인
// appdriver.get(PlayingMovieURL);
// appdriver.switchTo().frame(0)//frameBokdMBooking 프레임 가져옴
// res.send(movie_data);
// })
app
.
get
(
'/Megabox/GetPlayingMovie'
,
async
(
req
,
res
,
next
)
=>
{
//영화 상영 여부 객체에 넣음
// let movie_list = await appdriver.wait(until.elementsLocated(By.css('#mCSB_1_container>ul>li>.btn')));
...
...
@@ -181,4 +138,4 @@ app.get('/Megabox/GetPlayingMovie', async(req, res, next) => {//영화 상영
res
.
send
(
PlayingMovieList
);
})
app
.
listen
(
6000
);
\ No newline at end of file
app
.
listen
(
8000
);
\ No newline at end of file
...
...
Chatbot/app.js
View file @
2659eac
...
...
@@ -6,8 +6,11 @@ megabox.init();
const
request
=
require
(
'request'
);
var
express
=
require
(
'express'
);
const
PUSH_TARGET_URL
=
'https://api.line.me/v2/bot/message/push'
const
USER_ID
=
''
const
REPLY_TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
REPLY_
TOKEN
=
''
const
TOKEN
=
''
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
...
...
@@ -21,6 +24,7 @@ const moment = require("moment");
let
MEGA_date
;
let
MEGA_TheaterLocation
;
let
MEGA_PlayingMovieList
=
[];
let
MEGA_title
;
let
MEGA_PlayingMovieURL
;
exports
.
MEGA_PlayingMovieURL
=
MEGA_PlayingMovieURL
;
...
...
@@ -32,7 +36,7 @@ function SendMessage(eventObj, text1, text2 = ""){
{
url
:
REPLY_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
REPLY_
TOKEN
}
`
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
...
...
@@ -49,11 +53,35 @@ function SendMessage(eventObj, text1, text2 = ""){
}
},(
error
,
response
,
body
)
=>
{
//console.log(body)
console
.
log
(
body
);
});
}
function
PushMessage
(
eventObj
,
text1
,
text2
=
""
){
request
.
post
(
{
url
:
PUSH_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"to"
:
`
${
USER_ID
}
`
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
text1
},
{
"type"
:
"text"
,
"text"
:
text2
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
app
.
post
(
'/hook'
,
(
req
,
res
)
=>
{
var
eventObj
=
req
.
body
.
events
[
0
];
var
source
=
eventObj
.
source
;
...
...
@@ -67,37 +95,36 @@ app.post('/hook', function (req, res) {
if
(
eventObj
.
message
.
text
==
3
&&
MEGA_flag
===
0
){
const
text1
=
"영화관 위치를 입력해주세요"
;
const
text2
=
"ex1)강남, ex2)강남시티"
;
const
text2
=
"ex1)강남"
;
SendMessage
(
eventObj
,
text1
,
text2
);
MEGA_flag
++
;
console
.
log
(
MEGA_flag
)
}
if
(
MEGA_flag
===
1
){
console
.
log
(
MEGA_flag
);
for
(
i
of
megabox
.
location_data
){
if
(
i
[
'LocationName'
]
===
message
.
text
){
MEGA_TheaterLocation
=
i
[
'LocationNUm'
];
console
.
log
(
MEGA_TheaterLocation
);
MEGA_flag
++
;
console
.
log
(
MEGA_flag
)
break
;
}
}
}
else
{
SendMessage
(
eventObj
,
"다시입력해주세요"
);
}
if
(
MEGA_flag
===
2
){
MEGA_date
=
parseInt
(
message
.
text
);
const
text1
=
"영화를 보실 날짜를 입력해주세요."
;
const
text2
=
"ex)20020409"
;
SendMessage
(
eventObj
,
text1
,
text2
);
++
MEGA_flag
;
}
if
(
moment
(
eventObj
.
message
.
text
,
"YYYYMMDD"
,
true
).
isValid
()
&&
MEGA_flag
===
3
){
console
.
log
(
3
);
MEGA_date
=
parseInt
(
eventObj
.
message
.
text
);
if
(
MEGA_date
&&
MEGA_TheaterLocation
){
MEGA_PlayingMovieURL
=
"https://megabox.co.kr/on/oh/ohb/SimpleBooking/simpleBookingPage.do"
+
'?brchNo1='
+
MEGA_TheaterLocation
+
'&playDe='
+
MEGA_date
;
console
.
log
(
MEGA_PlayingMovieURL
)
...
...
@@ -106,11 +133,56 @@ app.post('/hook', function (req, res) {
megabox
.
geting_PlayingMovie
()
]
MEGA_flag
++
console
.
log
(
MEGA_flag
);
}
}
if
(
MEGA_flag
===
4
){
let
index
=
0
;
let
n
;
let
PlayingMovie
=
"-현재 상영작-\n\n"
;
const
text1
=
"현재상영작을 가져오는 중입니다."
;
const
text2
=
"잠시만 기다려주세요."
;
PushMessage
(
eventObj
,
text1
,
text2
);
setTimeout
(
function
()
{
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
;
}
n
++
;
}
if
(
MEGA_PlayingMovieList
.
length
==
0
){
SendMessage
(
eventObj
,
"현재상영작이 없습니다."
,
""
);
}
else
if
(
MEGA_PlayingMovieList
.
length
==
1
){
SendMessage
(
eventObj
,
MEGA_PlayingMovieList
[
0
],
""
);
}
else
{
index
=
0
;
for
(
let
playingmovie
=
0
;
playingmovie
<
MEGA_PlayingMovieList
.
length
;
playingmovie
++
)
{
PlayingMovie
+=
(
playingmovie
+
1
).
toString
()
+
'. '
+
MEGA_PlayingMovieList
[
playingmovie
];
PlayingMovie
+=
"\n"
;
}
console
.
log
(
PlayingMovie
);
PushMessage
(
eventObj
,
PlayingMovie
,
"예매할 영화 번호를 입력해주세요.\n ex)1 (영화 앞 숫자만 입력)"
);
}
MEGA_flag
++
;
},
10000
);
}
if
(
MEGA_flag
===
5
){
const
index
=
parseInt
(
message
.
text
)
-
1
;
//MEGA_title =
}
res
.
sendStatus
(
200
);
});
...
...
Please
register
or
login
to post a comment