Skip to content

Commit

Permalink
fix: 处理可能存在的在接收频道消息时没有 Member.Roles 的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsSov8forUs committed Sep 9, 2024
1 parent 0360a31 commit 7cafdcb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
18 changes: 12 additions & 6 deletions processor/process_channel_direct_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ func (p *Processor) ProcessChannelDirectMessage(payload *dto.WSPayload, data *dt
IsBot: data.Author.Bot,
}

// 构建 role
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}

// 填充事件数据
event = &operation.Event{
Id: id,
Expand All @@ -89,10 +84,21 @@ func (p *Processor) ProcessChannelDirectMessage(payload *dto.WSPayload, data *dt
Guild: guild,
Member: member,
Message: message,
Role: role,
User: user,
}

// 需要处理可能的 Member.Roles 为空的情况
//
// 傻逼腾讯
//
// 构建 role
if len(data.Member.Roles) > 0 {
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}
event.Role = role
}

// 上报消息到 Satori 应用
return p.BroadcastEvent(event)
}
Expand Down
18 changes: 12 additions & 6 deletions processor/process_guild_at_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ func (p *Processor) ProcessGuildATMessage(payload *dto.WSPayload, data *dto.WSAT
IsBot: data.Author.Bot,
}

// 构建 role
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}

// 填充事件数据
event = &operation.Event{
Id: id,
Expand All @@ -87,10 +82,21 @@ func (p *Processor) ProcessGuildATMessage(payload *dto.WSPayload, data *dto.WSAT
Guild: guild,
Member: member,
Message: message,
Role: role,
User: user,
}

// 需要处理可能的 Member.Roles 为空的情况
//
// 傻逼腾讯
//
// 构建 role
if len(data.Member.Roles) > 0 {
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}
event.Role = role
}

// 上报消息到 Satori 应用
return p.BroadcastEvent(event)
}
Expand Down
18 changes: 12 additions & 6 deletions processor/process_guild_normal_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ func (p *Processor) ProcessGuildNormalMessage(payload *dto.WSPayload, data *dto.
IsBot: data.Author.Bot,
}

// 构建 role
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}

// 填充事件数据
event = &operation.Event{
Id: id,
Expand All @@ -87,10 +82,21 @@ func (p *Processor) ProcessGuildNormalMessage(payload *dto.WSPayload, data *dto.
Guild: guild,
Member: member,
Message: message,
Role: role,
User: user,
}

// 需要处理可能的 Member.Roles 为空的情况
//
// 傻逼腾讯
//
// 构建 role
if len(data.Member.Roles) > 0 {
role := &guildrole.GuildRole{
Id: data.Member.Roles[0],
}
event.Role = role
}

// 上报消息到 Satori 应用
return p.BroadcastEvent(event)
}
Expand Down

0 comments on commit 7cafdcb

Please sign in to comment.