|
|
|
@ -6,6 +6,7 @@ import (
@@ -6,6 +6,7 @@ import (
|
|
|
|
|
"io" |
|
|
|
|
"math/rand" |
|
|
|
|
"net/http" |
|
|
|
|
"net/url" |
|
|
|
|
"os" |
|
|
|
|
"os/signal" |
|
|
|
|
"strings" |
|
|
|
@ -139,7 +140,7 @@ func runPurge(s *discordgo.Session) {
@@ -139,7 +140,7 @@ func runPurge(s *discordgo.Session) {
|
|
|
|
|
messages, _ := s.ChannelMessages(config.MonitorChann, 100, "", "", "") |
|
|
|
|
for _, message := range messages { |
|
|
|
|
found := false |
|
|
|
|
for user, _ := range config.Unverified { |
|
|
|
|
for user := range config.Unverified { |
|
|
|
|
if message.Author.ID == user { |
|
|
|
|
found = true |
|
|
|
|
} |
|
|
|
@ -171,7 +172,7 @@ func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
@@ -171,7 +172,7 @@ func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
|
|
|
|
|
|
|
|
|
func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
for uid, _ := range config.Probations { |
|
|
|
|
for uid := range config.Probations { |
|
|
|
|
if m.User.Email == uid { |
|
|
|
|
delete(config.Probations, uid) |
|
|
|
|
} |
|
|
|
@ -293,16 +294,24 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
@@ -293,16 +294,24 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
|
|
|
|
log.LogInfo(fmt.Sprintf("%+v", verification.prettyPrint())) |
|
|
|
|
delete(config.Verifications, m.MessageID) |
|
|
|
|
} |
|
|
|
|
func storeVerification(id string, username string, url string) { |
|
|
|
|
func storeVerification(id string, username string, verificationURL string) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
file, _ := os.Create(fmt.Sprintf("./verifications/%s-%s", id, username)) |
|
|
|
|
fileURL, _ := url.Parse(verificationURL) |
|
|
|
|
path := fileURL.Path |
|
|
|
|
segments := strings.Split(path, "/") |
|
|
|
|
|
|
|
|
|
fileName := segments[len(segments)-1] |
|
|
|
|
file, _ := os.Create(fmt.Sprintf("./verifications/%s-%s-%s", id, username, fileName)) |
|
|
|
|
client := http.Client{ |
|
|
|
|
CheckRedirect: func(r *http.Request, via []*http.Request) error { |
|
|
|
|
r.URL.Opaque = r.URL.Path |
|
|
|
|
return nil |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
resp, _ := client.Get(url) |
|
|
|
|
resp, err := client.Get(verificationURL) |
|
|
|
|
if err != nil { |
|
|
|
|
log.LogError(fmt.Sprintf("Unable to store verification %s-%s-%s", id, username, fileName)) |
|
|
|
|
} |
|
|
|
|
defer resp.Body.Close() |
|
|
|
|
defer file.Close() |
|
|
|
|
_, _ = io.Copy(file, resp.Body) |
|
|
|
|