trim domain
This commit is contained in:
17
commands.go
17
commands.go
@ -93,11 +93,11 @@ func setupCommands() {
|
|||||||
}
|
}
|
||||||
commands = append(commands, activityReport)
|
commands = append(commands, activityReport)
|
||||||
urlWhitelist := Command{
|
urlWhitelist := Command{
|
||||||
Name: "Whitelist URL",
|
Name: "Whitelist URL",
|
||||||
RequiresAdmin: true,
|
RequiresAdmin: true,
|
||||||
Keywords: []string{"whitelist", "wl"},
|
Keywords: []string{"whitelist", "wl"},
|
||||||
Exec: WhitelistURL,
|
Exec: WhitelistURL,
|
||||||
Help: "Add a domain to the HTTP whitelist domains are in the format `thisvid.com` without the subdomain.",
|
Help: "Add a domain to the HTTP whitelist domains are in the format `thisvid.com` without the subdomain.",
|
||||||
}
|
}
|
||||||
commands = append(commands, urlWhitelist)
|
commands = append(commands, urlWhitelist)
|
||||||
}
|
}
|
||||||
@ -292,9 +292,14 @@ func Status(b BotCommand) bool {
|
|||||||
|
|
||||||
func WhitelistURL(b BotCommand) bool {
|
func WhitelistURL(b BotCommand) bool {
|
||||||
defer log.PanicSafe()
|
defer log.PanicSafe()
|
||||||
config.WhitelistURLs = append(config.WhitelistURLs, strings.ReplaceAll(strings.ReplaceAll(b.Message.Content, b.Command, ""), "<@688025671968096341>", ""))
|
config.WhitelistURLs = append(config.WhitelistURLs, strings.Trim(
|
||||||
|
strings.ReplaceAll(
|
||||||
|
strings.ReplaceAll(b.Message.Content, b.Command, ""),
|
||||||
|
"<@688025671968096341>", ""),
|
||||||
|
),
|
||||||
|
)
|
||||||
domains := strings.Join(config.WhitelistURLs, "\n")
|
domains := strings.Join(config.WhitelistURLs, "\n")
|
||||||
b.Session.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("Current whitelisted domains: %+v", domains))
|
b.Session.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("Current whitelisted domains: %+v", domains))
|
||||||
log.LogDebug(fmt.Sprintf("Current whitelisted domains: %+v", domains))
|
log.LogDebug(fmt.Sprintf("Current whitelisted domains: %+v", domains))
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
if strings.Contains(m.Content, "http") {
|
if strings.Contains(m.Content, "http") {
|
||||||
safe := false
|
safe := false
|
||||||
for _, testURL := range config.WhitelistURLs {
|
for _, testURL := range config.WhitelistURLs {
|
||||||
if strings.Contains(m.Content, testURL) {
|
if strings.Contains(m.Content, testURL) {
|
||||||
safe = true
|
safe = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user