권은령

update app.js

...@@ -246,6 +246,60 @@ function handleEvent(event) { ...@@ -246,6 +246,60 @@ function handleEvent(event) {
246 }); 246 });
247 }); 247 });
248 } 248 }
249 + else if(event.message.text.substring(0,6)=='콘서트 보기'||event.message.text.substring(0,5)=='콘서트보기'){
250 +
251 + return new Promise(function(resolve, reject)
252 + {
253 + var showlist = { type: 'text', text:''};
254 + for(var i = 0; i < concert_list.length; i++)
255 + {
256 + showlist.text+=i+1 + ". " + concert_list[i] + "\n";
257 + }
258 + console.log(showlist.text);
259 +
260 + client.replyMessage(event.replyToken, showlist).then(resolve).catch(reject);
261 + });
262 + }
263 +
264 + else if(0 < event.message.text.substr(0,2)*1 && event.message.text.substr(0,2)*1 < 27){
265 +
266 + var selectnum = (event.message.text.substr(0,2)*1);
267 + var result = { type: 'text', text:''};
268 + console.log(selectnum);
269 + if(selectnum <=0 || selectnum >=27){
270 + result.text = '목록에 존재하지 않는 콘서트입니다.';
271 + return ;
272 + }
273 +
274 + return new Promise(function(resolve, reject){
275 + var concert_name = concert_list[selectnum-1];
276 + var $ = cheerio.load(concert_name);
277 + var keyword = $.text();
278 + console.log(keyword);
279 +
280 + var options = {method: 'GET',
281 + url: 'https://www.googleapis.com/youtube/v3/search',
282 + qs: { key: 'AIzaSyB4b-n8SSv73CLDKvFigpLPYA6yWG2JQ9A',
283 + part: 'id',
284 + maxResults: '1',
285 + order: 'relevance',
286 + q: keyword,
287 + type: 'video'}
288 + };
289 +
290 +
291 + request(options, function(error,result,body){
292 + if(error) throw new Error(error);
293 + var videourl = { type: 'text', text:''};
294 +
295 + var temp1 = body.split(':');
296 + videourl.text += "https://www.youtube.com/watch?v=" + temp1[13].substr(2,11);
297 +
298 + console.log(videourl.text);
299 + client.replyMessage(event.replyToken, videourl).then(resolve).catch(reject);
300 + });
301 + });
302 + }
249 else{ 303 else{
250 return new Promise(function(resolve, reject) { 304 return new Promise(function(resolve, reject) {
251 //언어 감지 option 305 //언어 감지 option
......
This diff could not be displayed because it is too large.