Miao-Yunzai/plugins/genshin/apps/calculator.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-03-04 14:30:13 +08:00
import plugin from '../../../lib/plugins/plugin.js'
import Calculator from '../model/calculator.js'
import Blueprint from '../model/blueprint.js'
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
import gsCfg from '../model/gsCfg.js'
export class calculator extends plugin {
constructor() {
2023-03-04 14:30:13 +08:00
super({
name: '养成计算',
dsc: '角色养成材料计算器',
event: 'message',
priority: 700,
rule: [
{
reg: '^#*(星铁)?(.*)(养成|计算)([0-9]|,|| )*$',
2023-03-04 14:30:13 +08:00
fnc: 'Calculator'
},
{
reg: '^#*(星铁)?角色(养成|计算|养成计算)$',
2023-03-04 14:30:13 +08:00
fnc: 'calculatorHelp'
},
{
reg: '^#*尘歌壶模数(养成|计算|养成计算)$',
fnc: 'blueprintHelp'
},
{
reg: '^#*尘歌壶(模数|养成|养成计算)(\\d{10,15})$',
fnc: 'Blueprint'
},
2023-03-04 14:30:13 +08:00
]
})
this._path = process.cwd().replace(/\\/g, '/')
2023-03-04 14:30:13 +08:00
}
async blueprintHelp(e) {
2023-03-04 14:30:13 +08:00
let msg = '#尘歌壶模数\n指令#尘歌壶模数\n示例#尘歌壶模数123456\n参数为模数id(10-15位数字)'
await e.reply(msg)
return true
}
async calculatorHelp(e) {
let msg = `角色养成计算\n指令:${e.isSr ? '*克拉拉养成\n示例*克拉拉养成75 80 6 9 9 9\n参数为角色、武器、普攻、战技、终结技、天赋' : '#刻晴养成\n示例#刻晴养成81 90 9 9 9\n参数为角色、武器、技能等级'}`
2023-03-04 14:30:13 +08:00
await e.reply(msg)
return true
}
async Blueprint() {
let role = this.e.msg.replace(/#/, '').match(/\d+/g);
let data = await new Blueprint(this.e).get(role)
if (!data) return
/** 生成图片 */
let img = await puppeteer.screenshot('Blueprint', data)
if (img) await this.reply(img)
2023-03-04 14:30:13 +08:00
}
/** #刻晴养成 */
async Calculator() {
let role = gsCfg.getRole(this.e.msg, '#||星铁|养成|计算|[0-9]|,|| ', this.e.isSr)
2023-03-04 14:30:13 +08:00
if (!role) return false
if ([10000005, 10000007, 20000000].includes(Number(role.roleId))) {
await this.e.reply('暂不支持旅行者养成计算')
return true
}
let data = await new Calculator(this.e).get(role)
if (!data) return
/** 生成图片 */
2023-08-19 19:48:02 +08:00
let img = await puppeteer.screenshot(`${data.srtempFile}calculator`, data)
2023-03-04 14:30:13 +08:00
if (img) await this.reply(img)
}
}