Add URL Whitelisting to Thanos since @MEE6 wants us to pay for it
This commit is contained in:
14
commands.go
14
commands.go
@ -92,6 +92,14 @@ func setupCommands() {
|
||||
Help: "List activity for the discord. Supply a number to get the top N users (5 would be top 5 users) or all for all users!",
|
||||
}
|
||||
commands = append(commands, activityReport)
|
||||
urlWhitelist := Command{
|
||||
Name: "Whitelist URL",
|
||||
RequiresAdmin: true,
|
||||
Keywords: []string{"whitelist"},
|
||||
Exec: WhitelistURL,
|
||||
Help: "Add a domain to the HTTP whitelist domains are in the format `thisvid.com` without the subdomain.",
|
||||
}
|
||||
commands = append(commands, urlWhitelist)
|
||||
}
|
||||
|
||||
func Commands(b BotCommand) bool {
|
||||
@ -281,3 +289,9 @@ func Status(b BotCommand) bool {
|
||||
go runPurge(b.Session)
|
||||
return true
|
||||
}
|
||||
|
||||
func WhitelistURL(b BotCommand) bool {
|
||||
defer log.PanicSafe()
|
||||
config.WhitelistURLs = append(config.WhitelistURLs, strings.ReplaceAll(b.Message.Content, b.Command, ""))
|
||||
return true;
|
||||
}
|
||||
@ -25,21 +25,18 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
})
|
||||
|
||||
}
|
||||
if strings.Contains(m.Embeds[0].Description, "Bump done!") {
|
||||
log.LogDebug("Finding string %+v", m.Embeds[0].Description)
|
||||
go bumpTimer()
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
if m.Author.Bot || m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
||||
if m.GuildID == "" {
|
||||
handlePM(s, m)
|
||||
return
|
||||
}
|
||||
|
||||
if isAdmin(m.Member) {
|
||||
adminInteraction(s, m.Author.ID)
|
||||
}
|
||||
@ -57,6 +54,18 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
activeInteraction(s, m.Author.ID)
|
||||
}
|
||||
}
|
||||
if strings.Contains(m.Content, "http") {
|
||||
safe := false
|
||||
for _, testURL := range config.WhitelistURLs {
|
||||
if strings.Contains(m.Content, testURL) {
|
||||
safe = true
|
||||
}
|
||||
}
|
||||
if !safe {
|
||||
s.ChannelMessageSend(m.ChannelID, "That domain is not approved by the admins. Please contact Admins if the domain should be whitelisted.")
|
||||
s.ChannelMessageDelete(m.ChannelID, m.ID)
|
||||
}
|
||||
}
|
||||
if strings.Contains(m.Content, s.State.User.ID) {
|
||||
b := BotCommand{
|
||||
Session: s,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package tools
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package tools
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
Reference in New Issue
Block a user