Skip to content

Commit

Permalink
feat: 解析kicknt事件
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Nov 6, 2024
1 parent 8a030e5 commit c4ada2b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type QQClient struct {
cache cache.Cache

// event handles
KickedEvent EventHandle[*event.Kicked]

GroupMessageEvent EventHandle[*message.GroupMessage]
PrivateMessageEvent EventHandle[*message.PrivateMessage]
TempMessageEvent EventHandle[*message.TempMessage]
Expand Down
15 changes: 15 additions & 0 deletions client/event/sys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package event

import "github.com/LagrangeDev/LagrangeGo/client/packets/pb/system"

type Kicked struct {
Tips string
Tittle string
}

func ParseKickedEvent(e *system.ServiceKickNTResponse) *Kicked {
return &Kicked{
Tips: e.Tips,
Tittle: e.Title,
}
}
6 changes: 5 additions & 1 deletion client/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"errors"
"runtime/debug"

"github.com/LagrangeDev/LagrangeGo/client/packets/pb/system"

"github.com/LagrangeDev/LagrangeGo/internal/proto"

eventConverter "github.com/LagrangeDev/LagrangeGo/client/event"
Expand Down Expand Up @@ -344,7 +346,9 @@ func decodeOlPushServicePacket(c *QQClient, pkt *network.Packet) (any, error) {
}

func decodeKickNTPacket(c *QQClient, pkt *network.Packet) (any, error) {
c.Disconnect()
pb := system.ServiceKickNTResponse{}
_ = proto.Unmarshal(pkt.Payload, &pb)
c.KickedEvent.dispatch(c, eventConverter.ParseKickedEvent(&pb))
return nil, nil
}

Expand Down

0 comments on commit c4ada2b

Please sign in to comment.