This file contains hidden or 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 region = "asia-northeast1" | |
const axios = require('axios'); | |
const FormData = require('form-data'); | |
const speech = require('@google-cloud/speech'); | |
// สำหรับจัดการไฟล์ | |
const path = require("path"); | |
const os = require("os"); | |
const fs = require("fs"); |
This file contains hidden or 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
exports.go = (result) => ({ | |
"type": "text", | |
"text": "OK, Let's GO!" | |
}) | |
exports.ready = () => ({ | |
"type": "flex", | |
"altText": "Are you ready to run?", | |
"contents": { | |
"type": "bubble", |
This file contains hidden or 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 admin = require("firebase-admin"); | |
admin.initializeApp(); | |
const axios = require("axios"); | |
const LINE_MESSAGING_API = "https://api.line.me/v2/bot"; | |
const LINE_HEADER = { | |
"Content-Type": "application/json", | |
Authorization: `Bearer YOUR-ACCESS-TOKEN` | |
}; |
This file contains hidden or 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 uploadAndProcessImg = async (event, city) => { | |
// ดึงรูปของผู้ใช้ที่ส่งมาจาก LINE | |
const url = `${LINE_CONTENT_API}/${event.message.id}/content`; | |
const originalImage = await axios({ | |
method: "get", | |
headers: LINE_HEADER, | |
url: url, | |
responseType: "arraybuffer" | |
}); |
This file contains hidden or 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') | |
// สำหรับการเข้าถึง Cloud Storage | |
const admin = require("firebase-admin"); | |
admin.initializeApp(); | |
// สำหรับ network requests | |
const axios = require('axios'); | |
// สำหรับสร้าง public url ใน Cloud Storage |
This file contains hidden or 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 express = require("express"); | |
const bodyParser = require("body-parser"); | |
const crypto = require('crypto'); | |
const request = require("request-promise"); | |
const LINE_MESSAGING_API = 'https://api.line.me/v2/bot/message'; | |
const LINE_CHANNEL_SECRET = 'XXXXXXXXXXXXX'; | |
const LINE_HEADER = { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer XXXXXXXXXXXXXXXXXXX` | |
}; |
This file contains hidden or 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
{ | |
"destination": "xxxxxxxxxx", | |
"events": [ | |
{ | |
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA", | |
"type": "message", | |
"mode": "active", | |
"timestamp": 1462629479859, | |
"source": { | |
"type": "user", |
This file contains hidden or 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 spotify = require("./spotify"); | |
const request = require("request-promise"); | |
const LINE_HEADER = { | |
"Content-Type": "application/json", | |
Authorization: "Bearer " + process.env.LINE_ACCESS_TOKEN | |
} | |
const Commands = { | |
ADD_TRACK: "ADD_TRACK", | |
SEARCH_MORE: "SEARCH_MORE" |
This file contains hidden or 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 SpotifyWebApi = require("spotify-web-api-node"); | |
class Spotify { | |
constructor() { | |
// Init การเชื่อมต่อกับ Spotify | |
this.api = new SpotifyWebApi({ | |
clientId: process.env.SPOTIFY_CLIENT_ID, | |
clientSecret: process.env.SPOTIFY_CLIENT_SECRET, | |
redirectUri: process.env.SPOTIFY_CALLBACK |
This file contains hidden or 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 dotenv = require("dotenv"); | |
dotenv.config(); | |
const express = require("express"); | |
const lineApp = require("./lineapp"); | |
const spotify = require("./spotify"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
app.use(bodyParser.json()); |
NewerOlder