miao-plugin/components/Common.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-08-18 10:13:42 +00:00
import Cfg from './Cfg.js'
import { Version } from './index.js'
2022-07-23 20:32:10 +00:00
import { segment } from 'oicq'
export const render = async function (path, params, cfg) {
2022-07-23 20:32:10 +00:00
let paths = path.split('/')
let { render, e } = cfg
let layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/'
let base64 = await render(paths[0], paths[1], {
...params,
2022-07-23 20:32:10 +00:00
_layout_path: layoutPath,
_tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/',
2022-07-23 20:32:10 +00:00
defaultLayout: layoutPath + 'default.html',
elemLayout: layoutPath + 'elem.html',
sys: {
scale: Cfg.scale(cfg.scale || 1),
2022-08-18 10:13:42 +00:00
copyright: `Created By Yunzai-Bot<span class="version">${Version.yunzai}</span> & Miao-Plugin<span class="version">${Version.version}</span>`
}
2022-07-23 20:32:10 +00:00
})
let ret = true
if (base64) {
2022-08-18 10:13:42 +00:00
ret = Version.isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
}
return cfg.retMsgId ? ret : true
}
2022-07-23 20:32:10 +00:00
export const todoV3 = function (e) {
2022-08-18 10:13:42 +00:00
if (Version.isV3) {
2022-07-23 20:32:10 +00:00
e.reply('本功能暂时不支持V3版Yunzai...')
return true
}
return false
}
function sleep (ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
export default {
render,
cfg: Cfg.get,
2022-07-23 20:32:10 +00:00
isDisable: Cfg.isDisable,
todoV3,
sleep
2022-07-23 20:32:10 +00:00
}