Download long term verifications
This commit is contained in:
@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
20
main.go
20
main.go
@ -3,7 +3,9 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
@ -156,7 +158,7 @@ func runPurge(s *discordgo.Session) {
|
||||
|
||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
// Set the playing status.
|
||||
s.UpdateStatus(0, "DreamDaddy v0.6")
|
||||
s.UpdateStatus(0, "DreamDaddy v0.7")
|
||||
}
|
||||
|
||||
func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
|
||||
@ -277,6 +279,7 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
||||
} else if m.Emoji.Name == "👍" {
|
||||
verifyMember(s, user)
|
||||
verification.Status = "Accepted"
|
||||
go storeVerification(verification.UserID, verification.Username, verification.Photo)
|
||||
} else if m.Emoji.Name == "👶" {
|
||||
requestAge(s, user)
|
||||
log.LogInfo(fmt.Sprintf("%+v has requested ASL for user %+v.", admin.User.Username, user.Username))
|
||||
@ -290,6 +293,21 @@ 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) {
|
||||
defer log.PanicSafe()
|
||||
file, _ := os.Create(fmt.Sprintf("./verifications/%s-%s", id, username))
|
||||
client := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
}
|
||||
resp, _ := client.Get(url)
|
||||
defer resp.Body.Close()
|
||||
defer file.Close()
|
||||
_, _ = io.Copy(file, resp.Body)
|
||||
|
||||
}
|
||||
|
||||
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
defer log.PanicSafe()
|
||||
|
||||
Reference in New Issue
Block a user