Skip to content

Instantly share code, notes, and snippets.

@jirawatee
Created May 27, 2019 20:15
Show Gist options
  • Save jirawatee/7a7a1c0d87115d85f907d0cb17e5f745 to your computer and use it in GitHub Desktop.
Save jirawatee/7a7a1c0d87115d85f907d0cb17e5f745 to your computer and use it in GitHub Desktop.
Broadcast final score in UCL by Cloud Firestore
exports.finalScore = functions.region(region).pubsub
.schedule('02 of jun 04:00')
.timeZone('Asia/Bangkok')
.onRun(async context => {
// ดึงผลการแข่งขันล่าสุดจาก Firestore
let result = await admin.firestore().doc('ucl/final').get()
broadcast(`จบการแข่งขัน\n${result.data().score}`); // ส่งข้อความให่ทุกคนที่เป็น friend
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment