유재형
Committed by Ma Suhyeon

implement probabilities message

Showing 1 changed file with 24 additions and 0 deletions
......@@ -56,6 +56,11 @@ function onMessage(message, replyToken) {
return;
}
if(message.text.indexOf('확률') >= 0) {
sendProbabilities(replyToken);
return;
}
replyMessage(replyToken, [{type: 'text', text: '수행할 수 없는 명령입니다.'}]);
}
......@@ -193,6 +198,25 @@ async function recommendMeta(replyToken) {
replyMessage(replyToken, messages);
}
function sendProbabilities(replyToken) {
let probs = [
[100, 0, 0, 0, 0],
[100, 0, 0, 0, 0],
[75, 25, 0, 0, 0],
[55, 30, 15, 0, 0],
[45, 33, 20, 2, 0],
[35, 35, 25, 5, 0],
[22, 35, 30, 12, 1],
[15, 25, 35, 20, 5],
[10, 15, 30, 30, 15]
];
replyMessage(replyToken, [{
type: 'text',
text: probs.map((arr, idx) => `Lv.${idx + 1}: ${arr.map(e => `${e}%`).join(' ')}`).join('\n')
}])
}
function replyMessage(replyToken, messages) {
axios.post('https://api.line.me/v2/bot/message/reply', {
replyToken: replyToken,
......