diff --git a/mirai-core-api/src/commonMain/kotlin/IMirai.kt b/mirai-core-api/src/commonMain/kotlin/IMirai.kt index e29e958a3..42c12c63f 100644 --- a/mirai-core-api/src/commonMain/kotlin/IMirai.kt +++ b/mirai-core-api/src/commonMain/kotlin/IMirai.kt @@ -187,10 +187,12 @@ public interface IMirai : LowLevelApiAccessor { /** * 获取在线的 [OtherClient] 列表 + * @param mayIncludeSelf 服务器返回的列表可能包含 [Bot] 自己. [mayIncludeSelf] 为 `false` 会排除自己 */ @JvmBlockingBridge public suspend fun getOnlineOtherClientsList( bot: Bot, + mayIncludeSelf: Boolean = false ): List /** diff --git a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt index d4efbcd87..596d23e06 100644 --- a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt +++ b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt @@ -159,7 +159,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor { group.checkBotPermission(MemberPermission.ADMINISTRATOR) } - override suspend fun getOnlineOtherClientsList(bot: Bot): List { + override suspend fun getOnlineOtherClientsList(bot: Bot, mayIncludeSelf: Boolean): List { bot.asQQAndroidBot() val response = bot.network.run { StatSvc.GetDevLoginInfo(bot.client).sendAndExpect() @@ -172,7 +172,9 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor { deviceTypeInfo.orEmpty() ) - return response.deviceList.map { it.toOtherClientInfo() } + return response.deviceList.map { it.toOtherClientInfo() }.let { result -> + if (mayIncludeSelf) result else result.filterNot { it.appId == bot.client.protocol.id.toInt() } + } } override suspend fun ignoreMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean) {