This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03d62c5
commit 5f0cf95
Showing
5 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/SwitchAccount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package moe.fuqiuluo.shamrock.remote.action.handlers | ||
|
||
import kotlinx.serialization.json.JsonElement | ||
import moe.fuqiuluo.shamrock.remote.action.ActionSession | ||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler | ||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString | ||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher | ||
import mqq.app.MobileQQ | ||
|
||
internal object SwitchAccount: IActionHandler() { | ||
override suspend fun internalHandle(session: ActionSession): String { | ||
val userId = session.getString("user_id") | ||
return invoke(userId, session.echo) | ||
} | ||
|
||
operator fun invoke( | ||
userId: String, | ||
echo: JsonElement = EmptyJsonString | ||
): String { | ||
val account = MobileQQ.getMobileQQ().allAccounts.firstOrNull { it.uin == userId } | ||
?: return error("账号不存在", echo) | ||
val runtime = AppRuntimeFetcher.appRuntime | ||
val result = kotlin.runCatching { | ||
runtime.switchAccount(account, null) | ||
} | ||
if (result.isFailure) { | ||
return error(result.exceptionOrNull()?.message ?: "切换账号失败", echo) | ||
} | ||
return ok("切换成功", echo) | ||
} | ||
|
||
override val requiredParams: Array<String> = arrayOf("user_id") | ||
|
||
override fun path(): String = "switch_account" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters