Showing
1 changed file
with
14 additions
and
4 deletions
... | @@ -47,6 +47,20 @@ const client = new line.Client(config); | ... | @@ -47,6 +47,20 @@ const client = new line.Client(config); |
47 | 47 | ||
48 | var songList=[]; // list to store music(singer, song, lyric url) | 48 | var songList=[]; // list to store music(singer, song, lyric url) |
49 | 49 | ||
50 | +var data = require('./event.json'); | ||
51 | +//json 불러오기 | ||
52 | +var data_list = data["DATA"] | ||
53 | +var concert_list = []; | ||
54 | +for(var i = 0; i < data_list.length; i++){ | ||
55 | + if (data_list[i].codename=="콘서트"){ | ||
56 | + concert_list.push(data_list[i].title); | ||
57 | + } | ||
58 | + } | ||
59 | +for(var i = 0; i < concert_list.length; i++){ | ||
60 | + console.log(i+1,'. ',concert_list[i],'\n'); | ||
61 | + } | ||
62 | +//콘서트 목록 만들기 | ||
63 | + | ||
50 | 64 | ||
51 | app.post('/webhook', line.middleware(config), (req, res) => { | 65 | app.post('/webhook', line.middleware(config), (req, res) => { |
52 | Promise | 66 | Promise |
... | @@ -247,7 +261,6 @@ function handleEvent(event) { | ... | @@ -247,7 +261,6 @@ function handleEvent(event) { |
247 | }); | 261 | }); |
248 | } | 262 | } |
249 | else if(event.message.text.substring(0,6)=='콘서트 보기'||event.message.text.substring(0,5)=='콘서트보기'){ | 263 | else if(event.message.text.substring(0,6)=='콘서트 보기'||event.message.text.substring(0,5)=='콘서트보기'){ |
250 | - | ||
251 | return new Promise(function(resolve, reject) | 264 | return new Promise(function(resolve, reject) |
252 | { | 265 | { |
253 | var showlist = { type: 'text', text:''}; | 266 | var showlist = { type: 'text', text:''}; |
... | @@ -260,7 +273,6 @@ function handleEvent(event) { | ... | @@ -260,7 +273,6 @@ function handleEvent(event) { |
260 | client.replyMessage(event.replyToken, showlist).then(resolve).catch(reject); | 273 | client.replyMessage(event.replyToken, showlist).then(resolve).catch(reject); |
261 | }); | 274 | }); |
262 | } | 275 | } |
263 | - | ||
264 | else if(0 < event.message.text.substr(0,2)*1 && event.message.text.substr(0,2)*1 < 27){ | 276 | else if(0 < event.message.text.substr(0,2)*1 && event.message.text.substr(0,2)*1 < 27){ |
265 | 277 | ||
266 | var selectnum = (event.message.text.substr(0,2)*1); | 278 | var selectnum = (event.message.text.substr(0,2)*1); |
... | @@ -270,7 +282,6 @@ function handleEvent(event) { | ... | @@ -270,7 +282,6 @@ function handleEvent(event) { |
270 | result.text = '목록에 존재하지 않는 콘서트입니다.'; | 282 | result.text = '목록에 존재하지 않는 콘서트입니다.'; |
271 | return ; | 283 | return ; |
272 | } | 284 | } |
273 | - | ||
274 | return new Promise(function(resolve, reject){ | 285 | return new Promise(function(resolve, reject){ |
275 | var concert_name = concert_list[selectnum-1]; | 286 | var concert_name = concert_list[selectnum-1]; |
276 | var $ = cheerio.load(concert_name); | 287 | var $ = cheerio.load(concert_name); |
... | @@ -287,7 +298,6 @@ function handleEvent(event) { | ... | @@ -287,7 +298,6 @@ function handleEvent(event) { |
287 | type: 'video'} | 298 | type: 'video'} |
288 | }; | 299 | }; |
289 | 300 | ||
290 | - | ||
291 | request(options, function(error,result,body){ | 301 | request(options, function(error,result,body){ |
292 | if(error) throw new Error(error); | 302 | if(error) throw new Error(error); |
293 | var videourl = { type: 'text', text:''}; | 303 | var videourl = { type: 'text', text:''}; | ... | ... |
-
Please register or login to post a comment