2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00
xiaoyao-cvs-plugin/adapter/index.js

44 lines
984 B
JavaScript
Raw Normal View History

2022-07-24 11:46:05 +08:00
import plugin from '../../../lib/plugins/plugin.js'
import * as Atlas from '../apps/index.js'
import { render } from './render.js'
import { checkAuth, getMysApi } from './mys.js'
export class atlas extends plugin {
constructor () {
super({
name: 'xiaoyao-cvs-plugin',
desc: '图鉴插件',
event: 'message',
priority: 50,
rule: [{
reg: '.+',
fnc: 'dispatch'
}]
})
}
async dispatch (e) {
let msg = e.raw_message
e.checkAuth = async function (cfg) {
return await checkAuth(e, cfg)
}
e.getMysApi = async function (cfg) {
return await getMysApi(e, cfg)
}
2022-08-01 14:02:47 +08:00
msg = '#' + msg.replace(/#|/, '').trim()
2022-07-24 11:46:05 +08:00
for (let fn in Atlas.rule) {
let cfg = Atlas.rule[fn]
if (Atlas[fn] && new RegExp(cfg.reg).test(msg)) {
let ret = await Atlas[fn](e, {
render
})
if (ret === true) {
return true
}
}
}
return false
}
}