add module-alias , add image message

This commit is contained in:
Jay
2018-07-13 13:30:54 +08:00
parent 4c56ff4300
commit e1ad83566b
16 changed files with 51 additions and 20 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
const axios = require('axios')
const config = require('../../config')
const config = require('@config/index')
const qs = require('querystring')
const queryYoutubeName = async (id = '') => {
+12 -1
View File
@@ -1,5 +1,5 @@
const axios = require('axios')
const config = require('../../config')
const config = require('@config/index')
const client = axios.create({
baseURL: 'https://api.line.me/v2/bot',
@@ -44,6 +44,16 @@ const textObject = (txt = '') => {
}
}
const imageObject = (txt = '') => {
if (typeof txt !== 'string' || txt.trim().length === 0) return null
txt = txt.split(';')
return {
type: 'image',
originalContentUrl: txt[0],
previewImageUrl: txt[1]
}
}
/**
* send reply message
* @param {string} replyToken line message reply token
@@ -59,6 +69,7 @@ const replyMessage = async (replyToken, message) => {
if (m !== null && m.length > 1) {
switch (m[1]) {
case 'image':
obj = imageObject(message)
break
case 'text':
obj = textObject(message)
+1 -1
View File
@@ -1,5 +1,5 @@
const axios = require('axios')
const config = require('../../config')
const config = require('@config/index')
const client = axios.create({
baseURL: 'https://api.twitch.tv/helix',
headers: {