Fix duplicate issues
This commit is contained in:
parent
7da090badf
commit
c1da0b7a3b
@ -4,6 +4,7 @@
|
|||||||
[[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
|
||||||
@ -18,6 +19,7 @@
|
|||||||
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
11
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
@ -129,14 +130,15 @@ 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(message) {
|
if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(matchedAddress) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.ChannelMessageSend(server.OutputChannelID, message)
|
s.ChannelMessageSend(server.OutputChannelID, message)
|
||||||
MessageHistory[server.ServerID].Add(message)
|
MessageHistory[server.ServerID].Add(matchedAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,14 +150,15 @@ 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(message) {
|
if !server.AllowDuplicates && MessageHistory[server.ServerID].ContainsItem(matchedAddress) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.ChannelMessageSend(server.OutputChannelID, message)
|
s.ChannelMessageSend(server.OutputChannelID, message)
|
||||||
MessageHistory[server.ServerID].Add(message)
|
MessageHistory[server.ServerID].Add(matchedAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user