diff --git a/Makefile b/Makefile index 7394c4c..9f3066b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION ?= v1.3.11 +VERSION ?= v1.3.12 NAME := talkeq # run a copy of talkeq diff --git a/config/config_discord.go b/config/config_discord.go index b870497..f884e59 100644 --- a/config/config_discord.go +++ b/config/config_discord.go @@ -25,6 +25,7 @@ type DiscordRoute struct { GuildID string `toml:"guild_id,omitempty" desc:"Optional, and likely not needed to be set since guilddb file is better, destination guild ID to relay the discord message to"` MessagePattern string `toml:"message_pattern" desc:"Destination message in. E.g. {{.Name}} says {{.ChannelName}}, '{{.Message}}"` messagePatternTemplate *template.Template + IsAnyoneAllowed bool `toml:"is_anyone_allowed" desc:"Can anyone use this route? E.g., instead of IGN or a users.txt, anyone given access to provided channel will be able to relay in game using their discord name."` } // DiscordTrigger is custom discord triggering diff --git a/discord/discord_msg.go b/discord/discord_msg.go index a11fa40..9f712f8 100644 --- a/discord/discord_msg.go +++ b/discord/discord_msg.go @@ -80,8 +80,29 @@ func (t *Discord) handleMessage(s *discordgo.Session, m *discordgo.MessageCreate } if len(ign) == 0 { - tlog.Warn("[discord] ign not found, discarding") - return + for _, route := range t.config.Routes { + if !route.IsEnabled { + continue + } + if route.Trigger.ChannelID != m.ChannelID { + continue + } + if !route.IsAnyoneAllowed { + continue + } + member, err := s.GuildMember(m.GuildID, m.Author.ID) + if err != nil { + tlog.Warnf("[discord] guildMember failed for server_id %s, author_id %s: %s", m.GuildID, m.Author, err) + continue + } + + ign = sanitize(member.Nick) + tlog.Debugf("[discord] ign not found, but anyone is allowed, using %s", ign) + } + if len(ign) == 0 { + tlog.Warn("[discord] ign not found, discarding") + return + } } routes := 0 for routeIndex, route := range t.config.Routes {