Showing
1 changed file
with
10 additions
and
3 deletions
... | @@ -28,13 +28,20 @@ function onMessage(message, replyToken) { | ... | @@ -28,13 +28,20 @@ function onMessage(message, replyToken) { |
28 | if(message.type != 'text') | 28 | if(message.type != 'text') |
29 | return; | 29 | return; |
30 | 30 | ||
31 | - let sql = 'SELECT i.`name` FROM `character_items` c JOIN `items` i ON c.`item`=i.`id` WHERE c.`character_id`=? ORDER BY c.`count` DESC LIMIT 0,5'; | 31 | + if(message.text.indexOf('아이템') >= 0) |
32 | - pool.query(sql, [message.text]).then(function([results]) { | 32 | + recommendItem(message.text.split(' ')[0], replyToken); |
33 | + | ||
34 | + | ||
35 | +} | ||
36 | + | ||
37 | +function recommendItem(charAlias, replyToken) { | ||
38 | + let sql = 'SELECT n.`alias`, i.`name` FROM `character_aliases` a JOIN `character_items` c ON a.`character_id`=c.`character_id` JOIN `character_aliases` n ON c.`character_id`=n.`character_id` JOIN `items` i ON c.`item`=i.`id` WHERE a.`alias`=? AND n.`is_name`=1 ORDER BY c.`count` DESC LIMIT 0,5'; | ||
39 | + pool.query(sql, [charAlias]).then(function([results]) { | ||
33 | let reply; | 40 | let reply; |
34 | if(results.length == 0) | 41 | if(results.length == 0) |
35 | reply = '데이터가 없습니다.'; | 42 | reply = '데이터가 없습니다.'; |
36 | else | 43 | else |
37 | - reply = `${message.text}의 추천 아이템은 ${results.map(e => e.name).join(', ')} 입니다.`; | 44 | + reply = `${results[0].alias}의 추천 아이템은 ${results.map(e => e.name).join(', ')} 입니다.`; |
38 | 45 | ||
39 | axios.post('https://api.line.me/v2/bot/message/reply', { | 46 | axios.post('https://api.line.me/v2/bot/message/reply', { |
40 | replyToken: replyToken, | 47 | replyToken: replyToken, | ... | ... |
-
Please register or login to post a comment