mtfosbot/route/google/index.js
2018-07-03 22:14:14 +08:00

33 lines
718 B
JavaScript

const Router = require('koa-router')
const xml2js = require('xml2js')
const r = new Router()
// const koaBody = require('koa-body')
const {
getRaw
} = require('../../libs/middleware')
const {
textMessage
} = require('../../libs/line-message')
r.get('/youtube/webhook', async (c, n) => {
let mode = c.query['hub.mode'] || ''
let verifyToken = c.query['hub.verify_token'] || ''
let challenge = c.query['hub.challenge']
if (mode) {
if (mode === 'subscribe') {
c.status = 200
c.body = challenge
} else {
c.status = 403
c.body = ''
}
}
})
r.post('/youtube/webhook', getRaw, async (c, n) => {
console.log(JSON.stringify(c.request.body, null, 2))
})
module.exports = r