[Review] LowLevelApiAccessor:

- Rename method names, remove "_lowLevel"
- Add blocking bridges
This commit is contained in:
Him188 2021-01-06 14:58:06 +08:00
parent 1f0d8363f6
commit 1215a56775
7 changed files with 75 additions and 79 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 Mamoe Technologies and contributors. * Copyright 2019-2021 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -10,6 +10,7 @@
package net.mamoe.mirai package net.mamoe.mirai
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.mamoe.kjbb.JvmBlockingBridge
import net.mamoe.mirai.contact.AnonymousMember import net.mamoe.mirai.contact.AnonymousMember
import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.Friend
import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.Group
@ -33,14 +34,10 @@ import kotlin.annotation.AnnotationTarget.*
public annotation class LowLevelApi public annotation class LowLevelApi
/** /**
* [Bot] 相关协议层低级 API. * [IMirai] 协议层低级 API.
*
* **注意**: 不应该把这个类作为一个类型, 只应使用其中的方法
* *
* **警告**: 所有的低级 API 都可能在任意时刻不经过任何警告和迭代就被修改. 因此非常不建议在任何情况下使用这些 API. * **警告**: 所有的低级 API 都可能在任意时刻不经过任何警告和迭代就被修改. 因此非常不建议在任何情况下使用这些 API.
*/ */
@MiraiExperimentalApi
@Suppress("FunctionName", "unused")
@LowLevelApi @LowLevelApi
public interface LowLevelApiAccessor { public interface LowLevelApiAccessor {
/** /**
@ -50,7 +47,7 @@ public interface LowLevelApiAccessor {
* 因此, [Bot] 被关闭后, 这个对象也会被关闭. * 因此, [Bot] 被关闭后, 这个对象也会被关闭.
*/ */
@LowLevelApi @LowLevelApi
public fun _lowLevelNewFriend(bot: Bot, friendInfo: FriendInfo): Friend public fun newFriend(bot: Bot, friendInfo: FriendInfo): Friend
/** /**
* 构造一个 [Stranger] 对象. 它持有对 [Bot] 的弱引用([WeakRef]). * 构造一个 [Stranger] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
@ -59,13 +56,14 @@ public interface LowLevelApiAccessor {
* 因此, [Bot] 被关闭后, 这个对象也会被关闭. * 因此, [Bot] 被关闭后, 这个对象也会被关闭.
*/ */
@LowLevelApi @LowLevelApi
public fun _lowLevelNewStranger(bot: Bot, strangerInfo: StrangerInfo): Stranger public fun newStranger(bot: Bot, strangerInfo: StrangerInfo): Stranger
/** /**
* 向服务器查询群列表. 返回值高 32 bits uin, 32 bits groupCode * 向服务器查询群列表. 返回值高 32 bits uin, 32 bits groupCode
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelQueryGroupList(bot: Bot): Sequence<Long> @JvmBlockingBridge
public suspend fun getRawGroupList(bot: Bot): Sequence<Long>
/** /**
* 向服务器查询群成员列表. * 向服务器查询群成员列表.
@ -73,10 +71,11 @@ public interface LowLevelApiAccessor {
* *
* 这个函数很慢. 请不要频繁使用. * 这个函数很慢. 请不要频繁使用.
* *
* @see Group.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin * @see IMirai.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelQueryGroupMemberList( @JvmBlockingBridge
public suspend fun getRawGroupMemberList(
bot: Bot, bot: Bot,
groupUin: Long, groupUin: Long,
groupCode: Long, groupCode: Long,
@ -89,9 +88,12 @@ public interface LowLevelApiAccessor {
*/ */
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelGetAnnouncements( @JvmBlockingBridge
public suspend fun getRawGroupAnnouncements(
bot: Bot, bot: Bot,
groupId: Long, page: Int = 1, amount: Int = 10 groupId: Long,
page: Int = 1,
amount: Int = 10
): GroupAnnouncementList ): GroupAnnouncementList
/** /**
@ -100,10 +102,12 @@ public interface LowLevelApiAccessor {
* @return 公告的fid * @return 公告的fid
*/ */
@LowLevelApi @LowLevelApi
@JvmBlockingBridge
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelSendAnnouncement( public suspend fun sendGroupAnnouncement(
bot: Bot, bot: Bot,
groupId: Long, announcement: GroupAnnouncement groupId: Long,
announcement: GroupAnnouncement
): String ): String
@ -112,10 +116,12 @@ public interface LowLevelApiAccessor {
* @param fid [GroupAnnouncement.fid] * @param fid [GroupAnnouncement.fid]
*/ */
@LowLevelApi @LowLevelApi
@JvmBlockingBridge
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelDeleteAnnouncement( public suspend fun deleteGroupAnnouncement(
bot: Bot, bot: Bot,
groupId: Long, fid: String groupId: Long,
fid: String
) )
/** /**
@ -123,10 +129,12 @@ public interface LowLevelApiAccessor {
* @param fid [GroupAnnouncement.fid] * @param fid [GroupAnnouncement.fid]
*/ */
@LowLevelApi @LowLevelApi
@JvmBlockingBridge
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelGetAnnouncement( public suspend fun getGroupAnnouncement(
bot: Bot, bot: Bot,
groupId: Long, fid: String groupId: Long,
fid: String
): GroupAnnouncement ): GroupAnnouncement
@ -136,8 +144,9 @@ public interface LowLevelApiAccessor {
* page从0开始传入可以得到发言列表 * page从0开始传入可以得到发言列表
*/ */
@LowLevelApi @LowLevelApi
@JvmBlockingBridge
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelGetGroupActiveData(bot: Bot, groupId: Long, page: Int = -1): GroupActiveData public suspend fun getRawGroupActiveData(bot: Bot, groupId: Long, page: Int = -1): GroupActiveData
/** /**
@ -145,7 +154,8 @@ public interface LowLevelApiAccessor {
*/ */
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
public suspend fun _lowLevelGetGroupHonorListData( @JvmBlockingBridge
public suspend fun getRawGroupHonorListData(
bot: Bot, bot: Bot,
groupId: Long, groupId: Long,
type: GroupHonorType type: GroupHonorType
@ -155,8 +165,9 @@ public interface LowLevelApiAccessor {
/** /**
* 处理一个账号请求添加机器人为好友的事件 * 处理一个账号请求添加机器人为好友的事件
*/ */
@JvmBlockingBridge
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelSolveNewFriendRequestEvent( public suspend fun solveNewFriendRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
@ -169,7 +180,8 @@ public interface LowLevelApiAccessor {
* 处理被邀请加入一个群请求事件 * 处理被邀请加入一个群请求事件
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelSolveBotInvitedJoinGroupRequestEvent( @JvmBlockingBridge
public suspend fun solveBotInvitedJoinGroupRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
invitorId: Long, invitorId: Long,
@ -181,7 +193,8 @@ public interface LowLevelApiAccessor {
* 处理账号请求加入群事件 * 处理账号请求加入群事件
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelSolveMemberJoinRequestEvent( @JvmBlockingBridge
public suspend fun solveMemberJoinRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
@ -196,30 +209,22 @@ public interface LowLevelApiAccessor {
* 查询语音的下载连接 * 查询语音的下载连接
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelQueryGroupVoiceDownloadUrl( @JvmBlockingBridge
public suspend fun getGroupVoiceDownloadUrl(
bot: Bot, bot: Bot,
md5: ByteArray, md5: ByteArray,
groupId: Long, groupId: Long,
dstUin: Long dstUin: Long
): String ): String
/**
* 查询语音的上传连接
*/
@LowLevelApi
public suspend fun _lowLevelUploadVoice(
bot: Bot,
md5: ByteArray,
groupId: Long,
)
/** /**
* 禁言一个匿名用户 * 禁言一个匿名用户
* *
* @param anonymousId [AnonymousMember.anonymousId] * @param anonymousId [AnonymousMember.anonymousId]
*/ */
@LowLevelApi @LowLevelApi
public suspend fun _lowLevelMuteAnonymous( @JvmBlockingBridge
public suspend fun muteAnonymousMember(
bot: Bot, bot: Bot,
anonymousId: String, anonymousId: String,
anonymousNick: String, anonymousNick: String,

View File

@ -127,7 +127,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
"the request $event is outdated: You had already responded it on another device." "the request $event is outdated: You had already responded it on another device."
} }
_lowLevelSolveNewFriendRequestEvent( solveNewFriendRequestEvent(
event.bot, event.bot,
eventId = event.eventId, eventId = event.eventId,
fromId = event.fromId, fromId = event.fromId,
@ -147,7 +147,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
"the request $event is outdated: You had already responded it on another device." "the request $event is outdated: You had already responded it on another device."
} }
_lowLevelSolveNewFriendRequestEvent( solveNewFriendRequestEvent(
event.bot, event.bot,
eventId = event.eventId, eventId = event.eventId,
fromId = event.fromId, fromId = event.fromId,
@ -167,7 +167,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
if (event.group?.contains(event.fromId) == true) return if (event.group?.contains(event.fromId) == true) return
_lowLevelSolveMemberJoinRequestEvent( solveMemberJoinRequestEvent(
bot = event.bot, bot = event.bot,
eventId = event.eventId, eventId = event.eventId,
fromId = event.fromId, fromId = event.fromId,
@ -188,7 +188,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
if (event.group?.contains(event.fromId) == true) return if (event.group?.contains(event.fromId) == true) return
_lowLevelSolveMemberJoinRequestEvent( solveMemberJoinRequestEvent(
bot = event.bot, bot = event.bot,
eventId = event.eventId, eventId = event.eventId,
fromId = event.fromId, fromId = event.fromId,
@ -238,7 +238,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
"the request $this has already been responded" "the request $this has already been responded"
} }
_lowLevelSolveMemberJoinRequestEvent( solveMemberJoinRequestEvent(
bot = event.bot, bot = event.bot,
eventId = event.eventId, eventId = event.eventId,
fromId = event.fromId, fromId = event.fromId,
@ -266,7 +266,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
"the request $this is outdated: Bot has been already in the group." "the request $this is outdated: Bot has been already in the group."
} }
_lowLevelSolveBotInvitedJoinGroupRequestEvent( solveBotInvitedJoinGroupRequestEvent(
bot = event.bot, bot = event.bot,
eventId = event.eventId, eventId = event.eventId,
invitorId = event.invitorId, invitorId = event.invitorId,
@ -276,7 +276,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
} }
@LowLevelApi @LowLevelApi
override fun _lowLevelNewFriend(bot: Bot, friendInfo: FriendInfo): Friend { override fun newFriend(bot: Bot, friendInfo: FriendInfo): Friend {
return FriendImpl( return FriendImpl(
bot.asQQAndroidBot(), bot.asQQAndroidBot(),
bot.coroutineContext + SupervisorJob(bot.supervisorJob), bot.coroutineContext + SupervisorJob(bot.supervisorJob),
@ -285,7 +285,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
} }
@LowLevelApi @LowLevelApi
override fun _lowLevelNewStranger(bot: Bot, strangerInfo: StrangerInfo): Stranger { override fun newStranger(bot: Bot, strangerInfo: StrangerInfo): Stranger {
return StrangerImpl( return StrangerImpl(
bot.asQQAndroidBot(), bot.asQQAndroidBot(),
bot.coroutineContext + SupervisorJob(bot.supervisorJob), bot.coroutineContext + SupervisorJob(bot.supervisorJob),
@ -295,7 +295,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@OptIn(LowLevelApi::class) @OptIn(LowLevelApi::class)
override suspend fun _lowLevelQueryGroupList(bot: Bot): Sequence<Long> { override suspend fun getRawGroupList(bot: Bot): Sequence<Long> {
bot.asQQAndroidBot() bot.asQQAndroidBot()
return bot.network.run { return bot.network.run {
FriendList.GetTroopListSimplify(bot.client) FriendList.GetTroopListSimplify(bot.client)
@ -304,7 +304,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
} }
@OptIn(LowLevelApi::class) @OptIn(LowLevelApi::class)
override suspend fun _lowLevelQueryGroupMemberList( override suspend fun getRawGroupMemberList(
bot: Bot, bot: Bot,
groupUin: Long, groupUin: Long,
groupCode: Long, groupCode: Long,
@ -445,7 +445,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelGetAnnouncements( override suspend fun getRawGroupAnnouncements(
bot: Bot, bot: Bot,
groupId: Long, groupId: Long,
page: Int, page: Int,
@ -477,7 +477,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelSendAnnouncement(bot: Bot, groupId: Long, announcement: GroupAnnouncement): String = override suspend fun sendGroupAnnouncement(bot: Bot, groupId: Long, announcement: GroupAnnouncement): String =
bot.asQQAndroidBot().run { bot.asQQAndroidBot().run {
val rep = withContext(network.coroutineContext) { val rep = withContext(network.coroutineContext) {
Mirai.Http.post<String> { Mirai.Http.post<String> {
@ -514,7 +514,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelDeleteAnnouncement(bot: Bot, groupId: Long, fid: String) = bot.asQQAndroidBot().run { override suspend fun deleteGroupAnnouncement(bot: Bot, groupId: Long, fid: String) = bot.asQQAndroidBot().run {
val data = withContext(network.coroutineContext) { val data = withContext(network.coroutineContext) {
Mirai.Http.post<String> { Mirai.Http.post<String> {
url("https://web.qun.qq.com/cgi-bin/announce/del_feed") url("https://web.qun.qq.com/cgi-bin/announce/del_feed")
@ -543,7 +543,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelGetAnnouncement(bot: Bot, groupId: Long, fid: String): GroupAnnouncement = override suspend fun getGroupAnnouncement(bot: Bot, groupId: Long, fid: String): GroupAnnouncement =
bot.asQQAndroidBot().run { bot.asQQAndroidBot().run {
val rep = network.run { val rep = network.run {
Mirai.Http.post<String> { Mirai.Http.post<String> {
@ -570,7 +570,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelGetGroupActiveData(bot: Bot, groupId: Long, page: Int): GroupActiveData = override suspend fun getRawGroupActiveData(bot: Bot, groupId: Long, page: Int): GroupActiveData =
bot.asQQAndroidBot().run { bot.asQQAndroidBot().run {
val rep = network.run { val rep = network.run {
Mirai.Http.get<String> { Mirai.Http.get<String> {
@ -593,7 +593,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelGetGroupHonorListData( override suspend fun getRawGroupHonorListData(
bot: Bot, bot: Bot,
groupId: Long, groupId: Long,
type: GroupHonorType type: GroupHonorType
@ -719,7 +719,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelSolveNewFriendRequestEvent( override suspend fun solveNewFriendRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
@ -736,13 +736,13 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
blackList = blackList blackList = blackList
).sendWithoutExpect() ).sendWithoutExpect()
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
bot.friends.delegate.add(_lowLevelNewFriend(bot, FriendInfoImpl(fromId, fromNick, ""))) bot.friends.delegate.add(newFriend(bot, FriendInfoImpl(fromId, fromNick, "")))
} }
} }
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelSolveBotInvitedJoinGroupRequestEvent( override suspend fun solveBotInvitedJoinGroupRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
invitorId: Long, invitorId: Long,
@ -763,7 +763,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@LowLevelApi @LowLevelApi
@MiraiExperimentalApi @MiraiExperimentalApi
override suspend fun _lowLevelSolveMemberJoinRequestEvent( override suspend fun solveMemberJoinRequestEvent(
bot: Bot, bot: Bot,
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
@ -803,7 +803,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
@OptIn(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
@LowLevelApi @LowLevelApi
override suspend fun _lowLevelQueryGroupVoiceDownloadUrl( override suspend fun getGroupVoiceDownloadUrl(
bot: Bot, bot: Bot,
md5: ByteArray, md5: ByteArray,
groupId: Long, groupId: Long,
@ -816,12 +816,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
} }
} }
@LowLevelApi override suspend fun muteAnonymousMember(
override suspend fun _lowLevelUploadVoice(bot: Bot, md5: ByteArray, groupId: Long) {
}
override suspend fun _lowLevelMuteAnonymous(
bot: Bot, bot: Bot,
anonymousId: String, anonymousId: String,
anonymousNick: String, anonymousNick: String,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 Mamoe Technologies and contributors. * Copyright 2019-2021 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -77,7 +77,7 @@ internal class QQAndroidBot constructor(
override val asFriend: Friend by lazy { override val asFriend: Friend by lazy {
@OptIn(LowLevelApi::class) @OptIn(LowLevelApi::class)
Mirai._lowLevelNewFriend(this, FriendInfoImpl(uin, nick, "")) Mirai.newFriend(this, FriendInfoImpl(uin, nick, ""))
} }
override val groups: ContactList<Group> = ContactList() override val groups: ContactList<Group> = ContactList()
@ -117,7 +117,7 @@ internal class QQAndroidBot constructor(
get() = client.wLoginSigInfo.sKey.data get() = client.wLoginSigInfo.sKey.data
.fold(5381) { acc: Int, b: Byte -> acc + acc.shl(5) + b.toInt() } .fold(5381) { acc: Int, b: Byte -> acc + acc.shl(5) + b.toInt() }
.and(Int.MAX_VALUE) .and(Int.MAX_VALUE)
override val asStranger: Stranger by lazy { Mirai._lowLevelNewStranger(bot, StrangerInfoImpl(bot.id, bot.nick)) } override val asStranger: Stranger by lazy { Mirai.newStranger(bot, StrangerInfoImpl(bot.id, bot.nick)) }
override val strangers: ContactList<Stranger> = ContactList() override val strangers: ContactList<Stranger> = ContactList()
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 Mamoe Technologies and contributors. * Copyright 2019-2021 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -33,7 +33,7 @@ internal class AnonymousMemberImpl(
override suspend fun mute(durationSeconds: Int) { override suspend fun mute(durationSeconds: Int) {
checkBotPermissionHigherThanThis("mute") checkBotPermissionHigherThanThis("mute")
MiraiImpl._lowLevelMuteAnonymous(bot, anonymousId, nameCard, group.uin, durationSeconds) MiraiImpl.muteAnonymousMember(bot, anonymousId, nameCard, group.uin, durationSeconds)
} }
override fun toString(): String = "AnonymousMember($nameCard, $anonymousId)" override fun toString(): String = "AnonymousMember($nameCard, $anonymousId)"

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 Mamoe Technologies and contributors. * Copyright 2019-2021 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -343,7 +343,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
coroutineContext = bot.coroutineContext, coroutineContext = bot.coroutineContext,
id = groupCode, id = groupCode,
groupInfo = GroupInfoImpl(this), groupInfo = GroupInfoImpl(this),
members = Mirai._lowLevelQueryGroupMemberList( members = Mirai.getRawGroupMemberList(
bot, bot,
groupUin, groupUin,
groupCode, groupCode,

View File

@ -527,7 +527,7 @@ internal suspend fun MsgComm.Msg.transform(bot: QQAndroidBot): Packet? {
val nick = sequenceOf(msgHead.fromNick, msgHead.authNick, pbNick).filter { it.isNotEmpty() }.firstOrNull() val nick = sequenceOf(msgHead.fromNick, msgHead.authNick, pbNick).filter { it.isNotEmpty() }.firstOrNull()
?: return null ?: return null
val id = sequenceOf(msgHead.fromUin, msgHead.authUin).filter { it != 0L }.firstOrNull() ?: return null//对方QQ val id = sequenceOf(msgHead.fromUin, msgHead.authUin).filter { it != 0L }.firstOrNull() ?: return null//对方QQ
Mirai._lowLevelNewStranger(bot, StrangerInfoImpl(id, nick, fromGroup)).let { Mirai.newStranger(bot, StrangerInfoImpl(id, nick, fromGroup)).let {
bot.getStranger(id)?.let { previous -> bot.getStranger(id)?.let { previous ->
bot.strangers.remove(id) bot.strangers.remove(id)
StrangerRelationChangeEvent.Deleted(previous).broadcast() StrangerRelationChangeEvent.Deleted(previous).broadcast()
@ -566,7 +566,7 @@ internal suspend fun QQAndroidBot.getNewGroup(groupCode: Long): Group? {
coroutineContext = coroutineContext, coroutineContext = coroutineContext,
id = groupCode, id = groupCode,
groupInfo = GroupInfoImpl(troopNum), groupInfo = GroupInfoImpl(troopNum),
members = Mirai._lowLevelQueryGroupMemberList( members = Mirai.getRawGroupMemberList(
this, this,
troopNum.groupUin, troopNum.groupUin,
troopNum.groupCode, troopNum.groupCode,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 Mamoe Technologies and contributors. * Copyright 2019-2021 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -14,13 +14,9 @@
package net.mamoe.mirai.internal.network.protocol.packet.chat.receive package net.mamoe.mirai.internal.network.protocol.packet.chat.receive
import kotlinx.io.core.*
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.*
import kotlinx.io.core.discardExact
import kotlinx.io.core.readBytes
import kotlinx.io.core.readUInt
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
import net.mamoe.mirai.JavaFriendlyAPI import net.mamoe.mirai.JavaFriendlyAPI
@ -494,7 +490,7 @@ internal object Transformers528 : Map<Long, Lambda528> by mapOf(
0xB3L to lambda528 { bot -> 0xB3L to lambda528 { bot ->
// 08 01 12 52 08 A2 FF 8C F0 03 10 00 1D 15 3D 90 5E 22 2E E6 88 91 E4 BB AC E5 B7 B2 E7 BB 8F E6 98 AF E5 A5 BD E5 8F 8B E5 95 A6 EF BC 8C E4 B8 80 E8 B5 B7 E6 9D A5 E8 81 8A E5 A4 A9 E5 90 A7 21 2A 09 48 69 6D 31 38 38 6D 6F 65 30 07 38 03 48 DD F1 92 B7 07 // 08 01 12 52 08 A2 FF 8C F0 03 10 00 1D 15 3D 90 5E 22 2E E6 88 91 E4 BB AC E5 B7 B2 E7 BB 8F E6 98 AF E5 A5 BD E5 8F 8B E5 95 A6 EF BC 8C E4 B8 80 E8 B5 B7 E6 9D A5 E8 81 8A E5 A4 A9 E5 90 A7 21 2A 09 48 69 6D 31 38 38 6D 6F 65 30 07 38 03 48 DD F1 92 B7 07
val body = vProtobuf.loadAs(Submsgtype0xb3.SubMsgType0xb3.MsgBody.serializer()) val body = vProtobuf.loadAs(Submsgtype0xb3.SubMsgType0xb3.MsgBody.serializer())
val new = Mirai._lowLevelNewFriend( val new = Mirai.newFriend(
bot, FriendInfoImpl( bot, FriendInfoImpl(
uin = body.msgAddFrdNotify.fuin, uin = body.msgAddFrdNotify.fuin,
nick = body.msgAddFrdNotify.fuinNick, nick = body.msgAddFrdNotify.fuinNick,