diff --git a/config.toml.example b/config.toml.example index abbe7c2..d2c2135 100644 --- a/config.toml.example +++ b/config.toml.example @@ -5,6 +5,8 @@ SERVER_ID = "" OUTPUT_CHANNEL_ID = "" PREFIX_ENABLED = true + SERVER_ID_ENABLED = false + CHANNEL_ID_ENABLED = true [SERVERS.COIN_REGEXES] Bitcoin = "[13][a-km-zA-HJ-NP-Z1-9]{25,34}" Ethereum = "0x[a-fA-F0-9]{40}" @@ -15,6 +17,8 @@ SERVER_ID = "" OUTPUT_CHANNEL_ID = "" PREFIX_ENABLED = false + SERVER_ID_ENABLED = false + CHANNEL_ID_ENABLED = true [SERVERS.COIN_REGEXES] Ethereum = "0x[a-fA-F0-9]{40}" Solana = "[1-9A-HJ-NP-Za-km-z]{32,44}" diff --git a/main.go b/main.go index 68d6985..730104a 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,8 @@ type ServerConfig struct { } `toml:"CHANNEL_BLACKLIST"` PrefixEnabled bool `toml:"PREFIX_ENABLED"` AllowDuplicates bool `toml:"ALLOW_DUPLICATES"` - ServerIDEnabled bool `toml:"SERVER_ID_ENABLED"` + ServerIDEnabled bool `toml:"SERVER_ID_ENABLED"` + ChannelIDEnabled bool `toml:"CHANNEL_ID_ENABLED"` } func init() { @@ -127,7 +128,7 @@ func checkMessageContent(s *discordgo.Session, server ServerConfig, m *discordgo match := regex.FindStringSubmatch(m.Content) if len(match) > 0 { matchedAddress := match[0] - message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName) + message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m) if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(message) { return @@ -146,7 +147,7 @@ func checkEmbeds(s *discordgo.Session, server ServerConfig, m *discordgo.Message match := regex.FindStringSubmatch(embed.Description) if len(match) > 0 { matchedAddress := match[0] - message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName) + message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m) if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(message) { return @@ -160,7 +161,7 @@ func checkEmbeds(s *discordgo.Session, server ServerConfig, m *discordgo.Message } } -func formatMessage(server ServerConfig, coin, username, address, serverName string) string { +func formatMessage(server ServerConfig, coin, username, address, serverName string, m *discordgo.MessageCreate) string { message := address if server.PrefixEnabled { @@ -171,6 +172,10 @@ func formatMessage(server ServerConfig, coin, username, address, serverName stri message = fmt.Sprintf("%s (Server: %s)", message, serverName) } + if server.ChannelIDEnabled { + message = fmt.Sprintf("%s (From: <#%s>)", message, m.ChannelID) + } + return message }