Merge pull request #406 from AshenAshes/master

runtime适配星铁
This commit is contained in:
Ca(HCO₃)₂ 2024-04-05 11:21:49 +08:00 committed by GitHub
commit ba22480128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 targetType all: 所有用户均可 cookie查询用户必须具备Cookie
* @param option MysApi option * @param option MysApi option
* @param isSr 是否为星穹铁道
* @returns {Promise<boolean|MysApi>} * @returns {Promise<boolean|MysApi>}
*/ */
async getMysApi (targetType = 'all', option = {}) { async getMysApi (targetType = 'all', option = {}, isSr = false) {
let mys = await this.getMysInfo(targetType) let mys = await this.getMysInfo(targetType)
if (mys.uid && mys?.ckInfo?.ck) { 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 return false
} }
@ -153,10 +154,11 @@ export default class Runtime {
* @param uid * @param uid
* @param ck * @param ck
* @param option * @param option
* @param isSr 是否为星穹铁道
* @returns {Promise<MysApi>} * @returns {Promise<MysApi>}
*/ */
async createMysApi (uid, ck, option) { async createMysApi (uid, ck, option, isSr = false) {
return new MysApi(uid, ck, option) return new MysApi(uid, ck, option, isSr)
} }
/** /**

View File

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