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!",
|
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)
|
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 {
|
func Commands(b BotCommand) bool {
|
||||||
@ -281,3 +289,9 @@ func Status(b BotCommand) bool {
|
|||||||
go runPurge(b.Session)
|
go runPurge(b.Session)
|
||||||
return true
|
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
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
if m.Author.Bot || m.Author.ID == s.State.User.ID {
|
if m.Author.Bot || m.Author.ID == s.State.User.ID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.GuildID == "" {
|
if m.GuildID == "" {
|
||||||
handlePM(s, m)
|
handlePM(s, m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if isAdmin(m.Member) {
|
if isAdmin(m.Member) {
|
||||||
adminInteraction(s, m.Author.ID)
|
adminInteraction(s, m.Author.ID)
|
||||||
}
|
}
|
||||||
@ -57,6 +54,18 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
activeInteraction(s, m.Author.ID)
|
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) {
|
if strings.Contains(m.Content, s.State.User.ID) {
|
||||||
b := BotCommand{
|
b := BotCommand{
|
||||||
Session: s,
|
Session: s,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package main
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
|||||||
1
types.go
1
types.go
@ -42,6 +42,7 @@ type Config struct {
|
|||||||
Verifications map[string]Verification
|
Verifications map[string]Verification
|
||||||
Probations map[string]time.Time
|
Probations map[string]time.Time
|
||||||
LogOpts loggy.LogOpts
|
LogOpts loggy.LogOpts
|
||||||
|
WhitelistURLs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verification struct used for storing and logging
|
// Verification struct used for storing and logging
|
||||||
|
|||||||
Reference in New Issue
Block a user