2022-07-23 20:32:10 +00:00
|
|
|
import { Cfg } from './index.js'
|
|
|
|
import { segment } from 'oicq'
|
|
|
|
import { currentVersion, yunzaiVersion, isV3 } from './Changelog.js'
|
2022-05-22 13:10:10 +00:00
|
|
|
|
|
|
|
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/'
|
2022-05-22 13:10:10 +00:00
|
|
|
let base64 = await render(paths[0], paths[1], {
|
|
|
|
...params,
|
2022-07-23 20:32:10 +00:00
|
|
|
_layout_path: layoutPath,
|
2022-08-02 19:12:07 +00:00
|
|
|
_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',
|
2022-05-22 13:10:10 +00:00
|
|
|
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
|
|
|
})
|
2022-05-22 13:10:10 +00:00
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let ret = true
|
2022-05-22 13:10:10 +00:00
|
|
|
if (base64) {
|
2022-07-30 21:06:00 +00:00
|
|
|
ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
|
2022-05-22 13:10:10 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
return cfg.retMsgId ? ret : true
|
2022-05-22 13:10:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
export const todoV3 = function (e) {
|
|
|
|
if (isV3) {
|
|
|
|
e.reply('本功能暂时不支持V3版Yunzai...')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2022-05-22 13:10:10 +00:00
|
|
|
|
2022-08-01 21:15:37 +00:00
|
|
|
function sleep (ms) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
|
|
}
|
|
|
|
|
2022-05-22 13:10:10 +00:00
|
|
|
export default {
|
|
|
|
render,
|
|
|
|
cfg: Cfg.get,
|
2022-07-23 20:32:10 +00:00
|
|
|
isDisable: Cfg.isDisable,
|
2022-08-01 21:15:37 +00:00
|
|
|
todoV3,
|
|
|
|
sleep
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|