2024-01-05 14:46:23 +08:00
|
|
|
import plugin from "../../../lib/plugins/plugin.js"
|
|
|
|
import fs from "node:fs"
|
|
|
|
import GachaLog from "../model/gachaLog.js"
|
|
|
|
import ExportLog from "../model/exportLog.js"
|
|
|
|
import LogCount from "../model/logCount.js"
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
const _path = process.cwd() + "/plugins/genshin"
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
export class gcLog extends plugin {
|
2023-12-27 18:15:06 +08:00
|
|
|
constructor() {
|
2023-03-04 14:30:13 +08:00
|
|
|
super({
|
2024-01-05 14:46:23 +08:00
|
|
|
name: "抽卡记录",
|
|
|
|
dsc: "抽卡记录数据统计",
|
|
|
|
event: "message",
|
2023-03-04 14:30:13 +08:00
|
|
|
priority: 300,
|
|
|
|
rule: [
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "(.*)authkey=(.*)",
|
|
|
|
fnc: "logUrl"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#json文件导入记录$",
|
|
|
|
fnc: "logJson"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#?(原神|星铁)?(全部)?(抽卡|抽奖|角色|武器|常驻|up|新手|光锥|全部)池*(记录|祈愿|分析)$",
|
|
|
|
fnc: "getLog"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#?(原神|星铁)?(强制)?导出记录(json)?$",
|
|
|
|
fnc: "exportLog"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#?(记录帮助|抽卡帮助)$",
|
|
|
|
fnc: "help"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#?(安卓|苹果|电脑|pc|ios)帮助$",
|
|
|
|
fnc: "helpPort"
|
2023-03-04 14:30:13 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-05 14:46:23 +08:00
|
|
|
reg: "^#?(原神|星铁)?(抽卡|抽奖|角色|武器|常驻|up|新手|光锥)池*统计$",
|
|
|
|
fnc: "logCount"
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
this.androidUrl = "https://docs.qq.com/doc/DUWpYaXlvSklmVXlX"
|
2024-02-04 09:02:39 +08:00
|
|
|
Object.defineProperty(this, "button", {
|
|
|
|
get() {
|
|
|
|
this.prefix = this.e?.isSr ? "*" : "#"
|
|
|
|
return segment.button([
|
|
|
|
{ text: "角色记录", callback: `${this.prefix}角色记录` },
|
|
|
|
{ text: "角色统计", callback: `${this.prefix}角色统计` },
|
|
|
|
], [
|
|
|
|
{ text: "武器记录", callback: `${this.prefix}武器记录` },
|
|
|
|
{ text: "武器统计", callback: `${this.prefix}武器统计` },
|
|
|
|
], [
|
|
|
|
{ text: "常驻记录", callback: `${this.prefix}常驻记录` },
|
|
|
|
{ text: "常驻统计", callback: `${this.prefix}常驻统计` },
|
|
|
|
])
|
|
|
|
}
|
|
|
|
})
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2023-12-27 18:15:06 +08:00
|
|
|
async init() {
|
2024-01-05 14:46:23 +08:00
|
|
|
let file = ["./data/gachaJson", "./data/srJson", "./temp/html/StarRail", "./temp/uigf"]
|
2023-08-18 10:19:48 +08:00
|
|
|
for (let i of file) {
|
2023-05-03 22:09:39 +08:00
|
|
|
if (!fs.existsSync(i)) {
|
|
|
|
fs.mkdirSync(i)
|
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-27 18:15:06 +08:00
|
|
|
accept() {
|
2024-01-05 14:46:23 +08:00
|
|
|
if (this.e.file) {
|
2023-03-04 14:30:13 +08:00
|
|
|
let name = this.e.file?.name
|
2024-02-04 09:02:39 +08:00
|
|
|
if (/(.*)([1-9]|18)[0-9]{8}(.*).json/ig.test(name)) {
|
2024-01-05 14:46:23 +08:00
|
|
|
this.e.msg = "#json文件导入记录"
|
2023-03-04 14:30:13 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2024-01-05 14:46:23 +08:00
|
|
|
if (this.e.msg && /^#?(角色|武器)统计$/g.test(this.e.msg)) {
|
|
|
|
this.e.msg = this.e.msg.replace("统计", "池统计")
|
2023-03-04 14:30:13 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 抽卡记录链接 */
|
2023-12-27 18:15:06 +08:00
|
|
|
async logUrl() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new GachaLog(this.e).logUrl()
|
|
|
|
if (!data) return
|
2023-08-18 10:19:48 +08:00
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
await this.renderImg("genshin", `html/gacha/gacha-log`, data)
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
if (this.e.isGroup)
|
|
|
|
this.e.reply("已收到链接,请撤回", false, { at: true })
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** #抽卡记录 */
|
2023-12-27 18:15:06 +08:00
|
|
|
async getLog() {
|
2024-01-05 14:46:23 +08:00
|
|
|
this.e.isAll = !!(this.e.msg.includes("全部"))
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new GachaLog(this.e).getLogData()
|
|
|
|
if (!data) return
|
2023-11-08 03:03:36 +08:00
|
|
|
let name = `html/gacha/gacha-log`
|
2023-08-21 03:01:22 +08:00
|
|
|
if (this.e.isAll) {
|
2023-11-08 03:03:36 +08:00
|
|
|
name = `html/gacha/gacha-all-log`
|
2023-08-21 03:01:22 +08:00
|
|
|
}
|
2024-01-05 14:46:23 +08:00
|
|
|
this.reply([await this.renderImg("genshin", name, data, { retType: "base64" }), this.button])
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 导出记录 */
|
2024-01-05 14:46:23 +08:00
|
|
|
exportLog() {
|
|
|
|
if (this.e.isGroup && !this.e.msg.includes("强制")) {
|
|
|
|
return this.reply("建议私聊导出,若你确认要在此导出,请发送【#强制导出记录】", false, { at: true })
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
return new ExportLog(this.e).exportJson()
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2023-12-27 18:15:06 +08:00
|
|
|
async logJson() {
|
2024-01-05 14:46:23 +08:00
|
|
|
if (!this.e.file)
|
|
|
|
return this.e.reply("请发送Json文件")
|
2023-10-25 17:32:57 +08:00
|
|
|
|
|
|
|
await new ExportLog(this.e).logJson()
|
2024-01-05 14:46:23 +08:00
|
|
|
|
|
|
|
if (this.e.isGroup)
|
|
|
|
this.e.reply("已收到文件,请撤回", false, { at: true })
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
help() {
|
|
|
|
this.e.reply([segment.image(`file://${_path}/resources/logHelp/记录帮助.png`), segment.button([
|
2023-12-22 22:56:11 +08:00
|
|
|
{ text: "电脑", callback: "#电脑帮助" },
|
|
|
|
{ text: "安卓", callback: "#安卓帮助" },
|
|
|
|
{ text: "苹果", callback: "#苹果帮助" },
|
|
|
|
])])
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
helpPort() {
|
|
|
|
let msg = this.e.msg.replace(/#|帮助/g, "")
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
if (["电脑", "pc"].includes(msg)) {
|
|
|
|
this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助-电脑.png`))
|
|
|
|
} else if (["安卓"].includes(msg)) {
|
|
|
|
this.e.reply(`安卓抽卡记录获取教程:${this.androidUrl}`)
|
|
|
|
} else if (["苹果", "ios"].includes(msg)) {
|
|
|
|
this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助-苹果.png`))
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
2023-08-18 10:19:48 +08:00
|
|
|
|
2023-12-27 18:15:06 +08:00
|
|
|
async logCount() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new LogCount(this.e).count()
|
|
|
|
if (!data) return
|
2023-12-22 22:56:11 +08:00
|
|
|
|
2024-01-05 14:46:23 +08:00
|
|
|
this.reply([await this.renderImg("genshin", `html/gacha/log-count`, data, { retType: "base64" }), this.button])
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
2024-01-05 14:46:23 +08:00
|
|
|
}
|