diff --git a/plugins/genshin/apps/calculator.js b/plugins/genshin/apps/calculator.js index 9766fee..f3312e7 100644 --- a/plugins/genshin/apps/calculator.js +++ b/plugins/genshin/apps/calculator.js @@ -66,18 +66,7 @@ export class calculator extends plugin { if (!data) return /** 生成图片 */ - let url = this.srHead('calculator', data) - let img = await puppeteer.screenshot(url, data) + let img = await puppeteer.screenshot(this.e.isSr ?'StarRail/calculator':'calculator', data) if (img) await this.reply(img) } - srHead = (url, data) => { - let name = url - if (this.e.isSr) { - name = `StarRail/${url}` - data.pluResPath = `${this._path}/plugins/genshin/resources/StarRail/` - data.tplFile = `./plugins/genshin/resources/StarRail/html/${url}/${url}.html` - data.headStyle = `` - } - return name - } } diff --git a/plugins/genshin/apps/dailyNote.js b/plugins/genshin/apps/dailyNote.js index f139103..bc71be3 100644 --- a/plugins/genshin/apps/dailyNote.js +++ b/plugins/genshin/apps/dailyNote.js @@ -6,7 +6,7 @@ import puppeteer from '../../../lib/puppeteer/puppeteer.js' gsCfg.cpCfg('mys', 'set') export class dailyNote extends plugin { - constructor () { + constructor() { super({ name: '体力查询', dsc: '体力查询', @@ -22,12 +22,12 @@ export class dailyNote extends plugin { } /** #体力 */ - async note () { + async note() { let data = await Note.get(this.e) if (!data) return /** 生成图片 */ - let img = await puppeteer.screenshot('dailyNote', data) + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/dailyNote' : 'dailyNote', data) if (img) await this.reply(img) } diff --git a/plugins/genshin/apps/gcLog.js b/plugins/genshin/apps/gcLog.js index c044ae0..e1c3539 100644 --- a/plugins/genshin/apps/gcLog.js +++ b/plugins/genshin/apps/gcLog.js @@ -8,7 +8,7 @@ import LogCount from '../model/logCount.js' const _path = process.cwd() + '/plugins/genshin' export class gcLog extends plugin { - constructor () { + constructor() { super({ name: '抽卡记录', dsc: '抽卡记录数据统计', @@ -55,19 +55,18 @@ export class gcLog extends plugin { }) this.androidUrl = 'docs.qq.com/doc/DUWpYaXlvSklmVXlX' - this._path = process.cwd().replace(/\\/g, '/') } - async init () { - let file = ['./data/gachaJson','./data/srJson','./temp/html/StarRail'] - for(let i of file){ + async init() { + let file = ['./data/gachaJson', './data/srJson', './temp/html/StarRail'] + for (let i of file) { if (!fs.existsSync(i)) { fs.mkdirSync(i) } } } - accept () { + accept() { if (this.e.file && this.e.isPrivate) { let name = this.e.file?.name if (name.includes('txt')) { @@ -90,7 +89,7 @@ export class gcLog extends plugin { } /** 抽卡记录链接 */ - async logUrl () { + async logUrl() { if (!this.e.isPrivate) { this.e.reply('请私聊发送链接', false, { at: true }) return true @@ -98,13 +97,13 @@ export class gcLog extends plugin { let data = await new GachaLog(this.e).logUrl() if (!data) return - let url = this.srHead('gachaLog', data) - let img = await puppeteer.screenshot(url, data) + + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/gachaLog' : 'gachaLog', data) if (img) await this.reply(img) } /** 发送output_log.txt日志文件 */ - async logFile () { + async logFile() { if (!this.e.isPrivate) { await this.e.reply('请私聊发送日志文件', false, { at: true }) return true @@ -121,27 +120,22 @@ export class gcLog extends plugin { if (!data) return false if (typeof data != 'object') return - let url='gachaLog' - if(this.e.isSr){ - url ='StarRail/gachaLog' - data.tplFile = './plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.html' - data.headStyle = `` - } - let img = await puppeteer.screenshot(url, data) + + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/gachaLog' : 'gachaLog', data) if (img) await this.reply(img) } /** #抽卡记录 */ - async getLog () { + async getLog() { let data = await new GachaLog(this.e).getLogData() if (!data) return - let url = this.srHead('gachaLog', data) - let img = await puppeteer.screenshot(url, data) + + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/gachaLog' : 'gachaLog', data) if (img) await this.reply(img) } /** 导出记录 */ - async exportLog () { + async exportLog() { if (this.e.isGroup) { await this.reply('请私聊导出', false, { at: true }) return @@ -162,7 +156,7 @@ export class gcLog extends plugin { } } - async logXlsx () { + async logXlsx() { if (!this.e.isPrivate) { await this.e.reply('请私聊发送日志文件', false, { at: true }) return true @@ -176,7 +170,7 @@ export class gcLog extends plugin { await new ExportLog(this.e).logXlsx() } - async logJson () { + async logJson() { if (!this.e.isPrivate) { await this.e.reply('请私聊发送Json文件', false, { at: true }) return true @@ -190,11 +184,11 @@ export class gcLog extends plugin { await new ExportLog(this.e).logJson() } - async help () { + async help() { await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助.png`)) } - async helpPort () { + async helpPort() { let msg = this.e.msg.replace(/#|帮助/g, '') if (['电脑', 'pc'].includes(msg)) { @@ -205,20 +199,12 @@ export class gcLog extends plugin { await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助-苹果.png`)) } } - srHead = (url, data) => { - let name = url - if (this.e.isSr) { - name = `StarRail/${url}` - data.tplFile = `./plugins/genshin/resources/StarRail/html/${url}/${url}.html` - data.headStyle = `` - } - return name - } - async logCount () { + + async logCount() { let data = await new LogCount(this.e).count() if (!data) return - let url = this.srHead('logCount', data) - let img = await puppeteer.screenshot(url, data) + + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/logCount' : 'logCount', data) if (img) await this.reply(img) } } diff --git a/plugins/genshin/apps/ledger.js b/plugins/genshin/apps/ledger.js index 2ea3640..3323fb3 100644 --- a/plugins/genshin/apps/ledger.js +++ b/plugins/genshin/apps/ledger.js @@ -4,84 +4,74 @@ import puppeteer from '../../../lib/puppeteer/puppeteer.js' import fs from 'node:fs' export class ledger extends plugin { - constructor () { + constructor() { super({ name: '札记查询', - dsc: '原神体米游社札记原神查询', + dsc: '米游社札记·开拓月历查询', event: 'message', priority: 300, rule: [ { - reg: '^(#原石|#*札记)([0-9]|[一二两三四五六七八九十]+)*月*$', + reg: '^(#原石|#*札记|#*(星铁)?星琼)([0-9]|[一二两三四五六七八九十]+)*月*$', fnc: 'ledger' }, { - reg: '^(#签到|#*米游社(自动)*签到)$', - fnc: 'sign' - }, - { - reg: '^#原石任务$', + reg: '^#(原石|#*(星铁)?星琼)任务$', permission: 'master', fnc: 'ledgerTask' }, { - reg: '^#*(原石|札记)统计$', + reg: '^#*(原石|札记|#*(星铁)?星琼)统计$', fnc: 'ledgerCount' }, { - reg: '^#*(去年|今年|\\d{4}年)(原石|札记)统计$', + reg: '^#*(去年|今年|\\d{4}年)(原石|札记|(星铁)?星琼)统计$', fnc: 'ledgerCountHistory' } ] }) - - // this.set = gsCfg.getConfig('mys', 'set') - - // /** 定时任务 */ - // this.task = { - // cron: this.set.signTime, - // name: '米游社签到任务', - // fnc: () => this.signTask() - // } } - async init () { - if (!fs.existsSync('./data/NoteData')) { - fs.mkdirSync('./data/NoteData') + async init() { + let file = ['./data/NoteData', './data/SR_NoteData'] + for (let i of file) { + if (!fs.existsSync(i)) { + fs.mkdirSync(i) + } } } /** #原石札记 */ - async ledger () { + async ledger() { let data = await new Ledger(this.e).get() if (!data) return /** 生成图片 */ - let img = await puppeteer.screenshot('ledger', data) + let img = await puppeteer.screenshot(this.e.isSr ?'StarRail/ledger':'ledger', data) if (img) await this.reply(img) } /** 原石任务 */ - async ledgerTask () { + async ledgerTask() { let ledger = new Ledger(this.e) await ledger.ledgerTask(!!this?.e?.msg) } - async ledgerCount () { + async ledgerCount() { let data = await new Ledger(this.e).ledgerCount() if (!data) return /** 生成图片 */ - let img = await puppeteer.screenshot('ledgerCount', data) + let img = await puppeteer.screenshot(this.e.isSr ?'StarRail/ledgerCount':'ledgerCount', data) if (img) await this.reply(img) } - async ledgerCountHistory () { + async ledgerCountHistory() { let data = await new Ledger(this.e).ledgerCountHistory() if (!data) return /** 生成图片 */ - let img = await puppeteer.screenshot('ledgerCount', data) + let img = await puppeteer.screenshot(this.e.isSr ? 'StarRail/ledgerCount' : 'ledgerCount', data) if (img) await this.reply(img) } } diff --git a/plugins/genshin/model/base.js b/plugins/genshin/model/base.js index 57fcd43..78a8080 100644 --- a/plugins/genshin/model/base.js +++ b/plugins/genshin/model/base.js @@ -20,6 +20,16 @@ export default class base { get screenData() { let headImg = '林尼' + if(this.e?.isSr) + return { + saveId: this.userId, + cwd: this._path, + tplFile: `./plugins/genshin/resources/StarRail/html/${this.model}/${this.model}.html`, + /** 绝对路径 */ + pluResPath: `${this._path}/plugins/genshin/resources/StarRail/`, + headStyle: `` + } + return { saveId: this.userId, cwd: this._path, diff --git a/plugins/genshin/model/ledger.js b/plugins/genshin/model/ledger.js index 9589286..60f3571 100644 --- a/plugins/genshin/model/ledger.js +++ b/plugins/genshin/model/ledger.js @@ -1,4 +1,5 @@ import base from './base.js' +import GsCfg from './gsCfg.js' import MysInfo from './mys/mysInfo.js' import MysApi from './mys/mysApi.js' import lodash from 'lodash' @@ -7,12 +8,26 @@ import fs from 'node:fs' import common from '../../../lib/common/common.js' export default class Ledger extends base { - constructor (e) { + constructor(e) { super(e) + this.e = e this.model = 'ledger' + if (this.e.msg?.includes('星琼')) + this.e.isSr = true + + this.color = ['#73a9c6', '#d56565', '#70b2b4', '#bd9a5a', '#739970', '#7a6da7', '#597ea0'] + this.action = { + "other": 0, + "adventure_reward": 1, + "space_reward": 2, + "daily_reward": 3, + "abyss_reward": 4, + "mail_reward": 5, + "event_reward": 6 + } } - async get () { + async get() { this.getMonth() if (!this.month) return @@ -27,8 +42,8 @@ export default class Ledger extends base { return data } - getMonth () { - let month = this.e.msg.replace(/#|原石|月|札记/g, '') + getMonth() { + let month = this.e.msg.replace(/#|原石|月|札记|星铁|星琼/g, '') let NowMonth = Number(moment().month()) + 1 let monthData = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'] if (month) { @@ -59,74 +74,89 @@ export default class Ledger extends base { if ((NowMonth >= 3 && month > NowMonth) || (NowMonth < 3 && month > NowMonth && month <= 9 + month)) { month = NowMonth } - - this.NowMonth = NowMonth - this.month = month + if (this.e.isSr) { + this.NowMonth = moment().year().toString() + (NowMonth < 10 ? '0' : '') + NowMonth.toString() + this.month = moment().year().toString() + (month < 10 ? '0' : '') + month.toString() + this.srmonth = month + } else { + this.NowMonth = NowMonth + this.month = month + } } - dealData (ledgerInfo) { + dealData(ledgerInfo) { let day if (this.month == this.NowMonth) { - day = `${this.month}月${moment().date()}号` + day = `${this[this.e.isSr ? 'srmonth' : 'month']}月${moment().date()}号` } else { - day = `${this.month}月` + day = `${this[this.e.isSr ? 'srmonth' : 'month']}月` } - ledgerInfo.month_data.gacha = (ledgerInfo.month_data.current_primogems / 160).toFixed(0) - ledgerInfo.month_data.last_gacha = (ledgerInfo.month_data.last_primogems / 160).toFixed(0) - if (ledgerInfo.month_data.current_primogems > 10000) { - ledgerInfo.month_data.current_primogems = (ledgerInfo.month_data.current_primogems / 10000).toFixed(2) + ' w' + let gacha = this.e.isSr ? 'current_hcoin' : 'current_primogems' + let last_gacha = this.e.isSr ? 'last_hcoin' : 'last_primogems' + let mora = this.e.isSr ? 'current_rails_pass' : 'current_mora' + let last_mora = this.e.isSr ? 'last_rails_pass' : 'last_mora' + + ledgerInfo.month_data.gacha = (ledgerInfo.month_data[gacha] / 160).toFixed(0) + ledgerInfo.month_data.last_gacha = (ledgerInfo.month_data[last_gacha] / 160).toFixed(0) + if (ledgerInfo.month_data[gacha] > 10000) { + ledgerInfo.month_data[gacha] = (ledgerInfo.month_data[gacha] / 10000).toFixed(2) + ' w' } - if (ledgerInfo.month_data.last_primogems > 10000) { - ledgerInfo.month_data.last_primogems = (ledgerInfo.month_data.last_primogems / 10000).toFixed(2) + ' w' + if (ledgerInfo.month_data[last_gacha] > 10000) { + ledgerInfo.month_data[last_gacha] = (ledgerInfo.month_data[last_gacha] / 10000).toFixed(2) + ' w' } - if (ledgerInfo.month_data.current_mora > 10000) { - ledgerInfo.month_data.current_mora = (ledgerInfo.month_data.current_mora / 10000).toFixed(1) + ' w' + if (ledgerInfo.month_data[mora] > 10000) { + ledgerInfo.month_data[mora] = (ledgerInfo.month_data[mora] / 10000).toFixed(1) + ' w' } - if (ledgerInfo.month_data.last_mora > 10000) { - ledgerInfo.month_data.last_mora = (ledgerInfo.month_data.last_mora / 10000).toFixed(1) + ' w' + if (ledgerInfo.month_data[last_mora] > 10000) { + ledgerInfo.month_data[last_mora] = (ledgerInfo.month_data[last_mora] / 10000).toFixed(1) + ' w' } - if (ledgerInfo.day_data.current_primogems > 10000) { - ledgerInfo.day_data.current_primogems = (ledgerInfo.day_data.current_primogems / 10000).toFixed(1) + ' w' + if (ledgerInfo.day_data[gacha] > 10000) { + ledgerInfo.day_data[gacha] = (ledgerInfo.day_data[gacha] / 10000).toFixed(1) + ' w' } - if (ledgerInfo.day_data.current_mora > 10000) { - ledgerInfo.day_data.current_mora = (ledgerInfo.day_data.current_mora / 10000).toFixed(1) + ' w' + if (ledgerInfo.day_data[mora] > 10000) { + ledgerInfo.day_data[mora] = (ledgerInfo.day_data[mora] / 10000).toFixed(1) + ' w' } - let color = ['#73a9c6', '#d56565', '#70b2b4', '#bd9a5a', '#739970', '#7a6da7', '#597ea0'] - for (let i in ledgerInfo.month_data.group_by) { - ledgerInfo.month_data.group_by[i].color = color[ledgerInfo.month_data.group_by[i].action_id] - } ledgerInfo.color = [] ledgerInfo.month_data.group_by.forEach((item) => { - ledgerInfo.color.push(['#73a9c6', '#d56565', '#70b2b4', '#bd9a5a', '#739970', '#7a6da7', '#597ea0'][item.action_id]) + if (this.e.isSr) + item.color = this.color[this.action[item.action]] + else + item.color = this.color[item.action_id] + ledgerInfo.color.push(item.color) }) + ledgerInfo.group_by = JSON.stringify(ledgerInfo.month_data.group_by) ledgerInfo.color = JSON.stringify(ledgerInfo.color) + let files = fs.readdirSync('./plugins/genshin/resources/StarRail/img/role').filter(file => file.endsWith('.webp')) + let icon = lodash.sample(files) + return { saveId: this.e.uid, uid: this.e.uid, day, + icon, ...ledgerInfo, ...this.screenData } } // 保存上两个原石数据 - async saveLedger (uid, ck = '') { + async saveLedger(uid, ck = '', isTask = false) { if (ck) { uid = ck.uid } else { /** 获取个人ck */ - ck = await MysInfo.checkUidBing(uid) + ck = await MysInfo.checkUidBing(uid, this.e.isSr ? 'sr' : 'gs') } if (!ck || lodash.isEmpty(ck)) { return false } - let dataPath = `./data/NoteData/${uid}.json` + let dataPath = `./data/${this.e?.isSr ? 'SR_NoteData' : 'NoteData'}/${uid}.json` let NoteData = {} if (fs.existsSync(dataPath)) { NoteData = JSON.parse(fs.readFileSync(dataPath, 'utf8')) @@ -153,7 +183,10 @@ export default class Ledger extends base { if (NowMonth == month && this.e.nowData && this.e.nowData?.data?.data_month == NowMonth) { ledgerInfo = this.e.nowData } else { - ledgerInfo = await this.ysLedger(ck, month) + let months = month + if (this.e.isSr) months = String(year) + (month < 10 ? '0' : '') + String(month) + + ledgerInfo = await this.ysLedger(ck, months, isTask) if (!ledgerInfo) continue } @@ -166,47 +199,52 @@ export default class Ledger extends base { common.sleep(100) } - logger.mark(`[札记查询][自动保存] uid:${uid} 原石数据已保存`) + logger.mark(`[札记查询][自动保存] uid:${uid} 数据已保存`) fs.writeFileSync(dataPath, JSON.stringify(NoteData, '', '\t')) return NoteData } - async ysLedger (ck, month) { - let mysApi = new MysApi(ck.uid, ck.ck, { log: false }) - - let ledgerInfo = await mysApi.getData('ys_ledger', { month }) + async ysLedger(ck, month, isTask) { + let ledgerInfo = {} + if (isTask) { + let mysApi = new MysApi(ck.uid, ck.ck, { log: false }, this.e?.isSr) + ledgerInfo = await mysApi.getData('ys_ledger', { month }) + ledgerInfo = await new MysInfo(this.e).checkCode(ledgerInfo, 'ys_ledger', mysApi, { month }, isTask) + } else { + ledgerInfo = await MysInfo.get(this.e, 'ys_ledger', { month }) + } if (!ledgerInfo || ledgerInfo.retcode != 0) return false return ledgerInfo.data } - async ledgerTask (manual) { - let cks = await MysInfo.getBingCkUid() + async ledgerTask(manual) { + let cks = await GsCfg.getBingCk(this.e?.isSr ? 'sr' : 'gs') let uids = lodash.map(cks, 'uid') let finishTime = moment().add(uids.length * 0.7, 's').format('MM-DD HH:mm:ss') - logger.mark(`札记ck:${uids.length}个,预计需要${this.countTime(uids.length)} ${finishTime} 完成`) + logger.mark(`${this.e?.isSr ? '开拓月历' : '札记'}ck:${uids.length}个,预计需要${this.countTime(uids.length)} ${finishTime} 完成`) if (manual) { - await this.e.reply('开始任务:保存原石数据,完成前请勿重复执行') - await this.e.reply(`札记ck:${uids.length}个\n预计需要:${this.countTime(uids.length)}\n完成时间:${finishTime}`) + await this.e.reply(`开始任务:保存${this.e?.isSr ? '星琼' : '原石'}数据,完成前请勿重复执行`) + await this.e.reply(`${this.e?.isSr ? '开拓月历' : '札记'}ck:${uids.length}个\n预计需要:${this.countTime(uids.length)}\n完成时间:${finishTime}`) } for (let uid of uids) { let ck = cks[uid] this.e.user_id = ck.qq - await this.saveLedger(uid, ck) + await this.saveLedger(uid, ck, true) await common.sleep(500) } if (manual) { - this.e.reply('原石任务完成') + this.e.reply(`${this.e?.isSr ? '星琼' : '原石'}任务完成`) } } - countTime (num) { + countTime(num) { let time = num * 0.7 let hour = Math.floor((time / 3600) % 24) let min = Math.floor((time / 60) % 60) @@ -218,7 +256,7 @@ export default class Ledger extends base { return msg } - async ledgerCount () { + async ledgerCount() { this.model = 'ledgerCount' let mysInfo = await MysInfo.init(this.e, 'ys_ledger') @@ -231,7 +269,7 @@ export default class Ledger extends base { return this.ledgerCountData(NoteData) } - async ledgerCountHistory () { + async ledgerCountHistory() { let nowYear if (this.e.msg.includes('去年')) { nowYear = moment().year() - 1 @@ -251,19 +289,19 @@ export default class Ledger extends base { let mysInfo = await MysInfo.init(this.e, 'ys_ledger') let uid = mysInfo?.uid if (!uid) return false - let dataPath = `./data/NoteData/${uid}.json` + let dataPath = `./data/${this.e?.isSr ? 'SR_NoteData' : 'NoteData'}/${uid}.json` let NoteData = {} if (fs.existsSync(dataPath)) { NoteData = JSON.parse(fs.readFileSync(dataPath, 'utf8')) } // console.log(NoteData) if (!NoteData || lodash.isEmpty(NoteData)) { - this.e.reply('暂无原石数据,请先发送 #原石', false, { at: true }) + this.e.reply(`${this.e?.isSr ? '暂无星琼数据,请先发送 *星琼' : '暂无原石数据,请先发送 #原石'}`, false, { at: true }) return false } NoteData = NoteData[nowYear] if (!NoteData) { - this.e.reply(`uid:${uid} ${nowYear}年无原石统计数据!`, false, { at: true }) + this.e.reply(`uid:${uid} ${nowYear}年无${this.e?.isSr ? '星琼' : '原石'}统计数据!`, false, { at: true }) return false } lodash.forEach(NoteData, (val) => { @@ -273,7 +311,7 @@ export default class Ledger extends base { return this.ledgerCountData(NoteData, String(nowYear)) } - ledgerCountData (NoteData, nowYear) { + ledgerCountData(NoteData, nowYear) { let hasMore = false let yearText if (!nowYear) { @@ -317,28 +355,38 @@ export default class Ledger extends base { yearText } + let Primogems = this.e.isSr ? 'current_hcoin' : 'current_primogems' + let Mora = this.e.isSr ? 'current_rails_pass' : 'current_mora' lodash.forEach(NoteData, (val) => { - data.allPrimogems += val.month_data.current_primogems - data.allMora += val.month_data.current_mora + data.allPrimogems += val.month_data[Primogems] + data.allMora += val.month_data[Mora] // 柱状图数据 + if (this.e.isSr) + val.data_month = val.data_month.slice(-2, -1) == '0' ? val.data_month.slice(-1) : val.data_month.slice(-2) + data.primogemsMonth.push({ - value: val.month_data.current_primogems, + value: val.month_data[Primogems], month: String(val.data_month), year: String(val.year), - name: '原石' + name: this.e.isSr ? '星琼' : '原石' }) data.moraMonth.push({ - value: (val.month_data.current_mora / 1000).toFixed(0), + value: (val.month_data[Mora] / 1000).toFixed(0), month: String(val.data_month), year: String(val.year), - name: '摩拉' + name: this.e.isSr ? '专&通票' : '摩拉' }) }) // 单位处理 - data.allMora = (data.allMora / 10000).toFixed(0) + 'w' data.allPrimogemsShow = (data.allPrimogems / 10000).toFixed(2) + 'w' data.allGacha = (data.allPrimogems / 160).toFixed(0) + if (this.e.isSr) { + data.allGacha = (data.allPrimogems / 160 + data.allMora).toFixed(0) + data.allMora = data.allMora.toFixed(0) + '张' + } else { + data.allMora = (data.allMora / 10000).toFixed(0) + 'w' + } // 原石最多 data.maxPrimogems = lodash.maxBy(data.primogemsMonth, 'value') @@ -350,6 +398,12 @@ export default class Ledger extends base { let groupBy = lodash(NoteData).map('month_data').map('group_by').flatMap().value() + if (this.e.isSr) + groupBy.forEach((item) => { + item.action_id = this.action[item.action] + item.action = item.action_name + }) + let pieData = {} for (let val of groupBy) { if (!pieData[val.action]) { @@ -370,7 +424,7 @@ export default class Ledger extends base { data.color = [] pieData.forEach((item) => { - data.color.push(['#73a9c6', '#d56565', '#70b2b4', '#bd9a5a', '#739970', '#7a6da7', '#597ea0'][item.action_id]) + data.color.push(this.color[item.action_id]) }) data.group_by = pieData diff --git a/plugins/genshin/model/mys/apiTool.js b/plugins/genshin/model/mys/apiTool.js index 036e770..3df51e3 100644 --- a/plugins/genshin/model/mys/apiTool.js +++ b/plugins/genshin/model/mys/apiTool.js @@ -161,7 +161,7 @@ export default class apiTool { * 开拓阅历接口 */ ys_ledger: { - url: `${host}/event/srledger/month_info`, + url: `${host}event/srledger/month_info`, query: `region=${this.server}&uid=${this.uid}&month=${data.month}` }, /** 角色详情 */ diff --git a/plugins/genshin/model/mys/mysInfo.js b/plugins/genshin/model/mys/mysInfo.js index 31bb030..26aa0af 100644 --- a/plugins/genshin/model/mys/mysInfo.js +++ b/plugins/genshin/model/mys/mysInfo.js @@ -177,7 +177,7 @@ export default class MysInfo { } for (let i in res) { - res[i] = await mysInfo.checkCode(res[i], res[i].api, mysApi) + res[i] = await mysInfo.checkCode(res[i], res[i].api, mysApi, api[res[i].api]) if (res[i]?.retcode === 0) continue @@ -185,7 +185,7 @@ export default class MysInfo { } } else { res = await mysApi.getData(api, data) - res = await mysInfo.checkCode(res, api, mysApi) + res = await mysInfo.checkCode(res, api, mysApi, data) } return res @@ -329,15 +329,15 @@ export default class MysInfo { } else { // 重新分配 await mysUser.disable(game) - return onlySelfCk ? '' : await this.getCookie() + return onlySelfCk ? '' : await this.getCookie(game) } } return this.ckUser?.ck } - async checkCode(res, type, mysApi = {}) { + async checkCode(res, type, mysApi = {}, data = {}, isTask = false) { if (!res) { - this.e.reply('米游社接口请求失败,暂时无法查询') + if (!isTask) this.e.reply('米游社接口请求失败,暂时无法查询') return false } @@ -359,28 +359,30 @@ export default class MysInfo { if (/(登录|login)/i.test(res.message)) { if (this.ckInfo.uid) { logger.mark(`[ck失效][uid:${this.uid}][qq:${this.userId}]`) - this.e.reply(`UID:${this.ckInfo.uid},米游社cookie已失效`) + if (!isTask) this.e.reply(`UID:${this.ckInfo.uid},米游社cookie已失效`) } else { logger.mark(`[公共ck失效][ltuid:${this.ckInfo.ltuid}]`) - this.e.reply('米游社查询失败,请稍后再试') + if (!isTask) this.e.reply('米游社查询失败,请稍后再试') } - await this.delCk() + if (!isTask) await this.delCk() } else { - this.e.reply(`米游社接口报错,暂时无法查询:${res.message}`) + if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message}`) } break case 1008: - this.e.reply('\n请先去米游社绑定角色', false, { at: this.userId }) + if (!isTask) this.e.reply('\n请先去米游社绑定角色', false, { at: this.userId }) break case 10101: - await this.disableToday() - this.e.reply('查询已达今日上限') + if (!isTask) { + await this.disableToday() + this.e.reply('查询已达今日上限') + } break case 10102: if (res.message === 'Data is not public for the user') { - this.e.reply(`\nUID:${this.uid},米游社数据未公开`, false, { at: this.userId }) + if (!isTask) this.e.reply(`\nUID:${this.uid},米游社数据未公开`, false, { at: this.userId }) } else { - this.e.reply(`uid:${this.uid},请先去米游社绑定角色`) + if (!isTask) this.e.reply(`uid:${this.uid},请先去米游社绑定角色`) } break // 伙伴不存在~ @@ -389,17 +391,17 @@ export default class MysInfo { break case 1034: logger.mark(`[米游社查询失败][uid:${this.uid}][qq:${this.userId}] 遇到验证码`) - this.e.reply('米游社查询遇到验证码,请稍后再试') + if (!isTask) this.e.reply('米游社查询遇到验证码,请稍后再试') break default: - this.e.reply(`米游社接口报错,暂时无法查询:${res.message || 'error'}`) + if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message || 'error'}`) break } if (res.retcode !== 0) { logger.mark(`[mys接口报错]${JSON.stringify(res)},uid:${this.uid}`) } // 添加请求记录 - await this.ckUser.addQueryUid(this.uid) + if (!isTask) await this.ckUser.addQueryUid(this.uid) return res } diff --git a/plugins/genshin/model/note.js b/plugins/genshin/model/note.js index 3664249..3f2caa6 100644 --- a/plugins/genshin/model/note.js +++ b/plugins/genshin/model/note.js @@ -33,7 +33,6 @@ export default class Note extends base { let screenData = this.screenData if (this.e.isSr) { - screenData.tplFile = './plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html' resUser = await MysInfo.get(this.e, 'UserGame') resUser.data?.list?.forEach(v => this.e.uid.includes(v.game_biz)) if (!resUser || resUser.retcode !== 0) return false diff --git a/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html b/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html index 20b87b7..319b7b0 100644 --- a/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html +++ b/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html @@ -4,7 +4,7 @@
- + @@ -18,7 +18,7 @@