Showing
1 changed file
with
108 additions
and
72 deletions
| ... | @@ -4,7 +4,6 @@ const CGV = require('./CGVTicketing.js'); | ... | @@ -4,7 +4,6 @@ const CGV = require('./CGVTicketing.js'); |
| 4 | const async = require('async'); | 4 | const async = require('async'); |
| 5 | MEGABOX.init(); //메가박스 코드 시작(영화관 리스트 가져오기) | 5 | MEGABOX.init(); //메가박스 코드 시작(영화관 리스트 가져오기) |
| 6 | CGV.init(); //CGV 코드 시작 | 6 | CGV.init(); //CGV 코드 시작 |
| 7 | -const PUSH_TARGET_URL = 'https://api.line.me/v2/bot/message/push' | ||
| 8 | const REPLY_TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 7 | const REPLY_TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
| 9 | const asyncHandler = require('express-async-handler') | 8 | const asyncHandler = require('express-async-handler') |
| 10 | const bodyParser = require('body-parser'); | 9 | const bodyParser = require('body-parser'); |
| ... | @@ -19,7 +18,6 @@ var app = express(); | ... | @@ -19,7 +18,6 @@ var app = express(); |
| 19 | app.use(bodyParser.json()); | 18 | app.use(bodyParser.json()); |
| 20 | ///////////////////////////////////////////////// | 19 | ///////////////////////////////////////////////// |
| 21 | // commit 할때 지워야 할것들 | 20 | // commit 할때 지워야 할것들 |
| 22 | -const USER_ID = ''; | ||
| 23 | const TOKEN = ''; | 21 | const TOKEN = ''; |
| 24 | const domain = ''; | 22 | const domain = ''; |
| 25 | const KAKAO_KEY = ''; | 23 | const KAKAO_KEY = ''; |
| ... | @@ -32,6 +30,7 @@ let CGV_date = ""; //날짜 | ... | @@ -32,6 +30,7 @@ let CGV_date = ""; //날짜 |
| 32 | let CGV_RequestedLocation = ""; //사용자가 입력한 장소 | 30 | let CGV_RequestedLocation = ""; //사용자가 입력한 장소 |
| 33 | let CGV_RespondedTheaters = []; //API를 통해 받아온 영화관들 및 카카오맵 연결 링크 | 31 | let CGV_RespondedTheaters = []; //API를 통해 받아온 영화관들 및 카카오맵 연결 링크 |
| 34 | let CGV_SelectedTheater = ""; //사용자가 설정한 영화관 이름 | 32 | let CGV_SelectedTheater = ""; //사용자가 설정한 영화관 이름 |
| 33 | +let CGV_SelectedTheaterURL = ""; | ||
| 35 | let CGV_SelectedTheaterCode = ""; //영화관 고유코드 | 34 | let CGV_SelectedTheaterCode = ""; //영화관 고유코드 |
| 36 | let CGV_accessible_movies = []; //상영 날짜와 상영관에 따라 예매할 수 있는 영화 목록 | 35 | let CGV_accessible_movies = []; //상영 날짜와 상영관에 따라 예매할 수 있는 영화 목록 |
| 37 | let CGV_movie_chart = []; | 36 | let CGV_movie_chart = []; |
| ... | @@ -56,9 +55,9 @@ exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL; | ... | @@ -56,9 +55,9 @@ exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL; |
| 56 | //////////////////////////////////////////////// | 55 | //////////////////////////////////////////////// |
| 57 | //처음 영화관을 가져오는 것까지 대략 30초가 걸림 => 30초 기다리고 메세지 전송 | 56 | //처음 영화관을 가져오는 것까지 대략 30초가 걸림 => 30초 기다리고 메세지 전송 |
| 58 | 57 | ||
| 59 | -setTimeout(function () { | 58 | +// setTimeout(function () { |
| 60 | - PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 59 | +// PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 61 | -}, 30000); | 60 | +// }, 30000); |
| 62 | 61 | ||
| 63 | //app.post('/hook', function (req, res) { | 62 | //app.post('/hook', function (req, res) { |
| 64 | app.post('/hook', asyncHandler(async (req, res, next) => { | 63 | app.post('/hook', asyncHandler(async (req, res, next) => { |
| ... | @@ -76,7 +75,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -76,7 +75,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 76 | if (eventObj.message.text == "브랜드") { | 75 | if (eventObj.message.text == "브랜드") { |
| 77 | initFlag = false; | 76 | initFlag = false; |
| 78 | MEGA_flag = -1; | 77 | MEGA_flag = -1; |
| 79 | - PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 78 | + PushSingleMessage(eventObj, "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 80 | } | 79 | } |
| 81 | 80 | ||
| 82 | if (initFlag == false && eventObj.message.text == "1") { //브랜드 선택- CGV 인 경우: CGV_flag를 0으로 두어 메가박스 임을 확인 | 81 | if (initFlag == false && eventObj.message.text == "1") { //브랜드 선택- CGV 인 경우: CGV_flag를 0으로 두어 메가박스 임을 확인 |
| ... | @@ -103,7 +102,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -103,7 +102,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 103 | GetCGVKakaoLocalAPI(CGV_RequestedLocation); | 102 | GetCGVKakaoLocalAPI(CGV_RequestedLocation); |
| 104 | setTimeout(function () { | 103 | setTimeout(function () { |
| 105 | if (CGV_RespondedTheaters.length == 0) | 104 | if (CGV_RespondedTheaters.length == 0) |
| 106 | - PushSingleMessage("검색 결과가 없습니다. 다시 입력해주세요."); | 105 | + PushSingleMessage(eventObj, "검색 결과가 없습니다. 다시 입력해주세요."); |
| 107 | else { | 106 | else { |
| 108 | if (CGV_RespondedTheaters.length == 1) { | 107 | if (CGV_RespondedTheaters.length == 1) { |
| 109 | CGV_SelectedTheater = CGV_RespondedTheaters[0].theater_name; | 108 | CGV_SelectedTheater = CGV_RespondedTheaters[0].theater_name; |
| ... | @@ -118,7 +117,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -118,7 +117,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 118 | CGV_OutputString += String(i + 1) + ": " + CGV_RespondedTheaters[i].theater_name + "\n"; | 117 | CGV_OutputString += String(i + 1) + ": " + CGV_RespondedTheaters[i].theater_name + "\n"; |
| 119 | } | 118 | } |
| 120 | CGV_OutputString += String(CGV_RespondedTheaters.length + 1) + ": 다시 검색하기"; | 119 | CGV_OutputString += String(CGV_RespondedTheaters.length + 1) + ": 다시 검색하기"; |
| 121 | - PushSingleMessage(CGV_OutputString); | 120 | + PushSingleMessage(eventObj, CGV_OutputString); |
| 122 | CGV_flag = 101; | 121 | CGV_flag = 101; |
| 123 | } | 122 | } |
| 124 | } | 123 | } |
| ... | @@ -129,6 +128,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -129,6 +128,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 129 | let selection = parseInt(message.text); | 128 | let selection = parseInt(message.text); |
| 130 | if (selection > 0 && selection < CGV_RespondedTheaters.length + 1) { | 129 | if (selection > 0 && selection < CGV_RespondedTheaters.length + 1) { |
| 131 | CGV_SelectedTheater = CGV_RespondedTheaters[selection - 1].theater_name; | 130 | CGV_SelectedTheater = CGV_RespondedTheaters[selection - 1].theater_name; |
| 131 | + CGV_SelectedTheaterURL = CGV_RespondedTheaters[selection - 1].theater_url; | ||
| 132 | CGV_SelectedTheaterCode = await CGV.getTheaterCode(CGV_SelectedTheater); | 132 | CGV_SelectedTheaterCode = await CGV.getTheaterCode(CGV_SelectedTheater); |
| 133 | CGV_flag = 2; | 133 | CGV_flag = 2; |
| 134 | } | 134 | } |
| ... | @@ -142,7 +142,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -142,7 +142,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 142 | } | 142 | } |
| 143 | ////날짜 입력 받기 | 143 | ////날짜 입력 받기 |
| 144 | if (CGV_flag === 2) { | 144 | if (CGV_flag === 2) { |
| 145 | - const text1 = "선택한 영화관은 CGV" + CGV_SelectedTheater + "입니다.\n 영화를 관람할 날짜를 선택해 주세요."; | 145 | + const text1 = "선택한 영화관은 " + CGV_SelectedTheater + "입니다.\n 영화를 관람할 날짜를 선택해 주세요."; |
| 146 | const text2 = "ex)20020409, YYYYMMDD"; | 146 | const text2 = "ex)20020409, YYYYMMDD"; |
| 147 | SendMessage(eventObj, text1, text2); | 147 | SendMessage(eventObj, text1, text2); |
| 148 | CGV_flag = 3; | 148 | CGV_flag = 3; |
| ... | @@ -156,7 +156,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -156,7 +156,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 156 | CGV_accessible_movies = await CGV.getMovieChart(5); | 156 | CGV_accessible_movies = await CGV.getMovieChart(5); |
| 157 | const text1 = "현재상영작을 가져오는 중입니다."; | 157 | const text1 = "현재상영작을 가져오는 중입니다."; |
| 158 | const text2 = "잠시만 기다려주세요."; | 158 | const text2 = "잠시만 기다려주세요."; |
| 159 | - PushMessage(text1, text2); | 159 | + //PushMessage(text1, text2); |
| 160 | console.log(CGV_accessible_movies); | 160 | console.log(CGV_accessible_movies); |
| 161 | CGV_flag++; | 161 | CGV_flag++; |
| 162 | } else { | 162 | } else { |
| ... | @@ -180,23 +180,23 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -180,23 +180,23 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 180 | if (CGV_flag === 4) { | 180 | if (CGV_flag === 4) { |
| 181 | let AccessibleMovieText = "-- 예매 가능한 상영작 --\n\n"; | 181 | let AccessibleMovieText = "-- 예매 가능한 상영작 --\n\n"; |
| 182 | if (CGV_accessible_movies.length == 0) { | 182 | if (CGV_accessible_movies.length == 0) { |
| 183 | - PushMessage("현재상영작이 없습니다.", "영화관 선택 단계로 이동합니다."); | 183 | + PushMessage(eventObj, "현재상영작이 없습니다.\n영화관 선택 단계로 이동합니다.", "영화관 위치를 입력해주세요\nex1)강남"); |
| 184 | - setTimeout(function () { | 184 | + // setTimeout(function () { |
| 185 | - PushMessage("영화관 위치를 입력해주세요", "ex1) 강남"); | 185 | + // PushMessage(eventObj, "영화관 위치를 입력해주세요", "ex1) 강남"); |
| 186 | - }, 1000); | 186 | + // }, 1000); |
| 187 | CGV_flag = 1; | 187 | CGV_flag = 1; |
| 188 | } | 188 | } |
| 189 | else if (CGV_accessible_movies.length == 1) { | 189 | else if (CGV_accessible_movies.length == 1) { |
| 190 | AccessibleMovieText += ("1. " + CGV_accessible_movies[0].title); | 190 | AccessibleMovieText += ("1. " + CGV_accessible_movies[0].title); |
| 191 | const SelectedMovieCode = CGV_accessible_movies[0].code; | 191 | const SelectedMovieCode = CGV_accessible_movies[0].code; |
| 192 | - PushMessage(AccessibleMovieText, "바로 링크가 전송됩니다."); | 192 | + //PushMessage(AccessibleMovieText, "바로 링크가 전송됩니다."); |
| 193 | - setTimeout(function () { | 193 | + //setTimeout(function () { |
| 194 | - const finalURL_web = CGV_url_web + "?MOVIE_CD=" + SelectedMovieCode + "&MOVIE_CD_GROUP=" + SelectedMovieCode + "&THEATER_CD=" + CGV_SelectedTheaterCode + "&PLAY_YMD=" + CGV_date; | 194 | + const finalURL_web = CGV_url_web + "?MOVIE_CD=" + SelectedMovieCode + "&MOVIE_CD_GROUP=" + SelectedMovieCode + "&THEATER_CD=" + CGV_SelectedTheaterCode + "&PLAY_YMD=" + CGV_date; |
| 195 | - const finalURL_mobile = CGV_url_mobile + "?mgc=" + SelectedMovieCode + "&tc=" + CGV_SelectedTheaterCode + "&ymd=" + CGV_date; | 195 | + const finalURL_mobile = CGV_url_mobile + "?mgc=" + SelectedMovieCode + "&tc=" + CGV_SelectedTheaterCode + "&ymd=" + CGV_date; |
| 196 | - //console.log(finalURL_web); | 196 | + //console.log(finalURL_web); |
| 197 | - //PushMessage(finalURL_web, "링크를 누르면 예매 창으로 바로 이동합니다."); | 197 | + //PushMessage(finalURL_web, "링크를 누르면 예매 창으로 바로 이동합니다."); |
| 198 | - PushURLMessage(finalURL_web, finalURL_mobile); | 198 | + PushFinalMessage(eventObj, finalURL_web, finalURL_mobile, CGV_SelectedTheaterURL, "카카오맵으로 검색한 " + CGV_SelectedTheater + "의 위치입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 199 | - }, 1000); | 199 | + //}, 1000); |
| 200 | } | 200 | } |
| 201 | else { | 201 | else { |
| 202 | setTimeout(function () { | 202 | setTimeout(function () { |
| ... | @@ -207,7 +207,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -207,7 +207,7 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 207 | rank++; | 207 | rank++; |
| 208 | } | 208 | } |
| 209 | console.log(AccessibleMovieText); | 209 | console.log(AccessibleMovieText); |
| 210 | - PushMessage(AccessibleMovieText, "예매할 영화 번호를 입력해주세요.\n ex)1 (영화 앞 숫자만 입력)"); | 210 | + PushMessage(eventObj, AccessibleMovieText, "예매할 영화 번호를 입력해주세요.\n ex)1 (영화 앞 숫자만 입력)"); |
| 211 | CGV_flag = 5; | 211 | CGV_flag = 5; |
| 212 | }, 1000); | 212 | }, 1000); |
| 213 | } | 213 | } |
| ... | @@ -215,30 +215,30 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -215,30 +215,30 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 215 | if (CGV_flag === 5) { | 215 | if (CGV_flag === 5) { |
| 216 | const index = parseInt(message.text) - 1; | 216 | const index = parseInt(message.text) - 1; |
| 217 | if (index < 0 || index > 4) { | 217 | if (index < 0 || index > 4) { |
| 218 | - PushSingleMessage("다시 입력해주세요!"); | 218 | + PushSingleMessage(eventObj, "다시 입력해주세요!"); |
| 219 | } else { | 219 | } else { |
| 220 | const SelectedMovieCode = CGV_accessible_movies[index].code; | 220 | const SelectedMovieCode = CGV_accessible_movies[index].code; |
| 221 | const finalURL_web = CGV_url_web + "?MOVIE_CD=" + SelectedMovieCode + "&MOVIE_CD_GROUP=" + SelectedMovieCode + "&THEATER_CD=" + CGV_SelectedTheaterCode + "&PLAY_YMD=" + CGV_date; | 221 | const finalURL_web = CGV_url_web + "?MOVIE_CD=" + SelectedMovieCode + "&MOVIE_CD_GROUP=" + SelectedMovieCode + "&THEATER_CD=" + CGV_SelectedTheaterCode + "&PLAY_YMD=" + CGV_date; |
| 222 | const finalURL_mobile = CGV_url_mobile + "?mgc=" + SelectedMovieCode + "&tc=" + CGV_SelectedTheaterCode + "&ymd=" + CGV_date; | 222 | const finalURL_mobile = CGV_url_mobile + "?mgc=" + SelectedMovieCode + "&tc=" + CGV_SelectedTheaterCode + "&ymd=" + CGV_date; |
| 223 | //console.log(finalURL_web); | 223 | //console.log(finalURL_web); |
| 224 | //PushMessage(finalURL_web, "링크를 누르면 예매 창으로 바로 이동합니다."); | 224 | //PushMessage(finalURL_web, "링크를 누르면 예매 창으로 바로 이동합니다."); |
| 225 | - PushURLMessage(finalURL_web, finalURL_mobile); | 225 | + PushFinalMessage(eventObj, finalURL_web, finalURL_mobile, CGV_SelectedTheaterURL, "카카오맵으로 검색한 " + CGV_SelectedTheater + "의 위치입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 226 | - setTimeout(function () { | 226 | + //setTimeout(function () { |
| 227 | - initFlag = false; | 227 | + initFlag = false; |
| 228 | - CGV_flag = -1; | 228 | + CGV_flag = -1; |
| 229 | - PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 229 | + //PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 230 | - }, 1000); | 230 | + //}, 1000); |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | } else if (initFlag == true && LOTTE_flag != -1) { //롯데시네마로 브랜드 선택된 경우 | 233 | } else if (initFlag == true && LOTTE_flag != -1) { //롯데시네마로 브랜드 선택된 경우 |
| 234 | - PushMessage("현재 롯데시네마는 AWS 서버 문제로 지원되지 않습니다!\n다른 브랜드를 선택해주세요.\n롯데시네마의 예매 링크 사이트는 https://www.lottecinema.co.kr/NLCHS/Ticketing 입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 234 | + PushMessage(eventObj, "현재 롯데시네마는 AWS 서버 문제로 지원되지 않습니다!\n다른 브랜드를 선택해주세요.\n롯데시네마의 예매 링크 사이트는 https://www.lottecinema.co.kr/NLCHS/Ticketing 입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 235 | initFlag = false; | 235 | initFlag = false; |
| 236 | LOTTE_flag = -1; | 236 | LOTTE_flag = -1; |
| 237 | } | 237 | } |
| 238 | else if (initFlag == true && MEGA_flag != -1) { //메가박스로 브랜드 선택된 경우 | 238 | else if (initFlag == true && MEGA_flag != -1) { //메가박스로 브랜드 선택된 경우 |
| 239 | if (MEGA_flag == 0) { | 239 | if (MEGA_flag == 0) { |
| 240 | const text1 = "영화관 위치를 입력해주세요"; | 240 | const text1 = "영화관 위치를 입력해주세요"; |
| 241 | - const text2 = "ex1)강남"; | 241 | + const text2 = "ex)강남"; |
| 242 | SendMessage(eventObj, text1, text2); | 242 | SendMessage(eventObj, text1, text2); |
| 243 | MEGA_flag++; | 243 | MEGA_flag++; |
| 244 | //PusbuttonhMessage("https://developers.line.biz/en/reference/messaging-api/#message-common-properties"); | 244 | //PusbuttonhMessage("https://developers.line.biz/en/reference/messaging-api/#message-common-properties"); |
| ... | @@ -267,10 +267,10 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -267,10 +267,10 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 267 | console.log(String(x + 1), MEGA_AbleLocationList[x].LocationName); | 267 | console.log(String(x + 1), MEGA_AbleLocationList[x].LocationName); |
| 268 | } | 268 | } |
| 269 | MEGA_OutputString += String(MEGA_count + 1) + ": 다시 검색하기"; | 269 | MEGA_OutputString += String(MEGA_count + 1) + ": 다시 검색하기"; |
| 270 | - PushSingleMessage(MEGA_OutputString); | 270 | + PushSingleMessage(eventObj, MEGA_OutputString); |
| 271 | MEGA_flag = 101; | 271 | MEGA_flag = 101; |
| 272 | } else { | 272 | } else { |
| 273 | - PushSingleMessage("다시 입력해주세요."); | 273 | + PushSingleMessage(eventObj, "다시 입력해주세요."); |
| 274 | } | 274 | } |
| 275 | //원본 코드 | 275 | //원본 코드 |
| 276 | //console.log(MEGA_flag); | 276 | //console.log(MEGA_flag); |
| ... | @@ -313,9 +313,9 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -313,9 +313,9 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 313 | let today = GettingToday();//오늘 이후인지 확인하기 위해 날짜 가져옴 | 313 | let today = GettingToday();//오늘 이후인지 확인하기 위해 날짜 가져옴 |
| 314 | //console.log(MEGA_date, MEGA_TheaterLocation); | 314 | //console.log(MEGA_date, MEGA_TheaterLocation); |
| 315 | if (today <= MEGA_date && MEGA_date && MEGA_TheaterLocationCode) { | 315 | if (today <= MEGA_date && MEGA_date && MEGA_TheaterLocationCode) { |
| 316 | - const text1 = "현재상영작을 가져오는 중입니다."; | 316 | + //const text1 = "현재상영작을 가져오는 중입니다."; |
| 317 | - const text2 = "잠시만 기다려주세요."; | 317 | + //const text2 = "잠시만 기다려주세요."; |
| 318 | - PushMessage(text1, text2); | 318 | + //PushMessage(text1, text2); |
| 319 | MEGA_PlayingMovieURL = "https://megabox.co.kr/on/oh/ohb/SimpleBooking/simpleBookingPage.do" + '?brchNo1=' + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; | 319 | MEGA_PlayingMovieURL = "https://megabox.co.kr/on/oh/ohb/SimpleBooking/simpleBookingPage.do" + '?brchNo1=' + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; |
| 320 | MEGABOX.using_PlayingMovieURL(MEGA_PlayingMovieURL); | 320 | MEGABOX.using_PlayingMovieURL(MEGA_PlayingMovieURL); |
| 321 | await MEGABOX.geting_PlayingMovie(); | 321 | await MEGABOX.geting_PlayingMovie(); |
| ... | @@ -355,26 +355,26 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -355,26 +355,26 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 355 | } | 355 | } |
| 356 | console.log(Object.keys(MEGA_PlayingMovieList).length); | 356 | console.log(Object.keys(MEGA_PlayingMovieList).length); |
| 357 | if (Object.keys(MEGA_PlayingMovieList).length == 0) { | 357 | if (Object.keys(MEGA_PlayingMovieList).length == 0) { |
| 358 | - PushSingleMessage("현재상영작이 없습니다.\n영화관 선택 단계로 이동합니다."); | 358 | + PushMessage(eventObj, "현재상영작이 없습니다.\n영화관 선택 단계로 이동합니다.","영화관 위치를 입력해주세요\nex1)강남"); |
| 359 | - setTimeout(function () { | 359 | + //setTimeout(function () { |
| 360 | - PushMessage("영화관 위치를 입력해주세요", "ex1)강남"); | 360 | + //PushMessage("영화관 위치를 입력해주세요", "ex1)강남"); |
| 361 | - }, 1000); | 361 | + //}, 1000); |
| 362 | MEGA_flag = 1; | 362 | MEGA_flag = 1; |
| 363 | } else if (Object.keys(MEGA_PlayingMovieList).length == 1) { | 363 | } else if (Object.keys(MEGA_PlayingMovieList).length == 1) { |
| 364 | PlayingMovie += '1: ' + Object.keys(MEGA_PlayingMovieList)[0]; | 364 | PlayingMovie += '1: ' + Object.keys(MEGA_PlayingMovieList)[0]; |
| 365 | - PushMessage(PlayingMovie, "바로 링크가 보내집니다."); | 365 | + //PushMessage(PlayingMovie, "바로 링크가 보내집니다."); |
| 366 | MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[0]]; | 366 | MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[0]]; |
| 367 | - setTimeout(function () { | 367 | + //setTimeout(function () { |
| 368 | - const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; | 368 | + const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; |
| 369 | - const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; | 369 | + const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; |
| 370 | - PushURLMessage(PC_final_URL, Smartphone_final_URL); | 370 | + PushFinalMessage(eventObj, PC_final_URL, Smartphone_final_URL, MegaboxKakaoResultTheaterURL, "카카오맵으로 검색한 " + MegaboxKakaoResultTheaterNAME + "의 위치입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 371 | - setTimeout(function () { | 371 | + //setTimeout(function () { |
| 372 | - initFlag = false; | 372 | + initFlag = false; |
| 373 | - MEGA_flag = -1; | 373 | + MEGA_flag = -1; |
| 374 | - MEGA_PlayingMovieList = []; | 374 | + MEGA_PlayingMovieList = []; |
| 375 | - PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 375 | + //PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 376 | - }, 1000); | 376 | + //}, 1000); |
| 377 | - }, 1000); | 377 | + //}, 1000); |
| 378 | } else { | 378 | } else { |
| 379 | let index = 0; | 379 | let index = 0; |
| 380 | for (let playingmovie = 0; playingmovie < Object.keys(MEGA_PlayingMovieList).length; playingmovie++) { | 380 | for (let playingmovie = 0; playingmovie < Object.keys(MEGA_PlayingMovieList).length; playingmovie++) { |
| ... | @@ -382,20 +382,20 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -382,20 +382,20 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 382 | PlayingMovie += "\n"; | 382 | PlayingMovie += "\n"; |
| 383 | } | 383 | } |
| 384 | console.log(PlayingMovie); | 384 | console.log(PlayingMovie); |
| 385 | - await PushMessage(PlayingMovie, "예매할 영화 번호를 입력해주세요.\n ex)1 (영화 앞 숫자만 입력)"); | 385 | + PushMessage(eventObj, PlayingMovie, "예매할 영화 번호를 입력해주세요.\n ex)1 (영화 앞 숫자만 입력)"); |
| 386 | MEGA_flag = 5; | 386 | MEGA_flag = 5; |
| 387 | } | 387 | } |
| 388 | } else if (MEGA_flag == 5) { | 388 | } else if (MEGA_flag == 5) { |
| 389 | const index = parseInt(message.text) - 1; | 389 | const index = parseInt(message.text) - 1; |
| 390 | console.log(Object.keys(MEGA_PlayingMovieList).length); | 390 | console.log(Object.keys(MEGA_PlayingMovieList).length); |
| 391 | if (index < 0 || index > Object.keys(MEGA_PlayingMovieList).length - 1) { | 391 | if (index < 0 || index > Object.keys(MEGA_PlayingMovieList).length - 1) { |
| 392 | - PushSingleMessage("다시 입력해주세요!"); | 392 | + PushSingleMessage(eventObj, "다시 입력해주세요!"); |
| 393 | } else { | 393 | } else { |
| 394 | MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[index]]; | 394 | MEGA_title = MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[index]]; |
| 395 | const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; | 395 | const PC_final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; |
| 396 | const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; | 396 | const Smartphone_final_URL = "https://m.megabox.co.kr/booking/movie?movieNo=" + MEGA_title + "&brchNo1=" + MEGA_TheaterLocationCode + '&playDe=' + MEGA_date; |
| 397 | console.log(PC_final_URL, Smartphone_final_URL); | 397 | console.log(PC_final_URL, Smartphone_final_URL); |
| 398 | - PushURLMessage(PC_final_URL, Smartphone_final_URL); | 398 | + //PushURLMessage(PC_final_URL, Smartphone_final_URL); |
| 399 | MEGA_PlayingMovieList = []; //영화 리스트 초기화 | 399 | MEGA_PlayingMovieList = []; //영화 리스트 초기화 |
| 400 | MegaboxKakaoResultTheater = []; | 400 | MegaboxKakaoResultTheater = []; |
| 401 | GetMegaboxKakaoMapURL(MEGA_TheaterLocation); | 401 | GetMegaboxKakaoMapURL(MEGA_TheaterLocation); |
| ... | @@ -404,13 +404,13 @@ app.post('/hook', asyncHandler(async (req, res, next) => { | ... | @@ -404,13 +404,13 @@ app.post('/hook', asyncHandler(async (req, res, next) => { |
| 404 | let MegaboxKakaoResultTheaterNAME = MegaboxKakaoResultTheater[0]['theater_name']; | 404 | let MegaboxKakaoResultTheaterNAME = MegaboxKakaoResultTheater[0]['theater_name']; |
| 405 | let MegaboxKakaoResultTheaterURL = MegaboxKakaoResultTheater[0]['theater_url']; | 405 | let MegaboxKakaoResultTheaterURL = MegaboxKakaoResultTheater[0]['theater_url']; |
| 406 | console.log(MegaboxKakaoResultTheaterNAME, MegaboxKakaoResultTheaterURL); | 406 | console.log(MegaboxKakaoResultTheaterNAME, MegaboxKakaoResultTheaterURL); |
| 407 | - PushMessage(MegaboxKakaoResultTheaterURL, "카카오맵으로 검색한 " + MegaboxKakaoResultTheaterNAME + "의 위치입니다."); | 407 | + PushFinalMessage(eventObj, PC_final_URL, Smartphone_final_URL, MegaboxKakaoResultTheaterURL, "카카오맵으로 검색한 " + MegaboxKakaoResultTheaterNAME + "의 위치입니다.", "원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 408 | - setTimeout(function () { | 408 | + //setTimeout(function () { |
| 409 | - //EGA_PlayingMovieList = []; | 409 | + //MEGA_PlayingMovieList = []; |
| 410 | - initFlag = false; | 410 | + initFlag = false; |
| 411 | - MEGA_flag = -1; | 411 | + MEGA_flag = -1; |
| 412 | - PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); | 412 | + //PushSingleMessage("원하시는 브랜드의 번호를 입력해주세요.\n1: CGV\n2: LotteCinema\n3: Megabox\n언제든 브랜드를 바꾸고 싶으시다면 '브랜드'를 입력해주세요."); |
| 413 | - }, 1000); | 413 | + //}, 1000); |
| 414 | }, 2000); | 414 | }, 2000); |
| 415 | } | 415 | } |
| 416 | } | 416 | } |
| ... | @@ -545,15 +545,15 @@ function SendMessage(eventObj, text1, text2 = "") { //reply message | ... | @@ -545,15 +545,15 @@ function SendMessage(eventObj, text1, text2 = "") { //reply message |
| 545 | console.log(body); | 545 | console.log(body); |
| 546 | }); | 546 | }); |
| 547 | } | 547 | } |
| 548 | -function PushMessage(text1, text2 = "") { //push two message | 548 | +function PushMessage(eventObj, text1, text2 = "") { //push two message |
| 549 | request.post( | 549 | request.post( |
| 550 | { | 550 | { |
| 551 | - url: PUSH_TARGET_URL, | 551 | + url: REPLY_TARGET_URL, |
| 552 | headers: { | 552 | headers: { |
| 553 | 'Authorization': `Bearer ${TOKEN}` | 553 | 'Authorization': `Bearer ${TOKEN}` |
| 554 | }, | 554 | }, |
| 555 | json: { | 555 | json: { |
| 556 | - "to": `${USER_ID}`, | 556 | + "replyToken": eventObj.replyToken, |
| 557 | "messages": [ | 557 | "messages": [ |
| 558 | { | 558 | { |
| 559 | "type": "text", | 559 | "type": "text", |
| ... | @@ -569,15 +569,51 @@ function PushMessage(text1, text2 = "") { //push two message | ... | @@ -569,15 +569,51 @@ function PushMessage(text1, text2 = "") { //push two message |
| 569 | console.log(body) | 569 | console.log(body) |
| 570 | }); | 570 | }); |
| 571 | } | 571 | } |
| 572 | -function PushSingleMessage(text1) {//push single message | 572 | +function PushFinalMessage(eventObj, text1, text2, text3, text4, text5) { //push four message with urls |
| 573 | + request.post( | ||
| 574 | + { | ||
| 575 | + url: REPLY_TARGET_URL, | ||
| 576 | + headers: { | ||
| 577 | + 'Authorization': `Bearer ${TOKEN}` | ||
| 578 | + }, | ||
| 579 | + json: { | ||
| 580 | + "replyToken": eventObj.replyToken, | ||
| 581 | + "messages": [ | ||
| 582 | + { | ||
| 583 | + "type": "text", | ||
| 584 | + "text": "pc버전 url입니다\n\n" + text1 | ||
| 585 | + }, | ||
| 586 | + { | ||
| 587 | + "type": "text", | ||
| 588 | + "text": "mobile버전 url입니다\n\n" + text2 | ||
| 589 | + }, | ||
| 590 | + { | ||
| 591 | + "type": "text", | ||
| 592 | + "text": text3 | ||
| 593 | + }, | ||
| 594 | + { | ||
| 595 | + "type": "text", | ||
| 596 | + "text": text4 | ||
| 597 | + }, | ||
| 598 | + { | ||
| 599 | + "type": "text", | ||
| 600 | + "text": text5 | ||
| 601 | + } | ||
| 602 | + ] | ||
| 603 | + } | ||
| 604 | + }, (error, response, body) => { | ||
| 605 | + console.log(body) | ||
| 606 | + }); | ||
| 607 | +} | ||
| 608 | +function PushSingleMessage(eventObj, text1) {//push single message | ||
| 573 | request.post( | 609 | request.post( |
| 574 | { | 610 | { |
| 575 | - url: PUSH_TARGET_URL, | 611 | + url: REPLY_TARGET_URL, |
| 576 | headers: { | 612 | headers: { |
| 577 | 'Authorization': `Bearer ${TOKEN}` | 613 | 'Authorization': `Bearer ${TOKEN}` |
| 578 | }, | 614 | }, |
| 579 | json: { | 615 | json: { |
| 580 | - "to": `${USER_ID}`, | 616 | + "replyToken": eventObj.replyToken, |
| 581 | "messages": [ | 617 | "messages": [ |
| 582 | { | 618 | { |
| 583 | "type": "text", | 619 | "type": "text", |
| ... | @@ -589,15 +625,15 @@ function PushSingleMessage(text1) {//push single message | ... | @@ -589,15 +625,15 @@ function PushSingleMessage(text1) {//push single message |
| 589 | console.log(body) | 625 | console.log(body) |
| 590 | }); | 626 | }); |
| 591 | } | 627 | } |
| 592 | -function PushURLMessage(pcurl, smartphoneurl) {//push single message | 628 | +function PushURLMessage(eventObj, pcurl, smartphoneurl) {//push single message |
| 593 | request.post( | 629 | request.post( |
| 594 | { | 630 | { |
| 595 | - url: PUSH_TARGET_URL, | 631 | + url: REPLY_TARGET_URL, |
| 596 | headers: { | 632 | headers: { |
| 597 | 'Authorization': `Bearer ${TOKEN}` | 633 | 'Authorization': `Bearer ${TOKEN}` |
| 598 | }, | 634 | }, |
| 599 | json: { | 635 | json: { |
| 600 | - "to": `${USER_ID}`, | 636 | + "replyToken": eventObj.replyToken, |
| 601 | "messages": [ | 637 | "messages": [ |
| 602 | { | 638 | { |
| 603 | "type": "text", | 639 | "type": "text", | ... | ... |
-
Please register or login to post a comment