更新星铁1.4角色数据,逐步去除对V2 Yunzai的支持

This commit is contained in:
Kokomi 2023-10-11 02:29:04 +08:00
parent f81e3846d4
commit e57e8c85df
37 changed files with 8 additions and 109 deletions

View File

@ -7,21 +7,10 @@ import help from './help.js'
import admin from './admin.js' import admin from './admin.js'
import gacha from './gacha.js' import gacha from './gacha.js'
export const characterApp = character.v2App()
export const profileApp = profile.v2App()
export const adminApp = admin.v2App()
export const helpApp = help.v2App()
export const statApp = stat.v2App()
export const wikiApp = wiki.v2App()
export const pokeApp = poke.v2App()
export const gachaApp = gacha.v2App()
let apps = { character, poke, profile, stat, wiki, gacha, admin, help } let apps = { character, poke, profile, stat, wiki, gacha, admin, help }
let rule = {} // v2
let rules = {} // v3 let rules = {} // v3
for (let key in apps) { for (let key in apps) {
rule[`${key}App`] = apps[key].v2Rule()
rules[`${key}`] = apps[key].v3App() rules[`${key}`] = apps[key].v3App()
} }
export { rule, rules as apps } export { rules as apps }

View File

@ -20,32 +20,11 @@ const _getTargetUid = async function (e) {
} }
let uid = false let uid = false
let getUid = async function (qq) { let getUid = async function (qq) {
let nCookie = global.NoteCookie || false
if (nCookie && nCookie[qq]) {
let nc = nCookie[qq]
if (nc.uid && uidReg.test(nc.uid)) {
return nc.uid
}
}
uid = await redis.get(`genshin:id-uid:${qq}`) || await redis.get(`Yz:genshin:mys:qq-uid:${qq}`) uid = await redis.get(`genshin:id-uid:${qq}`) || await redis.get(`Yz:genshin:mys:qq-uid:${qq}`)
if (uid && uidReg.test(uid)) { if (uid && uidReg.test(uid)) {
return uid return uid
} }
} }
if (!Version.isV3) {
let botQQ = global?.Bot?.uin || global?.BotConfig?.account?.qq
if (e.at && e.at !== botQQ) {
uid = await getUid(e.at)
if (uid) {
return uid
}
}
uid = await getUid(e.user_id)
if (uid) {
return uid
}
}
try { try {
let user = await MysApi.initUser(e) let user = await MysApi.initUser(e)

View File

@ -124,69 +124,6 @@ class App {
} }
return cls return cls
} }
// 获取v2版rule
v2Rule () {
let cfg = this.cfg
return {
reg: 'noCheck',
describe: cfg.desc || '',
priority: cfg.priority || 50,
hashMark: true
}
}
// v2执行方法
v2App (e) {
let cfg = this.cfg || {}
let event = cfg.event
let apps = this.apps
return async function (e) {
e.original_msg = e.original_msg || e.msg
let msg = e.original_msg || e.msg || ''
for (let key in apps) {
let app = apps[key]
if (app.check && app.check(e, msg) === true) {
break
}
}
msg = e.msg
for (let key in apps) {
let app = apps[key]
let rule = app.rule || app.reg || 'noCheck'
if (app.rule) {
if (typeof (rule) === 'string') {
if (rule === '#poke#') {
continue
} else if (rule === 'noCheck') {
rule = /.*/
}
rule = new RegExp(rule)
}
if (rule.test(msg)) {
let ret = await app.fn(e, {})
if (ret === true) {
return true
}
} else if (app.yzRule && app.yzCheck()) {
rule = new RegExp(app.yzRule)
if (rule.test(msg)) {
let ret = await app.fn(e, {})
if (ret === true) {
return true
}
}
}
} else if (event === 'poke' && msg === '#poke#') {
let ret = await app.fn(e, {})
if (ret === true) {
return true
}
}
}
return false
}
}
} }
App.init = function (cfg) { App.init = function (cfg) {

View File

@ -2,7 +2,7 @@ import { Data, Version } from '#miao'
import fs from 'fs' import fs from 'fs'
if (!global.segment) { if (!global.segment) {
global.segment = (await import("oicq")).segment global.segment = (await import('oicq')).segment
} }
export * from './apps/index.js' export * from './apps/index.js'
@ -18,7 +18,7 @@ setTimeout(async function () {
let msgStr = await redis.get('miao:restart-msg') let msgStr = await redis.get('miao:restart-msg')
let relpyPrivate = async function () { let relpyPrivate = async function () {
} }
let common = await Data.importModule(Version.isV3 ? 'lib/common/common.js' : 'lib/common.js', 'root') let common = await Data.importModule('lib/common/common.js', 'root')
if (common && common.default && common.default.relpyPrivate) { if (common && common.default && common.default.relpyPrivate) {
relpyPrivate = common.default.relpyPrivate relpyPrivate = common.default.relpyPrivate
} }
@ -29,8 +29,11 @@ setTimeout(async function () {
let msgs = [`当前喵喵版本: ${Version.version}`, '您可使用 #喵喵版本 命令查看更新信息'] let msgs = [`当前喵喵版本: ${Version.version}`, '您可使用 #喵喵版本 命令查看更新信息']
await relpyPrivate(msg.qq, msgs.join('\n')) await relpyPrivate(msg.qq, msgs.join('\n'))
} }
if (!Version.isV3) {
console.log('警告miao-plugin需要V3 Yunzai请升级至最新版Miao-Yunzai以使用miao-plugin')
}
if (!fs.existsSync(process.cwd() + '/lib/plugins/runtime.js')) { if (!fs.existsSync(process.cwd() + '/lib/plugins/runtime.js')) {
let msg = '警告未检测到runtimemiao-plugin可能无法正常工作。请升级至最新版Yunzai以使用miao-plugin' let msg = '警告未检测到runtimemiao-plugin可能无法正常工作。请升级至最新版Miao-Yunzai以使用miao-plugin'
if (!await redis.get('miao:runtime-warning')) { if (!await redis.get('miao:runtime-warning')) {
await relpyPrivate(msg.qq, msg) await relpyPrivate(msg.qq, msg)
await redis.set('miao:runtime-warning', 'true', { EX: 3600 * 24 }) await redis.set('miao:runtime-warning', 'true', { EX: 3600 * 24 })

View File

@ -224,7 +224,7 @@ export default class ProfileRank {
add(user.qq, uid, type) add(user.qq, uid, type)
}) })
}) })
} else if (Version.isV3) { } else {
if (rn?.gsCfg?.getBingCk) { if (rn?.gsCfg?.getBingCk) {
// Yunzai-V3 // Yunzai-V3
let noteCks = await rn.gsCfg.getBingCk(game) || {} let noteCks = await rn.gsCfg.getBingCk(game) || {}
@ -235,15 +235,6 @@ export default class ProfileRank {
add(qq, uid, 'ck') add(qq, uid, 'ck')
}) })
} }
} else {
// V2
lodash.forEach(global.NoteCookie || {}, (ck) => {
const { qq, uid } = ck
if (!users[qq]) return true
if (qq && uid) {
add(qq, uid, 'ck')
}
})
} }
for (let qq in users) { for (let qq in users) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 12 KiB