2023-03-04 14:30:13 +08:00
|
|
|
import plugin from '../../../lib/plugins/plugin.js'
|
|
|
|
import Ledger from '../model/ledger.js'
|
|
|
|
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
|
|
|
|
import fs from 'node:fs'
|
|
|
|
|
|
|
|
export class ledger extends plugin {
|
2023-08-18 10:19:48 +08:00
|
|
|
constructor() {
|
2023-03-04 14:30:13 +08:00
|
|
|
super({
|
|
|
|
name: '札记查询',
|
2023-08-18 10:19:48 +08:00
|
|
|
dsc: '米游社札记·开拓月历查询',
|
2023-03-04 14:30:13 +08:00
|
|
|
event: 'message',
|
|
|
|
priority: 300,
|
|
|
|
rule: [
|
|
|
|
{
|
2023-08-18 10:19:48 +08:00
|
|
|
reg: '^(#原石|#*札记|#*(星铁)?星琼)([0-9]|[一二两三四五六七八九十]+)*月*$',
|
2023-03-04 14:30:13 +08:00
|
|
|
fnc: 'ledger'
|
|
|
|
},
|
|
|
|
{
|
2023-08-18 10:19:48 +08:00
|
|
|
reg: '^#(原石|#*(星铁)?星琼)任务$',
|
2023-03-04 14:30:13 +08:00
|
|
|
permission: 'master',
|
|
|
|
fnc: 'ledgerTask'
|
|
|
|
},
|
|
|
|
{
|
2023-08-18 10:19:48 +08:00
|
|
|
reg: '^#*(原石|札记|#*(星铁)?星琼)统计$',
|
2023-03-04 14:30:13 +08:00
|
|
|
fnc: 'ledgerCount'
|
|
|
|
},
|
|
|
|
{
|
2023-08-18 10:19:48 +08:00
|
|
|
reg: '^#*(去年|今年|\\d{4}年)(原石|札记|(星铁)?星琼)统计$',
|
2023-03-04 14:30:13 +08:00
|
|
|
fnc: 'ledgerCountHistory'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-08-18 10:19:48 +08:00
|
|
|
async init() {
|
|
|
|
let file = ['./data/NoteData', './data/SR_NoteData']
|
|
|
|
for (let i of file) {
|
|
|
|
if (!fs.existsSync(i)) {
|
|
|
|
fs.mkdirSync(i)
|
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** #原石札记 */
|
2023-08-18 10:19:48 +08:00
|
|
|
async ledger() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new Ledger(this.e).get()
|
|
|
|
if (!data) return
|
|
|
|
|
|
|
|
/** 生成图片 */
|
2023-08-19 19:48:02 +08:00
|
|
|
let img = await puppeteer.screenshot(`${data.srtempFile}ledger`, data)
|
2023-03-04 14:30:13 +08:00
|
|
|
if (img) await this.reply(img)
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 原石任务 */
|
2023-08-18 10:19:48 +08:00
|
|
|
async ledgerTask() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let ledger = new Ledger(this.e)
|
|
|
|
await ledger.ledgerTask(!!this?.e?.msg)
|
|
|
|
}
|
|
|
|
|
2023-08-18 10:19:48 +08:00
|
|
|
async ledgerCount() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new Ledger(this.e).ledgerCount()
|
|
|
|
if (!data) return
|
|
|
|
|
|
|
|
/** 生成图片 */
|
2023-08-19 19:48:02 +08:00
|
|
|
let img = await puppeteer.screenshot(`${data.srtempFile}ledgerCount`, data)
|
2023-03-04 14:30:13 +08:00
|
|
|
if (img) await this.reply(img)
|
|
|
|
}
|
|
|
|
|
2023-08-18 10:19:48 +08:00
|
|
|
async ledgerCountHistory() {
|
2023-03-04 14:30:13 +08:00
|
|
|
let data = await new Ledger(this.e).ledgerCountHistory()
|
|
|
|
if (!data) return
|
|
|
|
|
|
|
|
/** 生成图片 */
|
2023-08-19 19:48:02 +08:00
|
|
|
let img = await puppeteer.screenshot(`${data.srtempFile}ledgerCount`, data)
|
2023-03-04 14:30:13 +08:00
|
|
|
if (img) await this.reply(img)
|
|
|
|
}
|
|
|
|
}
|