-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GroupInvitedEvent, GroupJoinEvent, GroupLeaveEvent, GroupMember…
…JoinEvent, GroupMemberLeaveEvent Signed-off-by: JustAnotherID <[email protected]>
- Loading branch information
1 parent
069b85f
commit 12790e9
Showing
7 changed files
with
252 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package event | ||
|
||
import ( | ||
"github.com/LagrangeDev/LagrangeGo/packets/pb/message" | ||
"github.com/LagrangeDev/LagrangeGo/packets/pb/status" | ||
) | ||
|
||
type ( | ||
GroupEvent struct { | ||
GroupID uint32 | ||
} | ||
|
||
GroupMuteMember struct { | ||
GroupEvent | ||
OperatorUid string | ||
TargetUid string // when TargetUid is empty, mute all members | ||
Duration uint32 | ||
} | ||
|
||
GroupMemberJoinRequest struct { | ||
GroupEvent | ||
Uid string | ||
InvitorUid string | ||
Answer string // 问题:(.*)答案:(.*) | ||
} | ||
|
||
GroupMemberJoined struct { | ||
GroupEvent | ||
Uin uint32 | ||
Uid string | ||
JoinType int32 | ||
} | ||
|
||
GroupMemberQuit struct { | ||
GroupEvent | ||
Uin uint32 | ||
Uid string | ||
ExitType int32 | ||
OperatorUid string | ||
} | ||
) | ||
|
||
func (gmq *GroupMemberQuit) IsKicked() bool { | ||
return gmq.ExitType == 131 | ||
} | ||
|
||
func ParseMemberJoinRequest(event *status.MemberJoinRequest) *GroupMemberJoinRequest { | ||
return &GroupMemberJoinRequest{ | ||
GroupEvent: GroupEvent{ | ||
GroupID: event.GroupID, | ||
}, | ||
Uid: event.Uid, | ||
Answer: event.RequestField.Unwrap(), | ||
} | ||
} | ||
func ParseMemberJoinRequestFromInvite(event *status.MemberInviteRequest) *GroupMemberJoinRequest { | ||
if event.Cmd == 87 { | ||
inn := event.Info.Inner | ||
return &GroupMemberJoinRequest{ | ||
GroupEvent: GroupEvent{ | ||
GroupID: inn.GroupID, | ||
}, | ||
Uid: inn.Uid, | ||
InvitorUid: inn.InvitorUid, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func ParseMemberJoined(msg *message.PushMsg, event *status.MemberChanged) *GroupMemberJoined { | ||
return &GroupMemberJoined{ | ||
GroupEvent: GroupEvent{ | ||
GroupID: msg.Message.ResponseHead.FromUin, | ||
}, | ||
Uin: event.Uin, | ||
Uid: event.Uid, | ||
JoinType: event.JoinType.Unwrap(), | ||
} | ||
} | ||
|
||
func ParseMemberQuit(msg *message.PushMsg, event *status.MemberChanged) *GroupMemberQuit { | ||
return &GroupMemberQuit{ | ||
GroupEvent: GroupEvent{ | ||
GroupID: msg.Message.ResponseHead.FromUin, | ||
}, | ||
Uin: event.Uin, | ||
Uid: event.Uid, | ||
OperatorUid: event.OperatorUid.Unwrap(), | ||
ExitType: event.ExitType.Unwrap(), | ||
} | ||
} | ||
|
||
func ParseGroupMuteEvent(event *map[int]any) *GroupMuteMember { | ||
// TODO Parse GroupMuteEvent | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
syntax = "proto3"; | ||
|
||
option go_package = "github.com/LagrangeDev/LagrangeGo/packets/pb/status"; | ||
|
||
message MemberChanged { | ||
uint32 Uin = 1; | ||
string Uid = 3; | ||
optional int32 ExitType = 4; // 131 kick 130 exit | ||
optional string OperatorUid = 5; | ||
optional int32 JoinType = 6; // 6 scan qr | ||
} | ||
|
||
message MemberJoinRequest { | ||
// JoinType: Direct(scan qrcode or search GroupID) | ||
|
||
uint32 GroupID = 1; | ||
string Uid = 3; | ||
int32 Src = 4; | ||
optional string RequestField = 5; | ||
optional bytes Field9 = 9; | ||
} | ||
|
||
message InviteInner { | ||
uint32 GroupID = 1; | ||
string Uid = 5; | ||
string InvitorUid = 6; | ||
} | ||
|
||
message InviteInfo { | ||
InviteInner Inner = 1; | ||
} | ||
|
||
message MemberInviteRequest { | ||
// JoinType: Direct(scan qrcode or search GroupID) | ||
|
||
int32 Cmd = 1; | ||
InviteInfo Info = 2; | ||
} |