Browse Source

Download long term verifications

hkremer/rebranding
Gregory Rudolph 4 years ago
parent
commit
3c7c8d0776
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 2
      config.go
  2. 20
      main.go

2
config.go

@ -4,8 +4,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"time"
"os" "os"
"time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
) )

20
main.go

@ -3,7 +3,9 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"io"
"math/rand" "math/rand"
"net/http"
"os" "os"
"os/signal" "os/signal"
"strings" "strings"
@ -156,7 +158,7 @@ func runPurge(s *discordgo.Session) {
func ready(s *discordgo.Session, event *discordgo.Ready) { func ready(s *discordgo.Session, event *discordgo.Ready) {
// Set the playing status. // Set the playing status.
s.UpdateStatus(0, "DreamDaddy v0.6") s.UpdateStatus(0, "DreamDaddy v0.7")
} }
func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) { 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 == "👍" { } else if m.Emoji.Name == "👍" {
verifyMember(s, user) verifyMember(s, user)
verification.Status = "Accepted" verification.Status = "Accepted"
go storeVerification(verification.UserID, verification.Username, verification.Photo)
} else if m.Emoji.Name == "👶" { } else if m.Emoji.Name == "👶" {
requestAge(s, user) requestAge(s, user)
log.LogInfo(fmt.Sprintf("%+v has requested ASL for user %+v.", admin.User.Username, user.Username)) 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())) 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) {
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) { func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
defer log.PanicSafe() defer log.PanicSafe()

Loading…
Cancel
Save