适配亚服新UID (#364)

This commit is contained in:
Ca(HCO₃)₂ 2024-02-04 09:02:39 +08:00 committed by GitHub
parent 7636951048
commit 14e58fc4ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 176 additions and 154 deletions

View File

@ -46,7 +46,8 @@ export class gcLog extends plugin {
})
this.androidUrl = "https://docs.qq.com/doc/DUWpYaXlvSklmVXlX"
Object.defineProperty(this, "button", { get() {
Object.defineProperty(this, "button", {
get() {
this.prefix = this.e?.isSr ? "*" : "#"
return segment.button([
{ text: "角色记录", callback: `${this.prefix}角色记录` },
@ -58,7 +59,8 @@ export class gcLog extends plugin {
{ text: "常驻记录", callback: `${this.prefix}常驻记录` },
{ text: "常驻统计", callback: `${this.prefix}常驻统计` },
])
}})
}
})
}
async init() {
@ -73,7 +75,7 @@ export class gcLog extends plugin {
accept() {
if (this.e.file) {
let name = this.e.file?.name
if (/(.*)[1-9][0-9]{8}(.*).json/ig.test(name)) {
if (/(.*)([1-9]|18)[0-9]{8}(.*).json/ig.test(name)) {
this.e.msg = "#json文件导入记录"
return true
}

View File

@ -96,7 +96,13 @@ export class takeBirthdayPhoto extends plugin {
}
async getServer(uid) {
switch (String(uid)[0]) {
let uidPrefix = uid.toString()
if (uidPrefix.length == 10) {
uidPrefix = uidPrefix.slice(0, 2)
} else {
uidPrefix = uidPrefix.slice(0, 1)
}
switch (uidPrefix) {
case '1':
case '2':
return 'cn_gf01'
@ -107,6 +113,7 @@ export class takeBirthdayPhoto extends plugin {
case '7':
return 'os_euro'
case '8':
case '18':
return 'os_asia'
case '9':
return 'os_cht'

View File

@ -42,7 +42,7 @@ export class user extends plugin {
fnc: 'delUid'
},
{
reg: '^#(原神|星铁)?绑定(uid|UID)?\\s*[1-9][0-9]{8}$',
reg: '^#(原神|星铁)?绑定(uid|UID)?\\s*([1-9]|18)[0-9]{8}$',
fnc: 'bingUid'
},
{
@ -95,7 +95,7 @@ export class user extends plugin {
/** 绑定uid */
saveUid() {
if (!this.e.msg) return
let uid = this.e.msg.match(/[1|2|3|5-9][0-9]{8}/g)
let uid = this.e.msg.match(/([1-9]|18)[0-9]{8}/g)
if (!uid) {
this.reply('uid输入错误', false, { at: true })
return

View File

@ -182,7 +182,7 @@ export default class ExportLog extends base {
/** json导入抽卡记录 */
async logJson() {
let uid = /[1-9][0-9]{8}/g.exec(this.e.file.name)[0]
let uid = /([1-9]|18)[0-9]{8}/g.exec(this.e.file.name)[0]
let textPath = `${this.path}${this.e.file.name}`
/** 获取文件下载链接 */
let fileUrl = await this.e.friend.getFileUrl(this.e.file.fid)

View File

@ -164,7 +164,7 @@ class GsCfg {
}
getMsgUid(msg) {
let ret = /[1|2|5-9][0-9]{8}/g.exec(msg)
let ret = /([1-9]|18)[0-9]{8}/g.exec(msg)
if (!ret) return false
return ret[0]
}
@ -179,7 +179,7 @@ class GsCfg {
* @return uid 游戏uid
*/
getRole(msg, filterMsg = '', isSr = false) {
let alias = msg.replace(/#|老婆|老公|[1|2|3|5-9][0-9]{8}/g, '').trim()
let alias = msg.replace(/#|老婆|老公|([1-9]|18)[0-9]{8}/g, '').trim()
if (filterMsg) {
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
}
@ -260,7 +260,7 @@ class GsCfg {
// 仅供内部调用
_getRole(msg, filterMsg = '', isSr = false) {
let alias = msg.replace(/#|老婆|老公|[1|2|3|5-9][0-9]{8}/g, '').trim()
let alias = msg.replace(/#|老婆|老公|([1-9]|18)[0-9]{8}/g, '').trim()
if (filterMsg) {
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
}

View File

@ -431,7 +431,7 @@ export default class MysUser extends BaseModel {
return true
}
uid = '' + uid
if (/\d{9}/.test(uid)) {
if (/\d{9,10}/.test(uid)) {
let gameKey = this.gameKey(game)
let uids = this.uids[gameKey]
if (!uids.includes(uid)) {

View File

@ -50,8 +50,13 @@ export default class MysApi {
}
getServer() {
let uid = this.uid
switch (String(uid)[0]) {
let uidPrefix = this.uid.toString()
if (uidPrefix.length == 10) {
uidPrefix = uidPrefix.slice(0, 2)
} else {
uidPrefix = uidPrefix.slice(0, 1)
}
switch (uidPrefix) {
case '1':
case '2':
return this.isSr ? 'prod_gf_cn' : 'cn_gf01' // 官服
@ -62,6 +67,7 @@ export default class MysApi {
case '7':
return this.isSr ? 'prod_official_euro' : 'os_euro' // 欧服
case '8':
case '18':
return this.isSr ? 'prod_official_asia' : 'os_asia' // 亚服
case '9':
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服

View File

@ -55,11 +55,18 @@ export default class MysInfo {
return false
}
if (!['1', '2', '3', '5', '6', '7', '8', '9'].includes(String(mysInfo.uid)[0])) {
let uidPrefix = mysInfo.uid.toString()
if (uidPrefix.length == 10) {
uidPrefix = uidPrefix.slice(0, 2)
} else {
uidPrefix = uidPrefix.slice(0, 1)
}
if (!['1', '2', '3', '5', '6', '7', '8', '18', '9'].includes(uidPrefix)) {
// e.reply('只支持查询国服uid')
return false
}
if (!['6', '7', '8', '9'].includes(String(mysInfo.uid)[0]) && api === 'useCdk') {
if (!['6', '7', '8', '18', '9'].includes(uidPrefix) && api === 'useCdk') {
e.reply('兑换码使用只支持国际服uid')
return false
}
@ -103,7 +110,7 @@ export default class MysInfo {
}
let matchUid = (msg = '') => {
let ret = /[1235-9][0-9]{8}/g.exec(msg)
let ret = /([1-9]|18)[0-9]{8}/g.exec(msg)
if (!ret) return false
return ret[0]
}

View File

@ -197,7 +197,7 @@ export default class User extends base {
/** 绑定uid若有ck的话优先使用ck-uid */
async bingUid() {
let uid = this.e.msg.match(/[1|2|3|5-9][0-9]{8}/g)
let uid = this.e.msg.match(/([1-9]|18)[0-9]{8}/g)
if (!uid) return
uid = uid[0]
let user = await this.user()