Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Last active November 21, 2019 08:46
Show Gist options
  • Save jirawatee/ccfe2a9a40c8f12184e487379f3e6bd2 to your computer and use it in GitHub Desktop.
Save jirawatee/ccfe2a9a40c8f12184e487379f3e6bd2 to your computer and use it in GitHub Desktop.
UCL - Postback
...
case 'postback': {
// [8.4]
let msg = 'ทีมที่คุณเลือกมันเข้ารอบมาชิง UCL ซะทีไหนเล่า ปั๊ดโถ่!';
let team = event.postback.data.split('=')[1].toLowerCase()
if (team.indexOf('liverpool') >= 0 || team.indexOf('tottenham') >= 0) {
// Firebase Realtime Database
await admin.database().ref('ucl/uid').child(event.source.userId).set(true)
// Cloud Firestore
// await admin.firestore().doc('ucl/final').collection('uid').doc(event.source.userId).set({})
msg = 'ยินดีด้วยคุณผ่านการยืนยันตัวตน ระบบจะรายงานผลบอลคู่ชิงให้คุณทุกลมหายใจ';
}
reply(event.replyToken, { type: 'text', text: msg });
break;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment