2023-03-04 14:30:13 +08:00
|
|
|
import plugin from '../../../lib/plugins/plugin.js'
|
|
|
|
import fs from 'node:fs'
|
|
|
|
import gsCfg from '../model/gsCfg.js'
|
|
|
|
import RoleIndex from '../model/roleIndex.js'
|
|
|
|
import Abyss from '../model/abyss.js'
|
|
|
|
import Weapon from '../model/weapon.js'
|
2023-11-07 03:56:44 +08:00
|
|
|
|
2023-03-04 14:30:13 +08:00
|
|
|
export class role extends plugin {
|
|
|
|
constructor () {
|
|
|
|
super({
|
|
|
|
name: '角色查询',
|
|
|
|
dsc: '原神角色信息查询',
|
|
|
|
event: 'message',
|
|
|
|
priority: 200,
|
2023-11-07 03:56:44 +08:00
|
|
|
rule: [{
|
|
|
|
reg: '^(#*角色3|#*角色卡片|角色)$',
|
|
|
|
fnc: 'roleCard'
|
|
|
|
}, {
|
|
|
|
reg: '^#[上期|往期|本期]*(深渊|深境|深境螺旋)[上期|往期|本期]*[ |0-9]*$',
|
|
|
|
fnc: 'abyss'
|
|
|
|
}, {
|
|
|
|
reg: '^#*[上期|往期|本期]*(深渊|深境|深境螺旋)[上期|往期|本期]*[第]*(9|10|11|12|九|十|十一|十二)层[ |0-9]*$',
|
|
|
|
fnc: 'abyssFloor'
|
|
|
|
}, {
|
|
|
|
reg: '^#[五星|四星|5星|4星]*武器[ |0-9]*$',
|
|
|
|
fnc: 'weapon'
|
|
|
|
}, {
|
|
|
|
reg: '^#(宝箱|成就|尘歌壶|家园|探索|探险|声望|探险度|探索度)[ |0-9]*$',
|
|
|
|
fnc: 'roleExplore'
|
|
|
|
}]
|
2023-03-04 14:30:13 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 初始化配置文件 */
|
|
|
|
async init () {
|
|
|
|
|
|
|
|
let pubCk = './plugins/genshin/config/mys.pubCk.yaml'
|
|
|
|
if (!fs.existsSync(pubCk)) {
|
|
|
|
fs.copyFileSync('./plugins/genshin/defSet/mys/pubCk.yaml', pubCk)
|
|
|
|
}
|
|
|
|
|
|
|
|
let set = './plugins/genshin/config/mys.set.yaml'
|
|
|
|
if (!fs.existsSync(set)) {
|
|
|
|
fs.copyFileSync('./plugins/genshin/defSet/mys/set.yaml', set)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 接受到消息都会先执行一次 */
|
|
|
|
accept () {
|
|
|
|
if (!this.e.msg) return
|
|
|
|
if (!/^#(.*)$/.test(this.e.msg)) return
|
|
|
|
|
|
|
|
let role = gsCfg.getRole(this.e.msg)
|
|
|
|
if (role) {
|
|
|
|
/** 设置命令 */
|
|
|
|
this.e.msg = '#角色详情'
|
|
|
|
if (role.uid) this.e.msg += role.uid
|
|
|
|
/** 角色id */
|
|
|
|
this.e.roleId = role.roleId
|
|
|
|
/** 角色名称 */
|
|
|
|
this.e.roleName = role.alias
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 深渊 */
|
|
|
|
async abyss () {
|
|
|
|
let data = await new Abyss(this.e).getAbyss()
|
2023-11-07 03:56:44 +08:00
|
|
|
console.log('abyss', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
if (!data) return
|
|
|
|
|
2023-11-07 03:56:44 +08:00
|
|
|
this.renderImg('genshin', 'html/abyss/abyss', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 深渊十二层 */
|
|
|
|
async abyssFloor () {
|
|
|
|
let data = await new Abyss(this.e).getAbyssFloor()
|
|
|
|
if (!data) return
|
|
|
|
|
2023-11-08 03:03:36 +08:00
|
|
|
await this.renderImg('genshin', 'html/abyss/abyss-floor', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 武器 */
|
|
|
|
async weapon () {
|
|
|
|
let data = await Weapon.get(this.e)
|
|
|
|
if (!data) return
|
|
|
|
|
2023-11-08 03:03:36 +08:00
|
|
|
await this.renderImg('genshin', 'html/avatar/weapon', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 角色卡片 */
|
|
|
|
async roleCard () {
|
|
|
|
let data = await new RoleIndex(this.e).roleCard()
|
|
|
|
if (!data) return
|
|
|
|
|
2023-11-08 03:03:36 +08:00
|
|
|
await this.renderImg('genshin', 'html/player/role-card', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 探险 */
|
|
|
|
async roleExplore () {
|
|
|
|
let data = await new RoleIndex(this.e).roleExplore()
|
|
|
|
if (!data) return
|
|
|
|
|
2023-11-08 03:03:36 +08:00
|
|
|
this.renderImg('genshin', 'html/player/role-explore', data)
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|