This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reply = async(replyToken, messages) => { | |
const axios = require("axios") | |
const data = { replyToken, messages } | |
const headers = { | |
'Authorization': `Bearer ${channelAccessToken}`, | |
'Content-Type': 'application/json' | |
} | |
axios.post('https://api.line.me/v2/bot/message/reply', data, { | |
headers: headers | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const collectPoint = async(event) => { | |
try { | |
const userId = event.source.userId | |
const trackingId = event.videoPlayComplete.trackingId | |
const timestamp = event.timestamp | |
const params = { | |
userId, trackingId, timestamp | |
} | |
await admin.firestore().collection('collectPoint').add(params) | |
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkPointExists = async(event) => { | |
try { | |
const userId = event.source.userId | |
const trackingId = event.videoPlayComplete.trackingId | |
const data = await admin.firestore() | |
.collection('collectPoint') | |
.where('userId', '==', userId) | |
.where('trackingId', '==', trackingId) | |
.get() | |
return !data.empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handle events | |
events.forEach(async(event) => { | |
if (event.type === 'videoPlayComplete') { | |
await savePointVideoComlete(event) | |
} | |
console.log(event) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions") | |
const axios = require("axios") | |
const notiToken = 'REPLACE LINE NOTIFY TOKEN HERE' | |
exports.monitorData = functions.region("asia-southeast1").database.ref('Product/{id}').onWrite(async (snap, context) => { | |
message = `\มีข้อมูลเปลี่ยนแปลง | |
name จาก ${snap.before._data['1']} -> ${snap.after._data['1']} | |
stock จาก ${snap.before._data['2']} -> ${snap.after._data['2']} | |
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function syncData() { | |
var sheet = SpreadsheetApp.getActiveSheet() | |
var [rows, columns] = [sheet.getLastRow(), sheet.getLastColumn()] | |
var data = sheet.getRange(2, 1, rows-1, columns).getValues() | |
var dataPath = 'Product' | |
var projectId = 'ggsheets2rtdb' | |
var region = 'asia-southeast1' | |
var fireBaseUrl = 'https://' +projectId+ '-default-rtdb.' +region+ '.firebasedatabase.app/' +dataPath +'.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "bubble", | |
"hero": { | |
"type": "image", | |
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png", | |
"size": "full", | |
"aspectRatio": "20:13", | |
"aspectMode": "cover", | |
"action": { | |
"type": "uri", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
volumes: | |
postgres_data: | |
driver: local | |
services: | |
postgres: | |
image: postgres | |
volumes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "bubble", | |
"body": { | |
"type": "box", | |
"layout": "vertical", | |
"contents": [ | |
{ | |
"type": "box", | |
"layout": "vertical", | |
"contents": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const webhookLINE = functions.region(REGION).https.onRequest( async(req, res) => { | |
console.log('🚀 Start Webhook!!', JSON.stringify(req.body) ) | |
if(!req.body.events) { res.status(200).end()} | |
const event = req.body.events[0] | |
if(typeof(event) === 'undefined') { res.status(200).end()} | |
try { | |
await util_line.verify_signature(req, res) |