Преглед на файлове

Merge remote-tracking branch 'origin/dev' into dev

mzdluo123 преди 5 години
родител
ревизия
4b26d4d2c2

+ 20 - 0
CHANGELOG.md

@@ -1,5 +1,22 @@
 # Version 1.x
 
+## `1.1.0`  2020/7/9
+- 支持 Android 手表协议 (`BotConfiguration.MiraiProtocol.ANDROID_PAD`)
+- `EventHandler` 现在支持 `Nothing` 类型.
+- 修复无需同意直接进群时,在加载新群信息完成前收到消息过早处理的问题 (#370)
+- 修复在某些情况下,管理员邀请群Bot加群会被误判为群成员申请加群的问题 (#402 by [@kenvix](https://github.com/kenvix))
+- 修复从其他客户端加群时未同步的问题 (#404, #410)
+- 修复 `ConfigPushSvc.PushReq` 解析失败的问题 (#417)
+- 修复 `_lowLevelGetGroupActiveData`
+- 修复 `SimpleListenerHost.coroutineScope` 潜在的 Job 被覆盖的问题
+
+## `1.0.4` 2020/7/2
+- 修复上传图片失败时内存泄露的问题 (#385)
+- 修复大量图片同时上传时出错的问题 (#387)
+- 修复在一些情况下 BotOfflineEvent 没有正常处理而无法继续接收消息的问题 (#376)
+- 修复 Bot 在某个群 T 出某个人导致 Bot 终止的问题 (#372)
+- 修复 `@PlannedRemoval` 的文档
+
 ## `1.1-EA2` 2020/7/2
 
 - 添加 `BotConfiguration.json`, 作为序列化时使用的 Json format, 修复潜在的因 kotlinx.serialization 进行不兼容更新而导致的不兼容.
@@ -11,6 +28,9 @@
 - ([1.0.4](https://github.com/mamoe/mirai/releases/tag/1.0.4) 中修复的问题)
 - ([1.0.3](https://github.com/mamoe/mirai/releases/tag/1.0.3) 中修复的问题)
 
+## `1.0.3` 2020/6/29
+- 修复 friendlist.GetTroopListReqV2:java.lang.IllegalStateException: type mismatch 10 (#405)
+
 ## `1.1-EA` 2020/6/16
 
 **主要**:

+ 1 - 1
buildSrc/src/main/kotlin/Versions.kt

@@ -9,7 +9,7 @@
 
 object Versions {
     object Mirai {
-        const val version = "1.1-EA2"
+        const val version = "1.1.0"
     }
 
     object Kotlin {

+ 11 - 13
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt

@@ -148,22 +148,22 @@ internal class NewContact {
                 return struct?.msg?.run {
                     //this.soutv("SystemMsg")
                     when (subType) {
-                        1 -> { //管理员邀
-                            when (c2cInviteJoinGroupFlag) {
+                        1 -> { // 处理被邀请入群 或 处理成员入群申
+                            when (groupMsgType) {
                                 1 -> {
-                                    // 被邀请入群
-                                    BotInvitedJoinGroupRequestEvent(
-                                        bot, struct.msgSeq, actionUin,
-                                        groupCode, groupName, actionUinNick
-                                    )
-                                }
-                                0 -> {
                                     // 成员申请入群
                                     MemberJoinRequestEvent(
                                         bot, struct.msgSeq, msgAdditional,
                                         struct.reqUin, groupCode, groupName, reqUinNick
                                     )
                                 }
+                                2 -> {
+                                    // 被邀请入群
+                                    BotInvitedJoinGroupRequestEvent(
+                                        bot, struct.msgSeq, actionUin,
+                                        groupCode, groupName, actionUinNick
+                                    )
+                                }
                                 else -> throw contextualBugReportException(
                                     "parse SystemMsgNewGroup, subType=1",
                                     this._miraiContentToString(),
@@ -171,16 +171,14 @@ internal class NewContact {
                                 )
                             }
                         }
-                        2 -> {
-                            // 被邀请入群, 自动同意
+                        2 -> { // 被邀请入群, 自动同意, 不需处理
 
                             val group = bot.getNewGroup(groupCode) ?: return null
                             val invitor = group[actionUin]
 
                             BotJoinGroupEvent.Invite(invitor)
                         }
-                        3 -> {
-                            // 已被请他管理员处理
+                        3 -> { // 已被请他管理员处理
                             null
                         }
                         5 -> {

+ 15 - 0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt

@@ -44,6 +44,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
 import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.GroupInfoImpl
 import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.NewContact
 import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
+import net.mamoe.mirai.qqandroid.utils._miraiContentToString
 import net.mamoe.mirai.qqandroid.utils.io.serialization.readProtoBuf
 import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
 import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
@@ -190,6 +191,20 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
                     34 -> { // 与 33 重复
                         return@mapNotNull null
                     }
+
+                    85 -> bot.groupListModifyLock.withLock { // 其他客户端入群
+                        val group = bot.getGroupByUinOrNull(msg.msgHead.fromUin)
+                        if (msg.msgHead.toUin == bot.id && group == null) {
+
+                            val newGroup = bot.getNewGroup(Group.calculateGroupCodeByGroupUin(msg.msgHead.fromUin))
+                                ?: return@mapNotNull null
+                            bot.groups.delegate.addLast(newGroup)
+                            return@mapNotNull BotJoinGroupEvent.Active(newGroup)
+                        } else {
+                            // unknown
+                            return@mapNotNull null
+                        }
+                    }
                     /*
                     34 -> { // 主动入群
 

+ 3 - 1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.ReqPush.kt

@@ -81,7 +81,9 @@ internal object OnlinePushReqPush : IncomingPacketFactory<OnlinePushReqPush.ReqP
         val packets: Sequence<Packet> = reqPushMsg.vMsgInfos.deco(bot.client) { msgInfo ->
             when (msgInfo.shMsgType.toInt()) {
                 732 -> {
-                    val group = bot.getGroup(readUInt().toLong())
+                    val group = bot.getGroupOrNull(readUInt().toLong())
+                        ?: return@deco emptySequence() // group has not been initialized
+
                     GroupImpl.checkIsInstance(group)
 
                     val internalType = readByte().toInt()

Файловите разлики са ограничени, защото са твърде много
+ 4 - 2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/ConfigPushSvc.kt


+ 4 - 6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.common.kt

@@ -52,26 +52,24 @@ expect open class BotConfiguration() : BotConfigurationBase {
     @ConfigurationDsl
     fun randomDeviceInfo()
 
+    /**
+     * 协议类型, 服务器仅允许使用不同协议同时登录.
+     */
     enum class MiraiProtocol {
         /**
          * Android 手机.
-         *
-         * - 与手机冲突
-         * - 与平板和电脑不冲突
          */
         ANDROID_PHONE,
 
         /**
          * Android 平板.
-         *
-         * - 与平板冲突
-         * - 与手机和电脑不冲突
          */
         ANDROID_PAD,
 
         /**
          * Android 手表.
          * */
+        @SinceMirai("1.1.0")
         ANDROID_WATCH;
 
 

+ 1 - 6
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotConfiguration.kt

@@ -134,23 +134,18 @@ actual open class BotConfiguration : BotConfigurationBase() { // open for Java
     ) {
         /**
          * Android 手机.
-         *
-         * - 与手机冲突
-         * - 与平板和电脑不冲突
          */
         ANDROID_PHONE(537062845),
 
         /**
          * Android 平板.
-         *
-         * - 与平板冲突
-         * - 与手机和电脑不冲突
          */
         ANDROID_PAD(537062409),
 
         /**
          * Android 手表.
          * */
+        @SinceMirai("1.1.0")
         ANDROID_WATCH(537061176)
     }
 

+ 19 - 19
mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/event/JvmMethodEventsTest.kt

@@ -11,12 +11,12 @@
 
 package net.mamoe.mirai.event
 
+import junit.framework.TestCase.assertEquals
 import kotlinx.coroutines.CoroutineScope
 import net.mamoe.mirai.utils.internal.runBlocking
 import org.junit.Test
 import java.util.concurrent.atomic.AtomicInteger
 import kotlin.coroutines.EmptyCoroutineContext
-import kotlin.test.assertEquals
 
 
 internal class JvmMethodEventsTest {
@@ -88,15 +88,15 @@ internal class JvmMethodEventsTest {
             }
         }
 
-        TestClass().run {
-            this.registerEvents()
-
-            runBlocking {
-                TestEvent().broadcast()
-            }
-
-            assertEquals(9, this.getCalled())
-        }
+//        TestClass().run {
+//            this.registerEvents()
+//
+//            runBlocking {
+//                TestEvent().broadcast()
+//            }
+//
+//            assertEquals(9, this.getCalled())
+//        }
     }
 
     @Test
@@ -121,14 +121,14 @@ internal class JvmMethodEventsTest {
             }
         }
 
-        TestClass().run {
-            this.registerEvents()
-
-            runBlocking {
-                TestEvent().broadcast()
-            }
-
-            assertEquals(1, this.getCalled())
-        }
+//        TestClass().run {
+//            this.registerEvents()
+//
+//            runBlocking {
+//                TestEvent().broadcast()
+//            }
+//
+//            assertEquals(1, this.getCalled())
+//        }
     }
 }

Някои файлове не бяха показани, защото твърде много файлове са промени