浏览代码

支持解析好友输入状态

sandtechnology 5 年之前
父节点
当前提交
a062ff9ed3

+ 1 - 2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/msgType0x210.kt

@@ -182,7 +182,7 @@ internal class Submsgtype0x115 {
         @Serializable
         internal class NotifyItem(
             @ProtoId(1) @JvmField val ime: Int = 0,
-            @ProtoId(2) @JvmField val timeoutS: Int = 0,
+            @ProtoId(2) @JvmField val timeout: Int = 0,
             @ProtoId(3) @JvmField val timestamp: Long = 0L,
             @ProtoId(4) @JvmField val eventType: Int = 0,
             @ProtoId(5) @JvmField val interval: Int = 0,
@@ -611,7 +611,6 @@ internal class Submsgtype0x26 {
     }
 }
 
-
 internal class Submsgtype0x27 {
     internal class SubMsgType0x27 : ProtoBuf {
         @Serializable

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

@@ -16,10 +16,7 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
 
 import kotlinx.coroutines.CancellationException
 import kotlinx.coroutines.cancel
-import kotlinx.io.core.ByteReadPacket
-import kotlinx.io.core.discardExact
-import kotlinx.io.core.readBytes
-import kotlinx.io.core.readUInt
+import kotlinx.io.core.*
 import kotlinx.serialization.Serializable
 import kotlinx.serialization.protobuf.ProtoId
 import net.mamoe.mirai.JavaFriendlyAPI
@@ -43,6 +40,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
 import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Submsgtype0x27.SubMsgType0x27.*
 import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Submsgtype0x44
 import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Submsgtype0xb3
+import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Submsgtype0x115
 import net.mamoe.mirai.qqandroid.network.protocol.data.proto.TroopTips0x857
 import net.mamoe.mirai.qqandroid.network.protocol.packet.IncomingPacketFactory
 import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
@@ -449,6 +447,15 @@ internal object Transformers528 : Map<Long, Lambda528> by mapOf(
             sequenceOf(BotLeaveEvent.Active(group))
         } else emptySequence()
     },
+    //好友输入状态
+    0x115L to lambda528 {bot->
+        val body=vProtobuf.loadAs(Submsgtype0x115.SubMsgType0x115.MsgBody.serializer())
+        val friend = bot.getFriendOrNull(body.fromUin)
+        val item = body.msgNotifyItem
+        return@lambda528 if(friend!=null&&item!=null){
+            sequenceOf(FriendInputStatusChangedEvent(friend,item.eventType==1))
+        } else { emptySequence()}
+    },
     // 群相关,  ModFriendRemark, DelFriend, ModGroupProfile
     0x27L to lambda528 { bot ->
         fun ModFriendRemark.transform(bot: QQAndroidBot): Sequence<Packet> {

+ 8 - 0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/friend.kt

@@ -111,3 +111,11 @@ public data class FriendAvatarChangedEvent internal constructor(
     public override val friend: Friend
 ) : FriendEvent, Packet, AbstractEvent()
 
+/**
+ * 好友输入状态改变的事件,当开始输入文字、退出聊天窗口或清空输入框时会触发此事件
+ */
+public data class FriendInputStatusChangedEvent internal constructor(
+    public override val friend: Friend,
+    public val inputting: Boolean
+
+) : FriendEvent, Packet, AbstractEvent()