miao-plugin/components/Common.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-07-23 20:32:10 +00:00
import { Cfg } from './index.js'
import { segment } from 'oicq'
import { currentVersion, yunzaiVersion, isV3 } from './Changelog.js'
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,
defaultLayout: layoutPath + 'default.html',
elemLayout: layoutPath + 'elem.html',
sys: {
scale: Cfg.scale(cfg.scale || 1),
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & Miao-Plugin<span class="version">${currentVersion}</span>`
}
2022-07-23 20:32:10 +00:00
})
if (base64) {
2022-07-23 20:32:10 +00:00
return isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
}
2022-07-23 20:32:10 +00:00
return true
}
2022-07-23 20:32:10 +00:00
export const todoV3 = function (e) {
if (isV3) {
e.reply('本功能暂时不支持V3版Yunzai...')
return true
}
return false
}
export default {
render,
cfg: Cfg.get,
2022-07-23 20:32:10 +00:00
isDisable: Cfg.isDisable,
todoV3
}