runtime适配星铁

This commit is contained in:
Aluxes 2024-04-05 07:55:38 +08:00
parent 134d1cbb37
commit 61f513ac39
No known key found for this signature in database
GPG Key ID: 6696152F9C003087
2 changed files with 43 additions and 35 deletions

View File

@ -138,12 +138,13 @@ export default class Runtime {
*
* @param targetType all: 所有用户均可 cookie查询用户必须具备Cookie
* @param option MysApi option
* @param isSr 是否为星穹铁道
* @returns {Promise<boolean|MysApi>}
*/
async getMysApi (targetType = 'all', option = {}) {
async getMysApi (targetType = 'all', option = {}, isSr = false) {
let mys = await this.getMysInfo(targetType)
if (mys.uid && mys?.ckInfo?.ck) {
return new MysApi(mys.uid, mys.ckInfo.ck, option)
return new MysApi(mys.uid, mys.ckInfo.ck, option, isSr)
}
return false
}
@ -153,10 +154,11 @@ export default class Runtime {
* @param uid
* @param ck
* @param option
* @param isSr 是否为星穹铁道
* @returns {Promise<MysApi>}
*/
async createMysApi (uid, ck, option) {
return new MysApi(uid, ck, option)
async createMysApi (uid, ck, option, isSr = false) {
return new MysApi(uid, ck, option, isSr)
}
/**

View File

@ -29,7 +29,7 @@ export default class MysInfo {
this.gtest = false
this.mysButton = segment.button([
{ text: "米游社", link: "https://miyoushe.com" },
{ text: '米游社', link: 'https://miyoushe.com' }
])
}
@ -96,9 +96,11 @@ export default class MysInfo {
let atUser = await NoteUser.create(at)
uid = atUser.getUid(e)
if (uid) return String(uid)
if (e.noTips !== true) e.reply(['尚未绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
if (e.noTips !== true) {
e.reply(['尚未绑定uid', segment.button([
{ text: '绑定UID', input: '#绑定uid' }
])], false, { at })
}
return false
}
@ -116,9 +118,11 @@ export default class MysInfo {
return user.autoRegUid(uid, e)
}
if (e.noTips !== true) e.reply(['请先#绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
if (e.noTips !== true) {
e.reply(['请先#绑定uid', segment.button([
{ text: '绑定UID', input: '#绑定uid' }
])], false, { at: at || true })
}
return false
}
@ -136,9 +140,11 @@ export default class MysInfo {
let selfUser = at ? await NoteUser.create(at) : user
if (!selfUser.hasCk) {
if (e.noTips !== true) e.reply(['尚未绑定Cookie', segment.button([
{ text: "Cookie帮助", callback: "#Cookie帮助" },
if (e.noTips !== true) {
e.reply(['尚未绑定Cookie', segment.button([
{ text: 'Cookie帮助', callback: '#Cookie帮助' }
])], false, { at: selfUser.qq })
}
return false
}
@ -314,13 +320,13 @@ export default class MysInfo {
if (!this.uid) {
this.e.reply(['请先#绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
{ text: '绑定UID', input: '#绑定uid' }
])], false, { at: true })
}
if (!this.ckInfo.ck) {
this.e.reply(['暂无可用CK请绑定更多用户或设置公共ck..', segment.button([
{ text: "Cookie帮助", callback: "#Cookie帮助" },
{ text: 'Cookie帮助', callback: '#Cookie帮助' }
])])
}
@ -340,7 +346,7 @@ export default class MysInfo {
let mysUser = await MysUser.getByQueryUid(this.uid, game, onlySelfCk)
if (mysUser) {
if (mysUser.ck) {
this.ckInfo = mysUser.getCkInfo()
this.ckInfo = mysUser.getCkInfo(game)
this.ckUser = mysUser
// 暂时直接记录请求uid后期优化分析MysApi请求结果分状态记录结果
await mysUser.addQueryUid(this.uid, game)