Skip to content

Commit

Permalink
feat: 区分自身事件
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Jun 18, 2024
1 parent 6b660aa commit 3a2e702
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type QQClient struct {
PrivateMessageEvent EventHandle[*message.PrivateMessage]
TempMessageEvent EventHandle[*message.TempMessage]

SelfGroupMessageEvent EventHandle[*message.GroupMessage]
SelfPrivateMessageEvent EventHandle[*message.PrivateMessage]
SelfTempMessageEvent EventHandle[*message.TempMessage]

GroupInvitedEvent EventHandle[*event.GroupInvite] // 邀请入群
GroupMemberJoinRequestEvent EventHandle[*event.GroupMemberJoinRequest] // 加群申请
GroupMemberJoinEvent EventHandle[*event.GroupMemberIncrease] // 成员入群
Expand Down
21 changes: 18 additions & 3 deletions client/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,28 @@ func decodeOlPushServicePacket(c *QQClient, pkt *network.Packet) (any, error) {

switch typ {
case 166, 208: // 166 for private msg, 208 for private record
c.PrivateMessageEvent.dispatch(c, msgConverter.ParsePrivateMessage(&msg))
prvMsg := msgConverter.ParsePrivateMessage(&msg)
if prvMsg.Sender.Uin != c.Uin {
c.PrivateMessageEvent.dispatch(c, prvMsg)
} else {
c.SelfPrivateMessageEvent.dispatch(c, prvMsg)
}
return nil, nil
case 82: // group msg
c.GroupMessageEvent.dispatch(c, msgConverter.ParseGroupMessage(&msg))
grpMsg := msgConverter.ParseGroupMessage(&msg)
if grpMsg.Sender.Uin != c.Uin {
c.GroupMessageEvent.dispatch(c, grpMsg)
} else {
c.SelfGroupMessageEvent.dispatch(c, grpMsg)
}
return nil, nil
case 141: // temp msg
c.TempMessageEvent.dispatch(c, msgConverter.ParseTempMessage(&msg))
tempMsg := msgConverter.ParseTempMessage(&msg)
if tempMsg.Sender.Uin != c.Uin {
c.TempMessageEvent.dispatch(c, tempMsg)
} else {
c.SelfTempMessageEvent.dispatch(c, tempMsg)
}
return nil, nil
case 33: // member increase
pb := message.GroupChange{}
Expand Down

0 comments on commit 3a2e702

Please sign in to comment.