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-05 22:44:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ade4b9277f9c1c7074db91b37c2b458d96573df
3ade4b92
1 parent
cd9d16e4
chatbot 초기 단계
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
82 deletions
Chatbot/Megabox.js
Chatbot/app.js
Chatbot/Megabox.js
View file @
3ade4b9
...
...
@@ -19,7 +19,7 @@ app.use(bodyParser.urlencoded({ extended: false }));
app
.
use
(
bodyParser
.
json
());
const
booking_url
=
"https://megabox.co.kr/booking"
;
const
booking_url
=
"https://megabox.co.kr/booking
?
"
;
exports
.
booking_url
=
booking_url
;
const
rate_url
=
"https://www.megabox.co.kr/movie"
;
...
...
@@ -33,6 +33,7 @@ let index = 0;
exports
.
init
=
()
=>
{
async
.
waterfall
([
//for 동기적 처리
async
()
=>
{
const
driver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
//
driver
.
get
(
booking_url
);
driver
.
switchTo
().
frame
(
0
)
//frameBokdMBooking 프레임 가져옴
...
...
@@ -55,8 +56,7 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
// let location_num = await item.getAttribute("brch-no");
// let obj = {};
// obj[location_name]= location_num
// location_data[index++] = obj;
// location_data[index++] = obj;
}
}
...
...
@@ -108,30 +108,17 @@ exports.init = ()=>{async.waterfall([//for 동기적 처리
const
appdriver
=
new
webdriver
.
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
chrome
.
Options
().
headless
()).
build
();
let
PlayingMovieList
=
[];
exports
.
PlayingMovieList
=
PlayingMovieList
;
exports
.
using_PlayingMovieURL
=
function
(
PlayingMovieURL
){
async
(
)
=>
{
exports
.
using_PlayingMovieURL
=
async
(
PlayingMovieURL
)
=>
{
appdriver
.
get
(
PlayingMovieURL
);
appdriver
.
switchTo
().
frame
(
0
)
}
//frameBokdMBooking 프레임 가져옴
//
appdriver.switchTo().frame(0)
//frameBokdMBooking 프레임 가져옴
}
exports
.
geting_PlayingMovie
=
function
(){
async
(
)
=>
{
let
movie_list
=
await
appdriver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_1_container>ul>li>.btn'
)));
let
n
=
0
;
for
(
item
of
movie_list
)
{
let
play
=
await
item
.
getAttribute
(
'form-at'
)
let
title
=
await
item
.
getAttribute
(
"movie-nm"
);
if
(
play
===
'y'
){
PlayingMovieList
[
n
++
]
=
{
title
:
await
item
.
getAttribute
(
"movie-no"
)
}
}
}
console
.
log
(
PlayingMovieList
);
exports
.
geting_PlayingMovie
=
async
()
=>
{
let
movie_list
=
await
appdriver
.
wait
(
until
.
elementsLocated
(
By
.
css
(
'#mCSB_1_container>ul>li>.btn'
)));
let
n
=
0
;
for
(
item
of
movie_list
)
{
movie_data
[
n
++
][
'running'
]
=
await
item
.
getAttribute
(
'form-at'
)
}
}
...
...
Chatbot/app.js
View file @
3ade4b9
let
megabox
=
require
(
'./Megabox.js'
);
const
async
=
require
(
'async'
)
//let SearchingTheaterAPI = require('./SearchingTheaterAPI');
megabox
.
init
();
const
request
=
require
(
'request'
);
...
...
@@ -15,12 +17,42 @@ const bodyParser = require('body-parser');
var
app
=
express
();
app
.
use
(
bodyParser
.
json
());
const
moment
=
require
(
"moment"
);
let
MEGA_date
;
let
MEGA_TheaterLocation
;
let
MEGA_title
;
let
MEGA_PlayingMovieURL
;
exports
.
MEGA_PlayingMovieURL
=
MEGA_PlayingMovieURL
;
let
MEGA_flag
=
0
;
function
SendMessage
(
eventObj
,
text1
,
text2
=
""
){
request
.
post
(
{
url
:
REPLY_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
REPLY_TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
text1
},
{
"type"
:
"text"
,
"text"
:
text2
}
]
}
},(
error
,
response
,
body
)
=>
{
//console.log(body)
});
}
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
...
...
@@ -33,75 +65,52 @@ app.post('/hook', function (req, res) {
console
.
log
(
'[request source] '
,
eventObj
.
source
);
console
.
log
(
'[request message]'
,
eventObj
.
message
);
if
(
eventObj
.
message
.
text
==
3
){
request
.
post
(
{
url
:
REPLY_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
REPLY_TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"영화를 보실 날짜를 입력해주세요(잘못 입력하면 당일 날짜가 들어갑니다.)"
},
{
"type"
:
"text"
,
"text"
:
"ex)20020409"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
eventObj
.
message
.
text
.
length
===
8
){
MEGA_date
=
parseInt
(
message
.
text
);
request
.
post
(
{
url
:
REPLY_TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
REPLY_TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"영화관 위치를 입력해주세요"
},
{
"type"
:
"text"
,
"text"
:
"ex1)강남, ex2)강남시티"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
eventObj
.
message
.
text
==
3
&&
MEGA_flag
===
0
){
const
text1
=
"영화관 위치를 입력해주세요"
;
const
text2
=
"ex1)강남, ex2)강남시티"
;
SendMessage
(
eventObj
,
text1
,
text2
);
MEGA_flag
++
;
}
if
(
MEGA_flag
===
1
){
for
(
i
of
megabox
.
location_data
){
if
(
i
[
'LocationName'
]
==
message
.
text
){
if
(
i
[
'LocationName'
]
===
message
.
text
){
MEGA_TheaterLocation
=
i
[
'LocationNUm'
];
console
.
log
(
MEGA_TheaterLocation
)
console
.
log
(
MEGA_TheaterLocation
);
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
);
if
(
MEGA_date
&&
MEGA_TheaterLocation
){
MEGA_PlayingMovieURL
=
megabox
.
booking_url
+
'?brchNo1='
+
MEGA_TheaterLocation
+
'&playDe='
+
MEGA_date
;
MEGA_PlayingMovieURL
=
"https://megabox.co.kr/on/oh/ohb/SimpleBooking/simpleBookingPage.do"
+
'?brchNo1='
+
MEGA_TheaterLocation
+
'&playDe='
+
MEGA_date
;
console
.
log
(
MEGA_PlayingMovieURL
)
async
.
waterfall
[
megabox
.
using_PlayingMovieURL
(
MEGA_PlayingMovieURL
),
megabox
.
geting_PlayingMovie
(),
async
()
=>
{
console
.
log
(
megabox
.
PlayingMovieList
)}
megabox
.
geting_PlayingMovie
()
]
MEGA_flag
++
}
}
if
(
MEGA_flag
===
4
){
console
.
log
(
megabox
.
movie_data
);
}
res
.
sendStatus
(
200
);
});
...
...
Please
register
or
login
to post a comment