mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
feat: MemberJoinedGuildEvent
This commit is contained in:
parent
524b2b7881
commit
9778dd2369
@ -244,6 +244,11 @@ type (
|
||||
ChannelInfo *ChannelInfo
|
||||
}
|
||||
|
||||
MemberJoinGuildEvent struct {
|
||||
Guild *GuildInfo
|
||||
Member *GuildMemberInfo
|
||||
}
|
||||
|
||||
OcrResponse struct {
|
||||
Texts []*TextDetection `json:"texts"`
|
||||
Language string `json:"language"`
|
||||
|
@ -19,6 +19,7 @@ type eventHandlers struct {
|
||||
guildChannelUpdatedHandlers []func(*QQClient, *GuildChannelUpdatedEvent)
|
||||
guildChannelCreatedHandlers []func(*QQClient, *GuildChannelOperationEvent)
|
||||
guildChannelDestroyedHandlers []func(*QQClient, *GuildChannelOperationEvent)
|
||||
memberJoinedGuildHandlers []func(*QQClient, *MemberJoinGuildEvent)
|
||||
groupMuteEventHandlers []func(*QQClient, *GroupMuteEvent)
|
||||
groupRecalledHandlers []func(*QQClient, *GroupMessageRecalledEvent)
|
||||
friendRecalledHandlers []func(*QQClient, *FriendMessageRecalledEvent)
|
||||
@ -93,6 +94,10 @@ func (s *GuildService) OnGuildChannelDestroyed(f func(*QQClient, *GuildChannelOp
|
||||
s.c.eventHandlers.guildChannelDestroyedHandlers = append(s.c.eventHandlers.guildChannelDestroyedHandlers, f)
|
||||
}
|
||||
|
||||
func (s *GuildService) OnMemberJoinedGuild(f func(*QQClient, *MemberJoinGuildEvent)) {
|
||||
s.c.eventHandlers.memberJoinedGuildHandlers = append(s.c.eventHandlers.memberJoinedGuildHandlers, f)
|
||||
}
|
||||
|
||||
func (c *QQClient) OnGroupMuted(f func(*QQClient, *GroupMuteEvent)) {
|
||||
c.eventHandlers.groupMuteEventHandlers = append(c.eventHandlers.groupMuteEventHandlers, f)
|
||||
}
|
||||
@ -310,6 +315,17 @@ func (c *QQClient) dispatchGuildChannelDestroyedEvent(e *GuildChannelOperationEv
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchMemberJoinedGuildEvent(e *MemberJoinGuildEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
for _, f := range c.eventHandlers.memberJoinedGuildHandlers {
|
||||
cover(func() {
|
||||
f(c, e)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchGroupMuteEvent(e *GroupMuteEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
|
@ -140,6 +140,25 @@ func (c *QQClient) processGuildEventBody(m *channel.ChannelMsgContent, eventBody
|
||||
OldChannelInfo: oldInfo,
|
||||
NewChannelInfo: newInfo,
|
||||
})
|
||||
case eventBody.JoinGuild != nil:
|
||||
if mem := guild.FindMember(eventBody.JoinGuild.GetMemberTinyid()); mem != nil {
|
||||
c.Info("ignore join guild event: member %v already exists", mem.TinyId)
|
||||
return
|
||||
}
|
||||
profile, err := c.GuildService.GetGuildMemberProfileInfo(guild.GuildId, eventBody.JoinGuild.GetMemberTinyid())
|
||||
if err != nil {
|
||||
c.Error("error to decode member join guild event: get member profile error: %v", err)
|
||||
return
|
||||
}
|
||||
info := &GuildMemberInfo{
|
||||
TinyId: profile.TinyId,
|
||||
Nickname: profile.Nickname,
|
||||
}
|
||||
guild.Members = append(guild.Members, info)
|
||||
c.dispatchMemberJoinedGuildEvent(&MemberJoinGuildEvent{
|
||||
Guild: guild,
|
||||
Member: info,
|
||||
})
|
||||
case eventBody.UpdateMsg != nil:
|
||||
if eventBody.UpdateMsg.GetEventType() == 1 || eventBody.UpdateMsg.GetEventType() == 2 { // todo: 撤回消息
|
||||
return
|
||||
|
@ -411,9 +411,9 @@ func (x *ChannelMsgContent) GetExtInfo() *ChannelExtInfo {
|
||||
}
|
||||
|
||||
type ChannelMsgCtrlHead struct {
|
||||
IncludeUin []uint64 `protobuf:"varint,1,rep"`
|
||||
ExcludeUin []uint64 `protobuf:"varint,2,rep"`
|
||||
Featureid []uint64 `protobuf:"varint,3,rep"`
|
||||
IncludeUin []uint64 `protobuf:"varint,1,rep"`
|
||||
// repeated uint64 excludeUin = 2; // bytes?
|
||||
// repeated uint64 featureid = 3;
|
||||
OfflineFlag *uint32 `protobuf:"varint,4,opt"`
|
||||
Visibility *uint32 `protobuf:"varint,5,opt"`
|
||||
CtrlFlag *uint64 `protobuf:"varint,6,opt"`
|
||||
@ -433,20 +433,6 @@ func (x *ChannelMsgCtrlHead) GetIncludeUin() []uint64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ChannelMsgCtrlHead) GetExcludeUin() []uint64 {
|
||||
if x != nil {
|
||||
return x.ExcludeUin
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ChannelMsgCtrlHead) GetFeatureid() []uint64 {
|
||||
if x != nil {
|
||||
return x.Featureid
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ChannelMsgCtrlHead) GetOfflineFlag() uint32 {
|
||||
if x != nil && x.OfflineFlag != nil {
|
||||
return *x.OfflineFlag
|
||||
|
@ -82,8 +82,8 @@ message ChannelMsgContent {
|
||||
|
||||
message ChannelMsgCtrlHead {
|
||||
repeated uint64 includeUin = 1;
|
||||
repeated uint64 excludeUin = 2;
|
||||
repeated uint64 featureid = 3;
|
||||
// repeated uint64 excludeUin = 2; // bytes?
|
||||
// repeated uint64 featureid = 3;
|
||||
optional uint32 offlineFlag = 4;
|
||||
optional uint32 visibility = 5;
|
||||
optional uint64 ctrlFlag = 6;
|
||||
|
Loading…
x
Reference in New Issue
Block a user