删除多余匹配

This commit is contained in:
🌌 2023-09-23 19:17:53 +08:00
parent 197db1654f
commit 3bfd6693e6
2 changed files with 25 additions and 23 deletions

View File

@ -220,7 +220,7 @@ class PluginsLoader {
// 判断是否是星铁命令,若是星铁命令则标准化处理 // 判断是否是星铁命令,若是星铁命令则标准化处理
// e.isSr = true且命令标准化为 #星铁 开头 // e.isSr = true且命令标准化为 #星铁 开头
if (this.srReg.test(e.msg) || /(\/common\/|hkrpg)/.test(e.msg)) { if (this.srReg.test(e.msg)) {
e.isSr = true e.isSr = true
e.msg = e.msg.replace(this.srReg, '#星铁') e.msg = e.msg.replace(this.srReg, '#星铁')
} }

View File

@ -6,7 +6,7 @@ import common from '../../../lib/common/common.js'
import gsCfg from './gsCfg.js' import gsCfg from './gsCfg.js'
export default class GachaLog extends base { export default class GachaLog extends base {
constructor (e) { constructor(e) {
super(e) super(e)
this.model = 'gachaLog' this.model = 'gachaLog'
@ -35,7 +35,7 @@ export default class GachaLog extends base {
} }
} }
async logUrl () { async logUrl() {
let url = this.e.msg let url = this.e.msg
/** 处理url */ /** 处理url */
@ -73,7 +73,7 @@ export default class GachaLog extends base {
return data return data
} }
async logFile () { async logFile() {
let url = await this.downFile() let url = await this.downFile()
if (!url) { if (!url) {
if (this.e?.file?.name.includes('output')) { if (this.e?.file?.name.includes('output')) {
@ -86,7 +86,9 @@ export default class GachaLog extends base {
return this.logUrl() return this.logUrl()
} }
dealUrl (url) { dealUrl(url) {
if (!this.e.isSr) this.e.isSr = /hkrpg/.test(this.e.msg)
// timestamp=1641338980〈=zh-cn 修复链接有奇怪符号 // timestamp=1641338980〈=zh-cn 修复链接有奇怪符号
url = url.replace(/〈=/g, '&') url = url.replace(/〈=/g, '&')
if (url.includes('getGachaLog?')) url = url.split('getGachaLog?')[1] if (url.includes('getGachaLog?')) url = url.split('getGachaLog?')[1]
@ -111,7 +113,7 @@ export default class GachaLog extends base {
return params return params
} }
async downFile () { async downFile() {
this.creatFile() this.creatFile()
let textPath = `${this.path}output_log.txt` let textPath = `${this.path}output_log.txt`
@ -140,7 +142,7 @@ export default class GachaLog extends base {
return url[0] return url[0]
} }
async checkUrl (param) { async checkUrl(param) {
if (!param.region) { if (!param.region) {
let res = await this.logApi({ let res = await this.logApi({
size: 6, size: 6,
@ -209,7 +211,7 @@ export default class GachaLog extends base {
} }
} }
async logApi (param) { async logApi(param) {
// 调用一次接口判断链接是否正确 // 调用一次接口判断链接是否正确
let logUrl = 'https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?' let logUrl = 'https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?'
/** 国际服 */ /** 国际服 */
@ -252,7 +254,7 @@ export default class GachaLog extends base {
} }
/** 更新抽卡记录 */ /** 更新抽卡记录 */
async updateLog () { async updateLog() {
/** 获取authkey */ /** 获取authkey */
let authkey = await redis.get(`${this.urlKey}${this.uid}`) let authkey = await redis.get(`${this.urlKey}${this.uid}`)
if (!authkey) return false if (!authkey) return false
@ -295,7 +297,7 @@ export default class GachaLog extends base {
} }
/** 递归获取所有数据 */ /** 递归获取所有数据 */
async getAllLog (ids, authkey, page = 1, endId = 0) { async getAllLog(ids, authkey, page = 1, endId = 0) {
let res = await this.logApi({ let res = await this.logApi({
gacha_type: this.type, gacha_type: this.type,
page, page,
@ -342,7 +344,7 @@ export default class GachaLog extends base {
} }
// 读取本地json // 读取本地json
readJson () { readJson() {
let logJson = []; let ids = new Map() let logJson = []; let ids = new Map()
let file = `${this.path}/${this.uid}/${this.type}.json` let file = `${this.path}/${this.uid}/${this.type}.json`
if (fs.existsSync(file)) { if (fs.existsSync(file)) {
@ -358,7 +360,7 @@ export default class GachaLog extends base {
return { list: logJson, ids } return { list: logJson, ids }
} }
creatFile () { creatFile() {
if (!fs.existsSync(this.path)) { if (!fs.existsSync(this.path)) {
fs.mkdirSync(this.path) fs.mkdirSync(this.path)
} }
@ -369,7 +371,7 @@ export default class GachaLog extends base {
} }
} }
writeJson (data) { writeJson(data) {
this.creatFile() this.creatFile()
let file = `${this.path}${this.uid}/` let file = `${this.path}${this.uid}/`
@ -378,7 +380,7 @@ export default class GachaLog extends base {
} }
/** #抽卡记录 */ /** #抽卡记录 */
async getLogData () { async getLogData() {
/** 判断uid */ /** 判断uid */
await this.getUid() await this.getUid()
if (!this.uid) { if (!this.uid) {
@ -391,7 +393,7 @@ export default class GachaLog extends base {
} }
} }
async getAllGcLogData () { async getAllGcLogData() {
this.model = 'gachaAllLog' this.model = 'gachaAllLog'
const poolList = ['角色', this.e?.isSr ? '光锥' : '武器', '常驻'] const poolList = ['角色', this.e?.isSr ? '光锥' : '武器', '常驻']
const logData = [] const logData = []
@ -428,7 +430,7 @@ export default class GachaLog extends base {
return data return data
} }
async getGcLogData () { async getGcLogData() {
/** 卡池 */ /** 卡池 */
this.getPool() this.getPool()
/** 更新记录 */ /** 更新记录 */
@ -440,7 +442,7 @@ export default class GachaLog extends base {
return data return data
} }
getPool () { getPool() {
let msg = this.e.msg.replace(/#|抽卡|记录|祈愿|分析|池|原神|星铁|崩坏星穹铁道|铁道/g, '') let msg = this.e.msg.replace(/#|抽卡|记录|祈愿|分析|池|原神|星铁|崩坏星穹铁道|铁道/g, '')
this.type = this.e.isSr ? 11 : 301 this.type = this.e.isSr ? 11 : 301
this.typeName = '角色' this.typeName = '角色'
@ -471,7 +473,7 @@ export default class GachaLog extends base {
} }
} }
async getUid () { async getUid() {
if (!fs.existsSync(this.path)) { if (!fs.existsSync(this.path)) {
this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true }) this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true })
return false return false
@ -521,7 +523,7 @@ export default class GachaLog extends base {
} }
/** 统计计算记录 */ /** 统计计算记录 */
analyse () { analyse() {
if (lodash.isEmpty(this.all)) { if (lodash.isEmpty(this.all)) {
this.all = this.readJson().list this.all = this.readJson().list
} }
@ -684,7 +686,7 @@ export default class GachaLog extends base {
} }
} }
checkIsUp () { checkIsUp() {
if (['莫娜', '七七', '迪卢克', '琴', '姬子', '杰帕德', '彦卿', '白露', '瓦尔特', '克拉拉', '布洛妮娅'].includes(this.role.name)) { if (['莫娜', '七七', '迪卢克', '琴', '姬子', '杰帕德', '彦卿', '白露', '瓦尔特', '克拉拉', '布洛妮娅'].includes(this.role.name)) {
return false return false
} }
@ -717,7 +719,7 @@ export default class GachaLog extends base {
} }
/** 渲染数据 */ /** 渲染数据 */
randData (data) { randData(data) {
let line = [] let line = []
let weapon = this.e.isSr ? '光锥' : '武器' let weapon = this.e.isSr ? '光锥' : '武器'
if ([301, 11].includes(this.type)) { if ([301, 11].includes(this.type)) {
@ -796,7 +798,7 @@ export default class GachaLog extends base {
} }
} }
getServer () { getServer() {
let uid = this.uid let uid = this.uid
switch (String(uid)[0]) { switch (String(uid)[0]) {
case '1': case '1':
@ -815,4 +817,4 @@ export default class GachaLog extends base {
} }
return 'cn_gf01' return 'cn_gf01'
} }
} }