Skip to content

Commit

Permalink
Add logic for anyone allowed checks
Browse files Browse the repository at this point in the history
  • Loading branch information
xackery committed Feb 27, 2024
1 parent 763cb88 commit 9042fb3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion discord/discord_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func (t *Discord) handleMessage(s *discordgo.Session, m *discordgo.MessageCreate
}
}

isUnregisteredIGN := false
if len(ign) == 0 {
isUnregisteredIGN = true
for _, route := range t.config.Routes {
if !route.IsEnabled {
continue
Expand All @@ -96,7 +98,12 @@ func (t *Discord) handleMessage(s *discordgo.Session, m *discordgo.MessageCreate
continue
}

ign = sanitize(member.Nick)
if len(ign) == 0 {
ign = sanitize(member.Nick)
if len(ign) == 0 {
ign = sanitize(member.User.Username)
}
}
tlog.Debugf("[discord] ign not found, but anyone is allowed, using %s", ign)
}
if len(ign) == 0 {
Expand All @@ -112,6 +119,9 @@ func (t *Discord) handleMessage(s *discordgo.Session, m *discordgo.MessageCreate
if route.Trigger.ChannelID != m.ChannelID {
continue
}
if isUnregisteredIGN && !route.IsAnyoneAllowed {
continue
}

buf := new(bytes.Buffer)

Expand Down

0 comments on commit 9042fb3

Please sign in to comment.