瀏覽代碼

[mock] Add `OtherClient` parameter to `broadcastMsgSyncEvent`

(cherry picked from commit c1f7149aa718153a31131161f4c780aed94259b6)
Him188 3 年之前
父節點
當前提交
625e6568fc

+ 2 - 1
mirai-core-mock/src/contact/MockMsgSyncSupport.kt

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

+ 3 - 2
mirai-core-mock/src/internal/contact/MockFriendImpl.kt

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

+ 3 - 3
mirai-core-mock/src/internal/contact/MockGroupImpl.kt

@@ -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 ->
             OnlineMsgSrcToGroup(ids, internalIds, time0, message, bot, bot, this)
         }
         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> {
         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 =
         resource.mockUploadVoice(bot)