From 8028aaedd2cbd6d04dcd0af1ca99698de4910722 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8B=E4=BB=B6=20add:=20?= =?UTF-8?q?=E7=BE=A4=E8=A7=A3=E6=95=A3=E4=BA=8B=E4=BB=B6=20add:=20?= =?UTF-8?q?=E8=A2=AB=E5=88=A0=E9=99=A4=E5=A5=BD=E5=8F=8B=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 2 ++ client/decoders.go | 9 +++++++++ client/entities.go | 11 +++++++++++ client/online_push.go | 4 ++++ 4 files changed, 26 insertions(+) diff --git a/client/client.go b/client/client.go index 69b8aa12..9f0d9579 100644 --- a/client/client.go +++ b/client/client.go @@ -106,6 +106,8 @@ type QQClient struct { GroupDigestEvent EventHandle[*GroupDigestEvent] OtherClientStatusChangedEvent EventHandle[*OtherClientStatusChangedEvent] OfflineFileEvent EventHandle[*OfflineFileEvent] + GroupDisbandEvent EventHandle[*GroupDisbandEvent] + DeleteFriendEvent EventHandle[*DeleteFriendEvent] // message state msgSvcCache *utils.Cache[unit] diff --git a/client/decoders.go b/client/decoders.go index 789b6cb1..3a7ea414 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -732,6 +732,15 @@ func decodeOnlinePushTransPacket(c *QQClient, pkt *network.Packet) (any, error) Operator: g.FindMember(operator), }) } + case 0x01, 0x81: // kosbot add: 群解散. 暂时这样 See https://github.com/lz1998/ricq/blob/064ddddca19aa0410e2514852e3a151fd9913371/ricq-core/src/command/online_push/decoder.rs#L86 + c.GroupDisbandEvent.dispatch(c, &GroupDisbandEvent{ + Group: g, + Operator: g.FindMember(operator), + Time: int64(info.MsgTime.Unwrap()), + }) + if err = c.ReloadGroupList(); err != nil { + return nil, err + } } } } diff --git a/client/entities.go b/client/entities.go index b1e312ce..642ecbfb 100644 --- a/client/entities.go +++ b/client/entities.go @@ -191,6 +191,17 @@ type ( DownloadUrl string } + GroupDisbandEvent struct { + Group *GroupInfo + Time int64 + Operator *GroupMemberInfo + } + + DeleteFriendEvent struct { + Uin int64 + Nickname string + } + // GroupDigest 群精华消息 GroupDigest struct { GroupCode int64 `json:"group_code,string"` diff --git a/client/online_push.go b/client/online_push.go index 3cc5560c..e87bc79a 100644 --- a/client/online_push.go +++ b/client/online_push.go @@ -208,6 +208,10 @@ func msgType0x210Sub27Decoder(c *QQClient, protobuf []byte) error { if m.DelFriend != nil { frdUin := m.DelFriend.Uins[0] if frd := c.FindFriend(int64(frdUin)); frd != nil { + c.DeleteFriendEvent.dispatch(c, &DeleteFriendEvent{ + Uin: frd.Uin, + Nickname: frd.Nickname, + }) if err := c.ReloadFriendList(); err != nil { return errors.Wrap(err, "failed to reload friend list") }