2024-06-14 10:44:18 +08:00
|
|
|
import { plugin } from 'yunzai/core'
|
|
|
|
import User from '../model/user.js'
|
|
|
|
import { MysInfo } from 'yunzai/mys'
|
|
|
|
export class userAdmin extends plugin {
|
2024-06-15 12:27:43 +08:00
|
|
|
User = null
|
|
|
|
button = null
|
2024-06-14 10:44:18 +08:00
|
|
|
constructor(e) {
|
|
|
|
/**
|
|
|
|
name: '用户管理',
|
|
|
|
dsc: 'CK用户管理',
|
|
|
|
*/
|
|
|
|
super({
|
|
|
|
event: 'message',
|
|
|
|
priority: 300,
|
2024-06-17 23:04:18 +08:00
|
|
|
rule: [
|
|
|
|
{
|
|
|
|
reg: '^#用户统计$',
|
|
|
|
fnc: 'userAdmin',
|
|
|
|
permission: 'master'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
reg: '^#(刷新|重置)用户(缓存|统计|ck|Ck|CK)$',
|
|
|
|
fnc: 'resetCache',
|
|
|
|
permission: 'master'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
reg: '^#删除(无效|失效)(用户|ck|Ck|CK)$',
|
|
|
|
fnc: 'delDisable',
|
|
|
|
permission: 'master'
|
|
|
|
}
|
|
|
|
]
|
2024-06-14 10:44:18 +08:00
|
|
|
})
|
|
|
|
this.User = new User(e)
|
2024-06-17 23:04:18 +08:00
|
|
|
this.button = segment.button(
|
|
|
|
[
|
|
|
|
{ text: '用户统计', callback: '#用户统计' },
|
|
|
|
{ text: '删除无效', callback: '#删除无效用户' }
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{ text: '刷新统计', callback: '#刷新用户统计' },
|
|
|
|
{ text: '重置统计', callback: '#重置用户统计' }
|
|
|
|
]
|
|
|
|
)
|
2024-06-14 10:44:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** #用户统计$ */
|
|
|
|
async userAdmin() {
|
|
|
|
let data = await new User(this.e).userAdmin()
|
|
|
|
if (!data) return true
|
|
|
|
|
|
|
|
/** 生成图片 */
|
2024-06-17 23:04:18 +08:00
|
|
|
this.reply([
|
|
|
|
await this.renderImg('genshin', 'html/admin/userAdmin', data, {
|
|
|
|
retType: 'base64'
|
|
|
|
}),
|
|
|
|
this.button
|
|
|
|
])
|
2024-06-14 10:44:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** #刷新用户缓存 / #重置用户缓存 */
|
|
|
|
async resetCache() {
|
|
|
|
// 清空老数据
|
|
|
|
const clearData = /重置/.test(this.e.msg)
|
|
|
|
await MysInfo.initCache(true, clearData)
|
2024-06-17 23:04:18 +08:00
|
|
|
this.reply([
|
|
|
|
`用户缓存已${clearData ? '重置' : '刷新'}...\n通过【#用户统计】命令可查看详情`,
|
|
|
|
this.button
|
|
|
|
])
|
2024-06-14 10:44:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async delDisable() {
|
|
|
|
let count = await MysInfo.delDisable()
|
2024-06-17 23:04:18 +08:00
|
|
|
this.reply([
|
|
|
|
count > 0 ? `已删除${count}个无效用户` : '暂无无效用户...',
|
|
|
|
this.button
|
|
|
|
])
|
2024-06-14 10:44:18 +08:00
|
|
|
}
|
|
|
|
}
|