add key word command not fin
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const api = require('../../../api-action')
|
||||
const DB = require('../../../database')
|
||||
const axios = require('axios')
|
||||
|
||||
async function run (fn = null, txt, source) {
|
||||
if (!fn || typeof fn !== 'function') return null
|
||||
@@ -447,6 +448,29 @@ const addYoutube = async (txt = '', source = {}, db) => {
|
||||
}
|
||||
}
|
||||
|
||||
const image = async (txt, source, db) => {
|
||||
if (typeof txt !== 'string' || txt.trim().length === 0) return null
|
||||
let imgs = txt.split(';')
|
||||
if (imgs.length !== 2) return null
|
||||
|
||||
try {
|
||||
await axios({
|
||||
url: imgs[0],
|
||||
method: 'head'
|
||||
})
|
||||
await axios({
|
||||
url: imgs[1],
|
||||
method: 'head'
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return null
|
||||
}
|
||||
return {
|
||||
reply: `$image$${txt}`
|
||||
}
|
||||
}
|
||||
|
||||
const hello = async () => {
|
||||
return {reply: 'Hello World'}
|
||||
}
|
||||
@@ -458,5 +482,6 @@ module.exports = {
|
||||
addtwitch: run.bind(null, addTwitch),
|
||||
deltwitch: run.bind(null, delTwitch),
|
||||
addyoutube: run.bind(null, addYoutube),
|
||||
hello: run.bind(null, hello)
|
||||
hello: run.bind(null, hello),
|
||||
image: run.bind(null, image)
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ for (let i of actGrpFile) {
|
||||
}
|
||||
|
||||
const runAct = async (cmd, txt = '', source = {}) => {
|
||||
if (!cmd || typeof cmd !== 'string' || cmd.length === 0) return null
|
||||
if (!(cmd in cmds)) return null
|
||||
let result = await cmds[cmd](txt, source)
|
||||
if (!cmd || (typeof cmd !== 'string' && !Array.isArray(cmd)) || cmd.length === 0) return null
|
||||
let c = typeof cmd === 'string' ? cmd : cmd[0]
|
||||
if (!(c in cmds)) return null
|
||||
let result = await cmds[c](typeof cmd === 'string' ? txt : cmd[1] || '', source)
|
||||
return result.reply
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user