Skip to content

Instantly share code, notes, and snippets.

View GGSheets2RTDB_Functions.js
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']}
`
View GGSheets2RTDB_Appsscript.gs
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'
View LINE_Flex_Fixed_CuttingText.json
{
"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",
View docker-compose.yaml
version: '3'
volumes:
postgres_data:
driver: local
services:
postgres:
image: postgres
volumes:
View trello_line_webhook_tasklist.ts
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)
View trello_msg_tasklist.ts
// ส่วนข้อความขึ้นต้น Task List
const changeHead = (boardName: string, changeDate: string) => ([
{
"type": "text",
"text": `ข้อมูล Change ของ ${boardName} ณ.วันที่ ${changeDate}`,
"size": "xs",
"color": "#8C8C8C",
},
])
View trello_line_webhook_boardlist.ts
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)
let replyMessage: any = null
View trello_msg_boardList.ts
// ส่วน Carousel
const boardMain = (boardItems: any) => ([{
"type": "flex",
"altText": "My Board",
"contents": {
"type": "carousel",
"contents": boardItems,
},
}])
View trello_webhook_request.ts
{
"model": {
"name": "Test",
"id": "5e9460..........cbab52c1",
},
"action": {
"appCreator": null,
"data": {
"card": {
"name": "card2",
View trello_webhook.ts
export const webhookTrello = functions.region(REGION).https.onRequest( async(req, res) => {
const action = req.body.action
if(action && action.display.translationKey !== 'unknown') {
const data = {
action: action,
changeTime: Date.now() + 25200000,
}
const board = action.data.board
board.changeTime = Date.now() + 25200000
await firestore.collection('board').doc(action.data.board.id).set(board)