[mock] Add OtherClient parameter to broadcastMsgSyncEvent

This commit is contained in:
Him188 2022-10-21 16:26:58 +01:00
parent 25e66d19c7
commit c1f7149aa7
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
3 changed files with 8 additions and 6 deletions

View File

@ -9,6 +9,7 @@
package net.mamoe.mirai.mock.contact package net.mamoe.mirai.mock.contact
import net.mamoe.mirai.contact.OtherClient
import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageChain
import net.mamoe.mirai.mock.MockBotDSL import net.mamoe.mirai.mock.MockBotDSL
@ -17,5 +18,5 @@ public interface MockMsgSyncSupport : MockContact {
* 广播消息同步事件 * 广播消息同步事件
*/ */
@MockBotDSL @MockBotDSL
public suspend fun broadcastMsgSyncEvent(message: MessageChain, time: Int) public suspend fun broadcastMsgSyncEvent(client: OtherClient, message: MessageChain, time: Int)
} }

View File

@ -14,6 +14,7 @@ package net.mamoe.mirai.mock.internal.contact
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import net.mamoe.mirai.contact.AvatarSpec import net.mamoe.mirai.contact.AvatarSpec
import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.Friend
import net.mamoe.mirai.contact.OtherClient
import net.mamoe.mirai.contact.friendgroup.FriendGroup import net.mamoe.mirai.contact.friendgroup.FriendGroup
import net.mamoe.mirai.contact.roaming.RoamingMessages import net.mamoe.mirai.contact.roaming.RoamingMessages
import net.mamoe.mirai.event.broadcast import net.mamoe.mirai.event.broadcast
@ -130,12 +131,12 @@ internal class MockFriendImpl(
return msg return msg
} }
override suspend fun broadcastMsgSyncEvent(message: MessageChain, time: Int) { override suspend fun broadcastMsgSyncEvent(client: OtherClient, message: MessageChain, time: Int) {
val src = newMsgSrc(true, message, time.toLong()) { ids, internalIds, time0 -> val src = newMsgSrc(true, message, time.toLong()) { ids, internalIds, time0 ->
OnlineMsgSrcToFriend(ids, internalIds, time0, message, bot, bot, this) OnlineMsgSrcToFriend(ids, internalIds, time0, message, bot, bot, this)
} }
val msg = src.withMessage(message) val msg = src.withMessage(message)
FriendMessageSyncEvent(this, msg, time).broadcast() FriendMessageSyncEvent(client, this, msg, time).broadcast()
} }
override fun toString(): String { override fun toString(): String {

View File

@ -317,19 +317,19 @@ internal class MockGroupImpl(
} }
} }
override suspend fun broadcastMsgSyncEvent(message: MessageChain, time: Int) { override suspend fun broadcastMsgSyncEvent(client: OtherClient, message: MessageChain, time: Int) {
val src = newMsgSrc(true, message, time.toLong()) { ids, internalIds, time0 -> val src = newMsgSrc(true, message, time.toLong()) { ids, internalIds, time0 ->
OnlineMsgSrcToGroup(ids, internalIds, time0, message, bot, bot, this) OnlineMsgSrcToGroup(ids, internalIds, time0, message, bot, bot, this)
} }
val msg = src.withMessage(message) val msg = src.withMessage(message)
GroupMessageSyncEvent(this, msg, botAsMember, bot.nick, time).broadcast() GroupMessageSyncEvent(client, this, msg, botAsMember, bot.nick, time).broadcast()
} }
override suspend fun sendMessage(message: Message): MessageReceipt<Group> { override suspend fun sendMessage(message: Message): MessageReceipt<Group> {
return super<AbstractMockContact>.sendMessage(message).cast() return super<AbstractMockContact>.sendMessage(message).cast()
} }
@Suppress("OverridingDeprecatedMember", "DEPRECATION", "DEPRECATION_ERROR", "OVERRIDE_DEPRECATION") @Suppress("OverridingDeprecatedMember", "DEPRECATION_ERROR", "OVERRIDE_DEPRECATION")
override suspend fun uploadVoice(resource: ExternalResource): net.mamoe.mirai.message.data.Voice = override suspend fun uploadVoice(resource: ExternalResource): net.mamoe.mirai.message.data.Voice =
resource.mockUploadVoice(bot) resource.mockUploadVoice(bot)