Compare commits

..

No commits in common. "main" and "v1.0.0" have entirely different histories.
main ... v1.0.0

3 changed files with 4 additions and 37 deletions

View File

@ -37,31 +37,3 @@ This setting should be enabled for the bot in the discord developer panel for it
[SERVERS.CHANNEL_BLACKLIST] [SERVERS.CHANNEL_BLACKLIST]
CHANNELS = [] CHANNELS = []
``` ```
### Explaination
```toml
[DISCORD]
BOT_TOKEN = ""
[[SERVERS]]
# ID of the server in which all the channels should be monitored
SERVER_ID = "1050204101826334999"
# Channel where everything should be send to
OUTPUT_CHANNEL_ID = "1250585834726621999"
# Wether to show the coin prefix or not
PREFIX_ENABLED = true
# Display name of server a message has been send in
SERVER_ID_ENABLED = false
# Display clickable channel object of server a message has been send in
CHANNEL_ID_ENABLED = true
# Provides a link to the message where the regex has been matched
MESSAGE_LINK_ENABLED = false
[SERVERS.COIN_REGEXES]
# Prefix = Regex pair of the coin(s) to be matched; can theoretically be used for other stuff
Bitcoin = "[13][a-km-zA-HJ-NP-Z1-9]{25,34}"
Ethereum = "0x[a-fA-F0-9]{40}"
[SERVERS.CHANNEL_BLACKLIST]
# IDs of the channels that should NOT be monitored
CHANNELS = ["1250537334550827078"]
```

View File

@ -4,7 +4,6 @@
[[SERVERS]] [[SERVERS]]
SERVER_ID = "" SERVER_ID = ""
OUTPUT_CHANNEL_ID = "" OUTPUT_CHANNEL_ID = ""
ALLOW_DUPLICATES = false
PREFIX_ENABLED = true PREFIX_ENABLED = true
SERVER_ID_ENABLED = false SERVER_ID_ENABLED = false
CHANNEL_ID_ENABLED = true CHANNEL_ID_ENABLED = true
@ -19,7 +18,6 @@
SERVER_ID = "" SERVER_ID = ""
OUTPUT_CHANNEL_ID = "" OUTPUT_CHANNEL_ID = ""
PREFIX_ENABLED = false PREFIX_ENABLED = false
ALLOW_DUPLICATES = false
SERVER_ID_ENABLED = false SERVER_ID_ENABLED = false
CHANNEL_ID_ENABLED = true CHANNEL_ID_ENABLED = true
MESSAGE_LINK_ENABLED = false MESSAGE_LINK_ENABLED = false

11
main.go
View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"os" "os"
"regexp" "regexp"
"strings"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
@ -130,15 +129,14 @@ func checkMessageContent(s *discordgo.Session, server ServerConfig, m *discordgo
match := regex.FindStringSubmatch(m.Content) match := regex.FindStringSubmatch(m.Content)
if len(match) > 0 { if len(match) > 0 {
matchedAddress := match[0] matchedAddress := match[0]
matchedAddress = strings.TrimSpace(matchedAddress)
message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m) message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m)
if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(matchedAddress) { if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(message) {
return return
} }
s.ChannelMessageSend(server.OutputChannelID, message) s.ChannelMessageSend(server.OutputChannelID, message)
MessageHistory[server.ServerID].Add(matchedAddress) MessageHistory[server.ServerID].Add(message)
} }
} }
} }
@ -150,15 +148,14 @@ func checkEmbeds(s *discordgo.Session, server ServerConfig, m *discordgo.Message
match := regex.FindStringSubmatch(embed.Description) match := regex.FindStringSubmatch(embed.Description)
if len(match) > 0 { if len(match) > 0 {
matchedAddress := match[0] matchedAddress := match[0]
matchedAddress = strings.TrimSpace(matchedAddress)
message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m) message := formatMessage(server, coin, m.Author.Username, matchedAddress, serverName, m)
if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(matchedAddress) { if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(message) {
return return
} }
s.ChannelMessageSend(server.OutputChannelID, message) s.ChannelMessageSend(server.OutputChannelID, message)
MessageHistory[server.ServerID].Add(matchedAddress) MessageHistory[server.ServerID].Add(message)
} }
} }
} }