From 9042fb33b7e5353dcd9df0866dc8f672c42721bb Mon Sep 17 00:00:00 2001 From: Xackery Date: Tue, 27 Feb 2024 07:02:34 -0800 Subject: [PATCH] Add logic for anyone allowed checks --- discord/discord_msg.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/discord/discord_msg.go b/discord/discord_msg.go index 9f712f8..d01f6ba 100644 --- a/discord/discord_msg.go +++ b/discord/discord_msg.go @@ -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 @@ -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 { @@ -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)