updated filenames for verification storage
This commit is contained in:
19
main.go
19
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
@ -139,7 +140,7 @@ func runPurge(s *discordgo.Session) {
|
|||||||
messages, _ := s.ChannelMessages(config.MonitorChann, 100, "", "", "")
|
messages, _ := s.ChannelMessages(config.MonitorChann, 100, "", "", "")
|
||||||
for _, message := range messages {
|
for _, message := range messages {
|
||||||
found := false
|
found := false
|
||||||
for user, _ := range config.Unverified {
|
for user := range config.Unverified {
|
||||||
if message.Author.ID == user {
|
if message.Author.ID == user {
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
@ -171,7 +172,7 @@ func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
|||||||
|
|
||||||
func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) {
|
func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) {
|
||||||
defer log.PanicSafe()
|
defer log.PanicSafe()
|
||||||
for uid, _ := range config.Probations {
|
for uid := range config.Probations {
|
||||||
if m.User.Email == uid {
|
if m.User.Email == uid {
|
||||||
delete(config.Probations, uid)
|
delete(config.Probations, uid)
|
||||||
}
|
}
|
||||||
@ -293,16 +294,24 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
|||||||
log.LogInfo(fmt.Sprintf("%+v", verification.prettyPrint()))
|
log.LogInfo(fmt.Sprintf("%+v", verification.prettyPrint()))
|
||||||
delete(config.Verifications, m.MessageID)
|
delete(config.Verifications, m.MessageID)
|
||||||
}
|
}
|
||||||
func storeVerification(id string, username string, url string) {
|
func storeVerification(id string, username string, verificationURL string) {
|
||||||
defer log.PanicSafe()
|
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{
|
client := http.Client{
|
||||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||||
r.URL.Opaque = r.URL.Path
|
r.URL.Opaque = r.URL.Path
|
||||||
return nil
|
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 resp.Body.Close()
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
_, _ = io.Copy(file, resp.Body)
|
_, _ = io.Copy(file, resp.Body)
|
||||||
|
|||||||
Reference in New Issue
Block a user