임승현

Merge branch 'master' into 'feature/Chatbot_megabox'

Add KakaoAPI feature and Add refreshing and Fix bug



See merge request !32
......@@ -17,9 +17,11 @@ var app = express();
app.use(bodyParser.json());
/////////////////////////////////////////////////
// commit 할때 지워야 할것들
const USER_ID = ''
const TOKEN = ''
const domain = ""
const USER_ID = '';
const TOKEN = '';
const domain = '';
const KAKAO_KEY = '';
/////////////////////////////////////////////////
let MEGA_date;
let MEGA_TheaterLocation;
......@@ -31,6 +33,7 @@ let initFlag = false; //브랜드 선택 flag
let MEGA_flag = -1; //메가박스 인지 확인하는 flag
let MEGA_count; //메가박스에서 영화관 판단하는 count
let MEGA_AbleLocationList = []; //메가박스에서 영화관 이름 매치하는 것 저장하는 list
let MegaboxKakaoResultTheater = [];
exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL;
////////////////////////////////////////////////
//처음 영화관을 가져오는 것까지 대략 30초가 걸림 => 30초 기다리고 메세지 전송
......@@ -193,17 +196,16 @@ app.post('/hook', asyncHandler(async (req, res, next) => {
PushMessage(PlayingMovie, "바로 링크가 보내집니다.");
MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[0]];
setTimeout(function () {
const final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo="+ MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
console.log(final_URL)
PushURLMessage(PC_final_URL, Smartphone_final_URL);
}, 1000);
setTimeout(function () {
initFlag = false;
MEGA_flag = -1;
MEGA_PlayingMovieList = [];
PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요.");
}, 1000);
}, 1000);
} else {
let index = 0;
for (let playingmovie = 0; playingmovie < Object.keys(MEGA_PlayingMovieList).length; playingmovie++) {
......@@ -219,17 +221,26 @@ app.post('/hook', asyncHandler(async (req, res, next) => {
MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[index]];
const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo="+ MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date;
console.log(PC_final_URL);
console.log(PC_final_URL, Smartphone_final_URL);
PushURLMessage(PC_final_URL, Smartphone_final_URL);
MEGA_PlayingMovieList = []; //영화 리스트 초기화
MegaboxKakaoResultTheater = [];
GetMegaboxKakaoMapURL(MEGA_TheaterLocation);
setTimeout(function () {
MEGA_PlayingMovieList = [];
console.log(MegaboxKakaoResultTheater[0]);
let MegaboxKakaoResultTheaterNAME = MegaboxKakaoResultTheater[0]['theater_name'];
let MegaboxKakaoResultTheaterURL = MegaboxKakaoResultTheater[0]['theater_url'];
console.log(MegaboxKakaoResultTheaterNAME, MegaboxKakaoResultTheaterURL);
PushMessage(MegaboxKakaoResultTheaterURL, "카카오맵으로 검색한 " + MegaboxKakaoResultTheaterNAME+ "의 위치입니다.");
setTimeout(function () {
//EGA_PlayingMovieList = [];
initFlag = false;
MEGA_flag = -1;
PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요.");
}, 1000);
}, 2000);
}
}
res.sendStatus(200);
}))
//});
......@@ -255,7 +266,6 @@ function GettingToday(){
var dateString = year + month + day;
var dateInt = parseInt(dateString);
console.log(dateInt);
return dateInt;
}
......@@ -263,6 +273,46 @@ function GettingToday(){
var dayInMilliseconds = 1000 * 60 * 60 * 24;
setInterval(function() { megabox.init(); console.log("success") },dayInMilliseconds );
//Megabox - Kakao API로 영화관 위치 찾기
GetMegaboxKakaoMapURL= async(LOCATE) => {
let KAKAOOPTION = {
url: "https://dapi.kakao.com/v2/local/search/keyword",
method: "GET",
headers: {
'Authorization': `KakaoAK ${KAKAO_KEY}` // commit 할때 지워야 할것
},
qs: {
'query': '메가박스 ' + LOCATE, // 메가박스 영화관이름
//'category_group_code' : 'CT1',
'size': 5
},
encoding: 'UTF-8'
};
let selectable_theaters = [];
request(KAKAOOPTION, function (err, res, body) {
info_list = JSON.parse(body).documents;
if (!err && res.statusCode == 200) {
info_list.forEach(info => {
//console.log(info.category_name);
if (info.category_name.endsWith("메가박스")) {
const theater_info = {
"theater_name": info.place_name,
"theater_url": info.place_url
};
//console.log(theater_info);
//return theater_info;
selectable_theaters.push(theater_info);
}
});
}
console.log(selectable_theaters);
MegaboxKakaoResultTheater = selectable_theaters;
return;
});
}
//메세지 전송하는 function 모음
function SendMessage(eventObj, text1, text2 = "") { //reply message
request.post(
......
This diff could not be displayed because it is too large.
......@@ -16,7 +16,9 @@
"chromedriver": "^101.0.0",
"express": "^4.18.1",
"express-async-handler": "^1.2.0",
"moment": "^2.29.3",
"puppeteer": "^14.1.1",
"request": "^2.88.2",
"selenium-webdriver": "^4.1.2"
}
}
......