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 ( @@ -4,8 +4,8 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"time"
"os"
"time"
"github.com/bwmarrin/discordgo"
)

20
main.go

@ -3,7 +3,9 @@ package main @@ -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) { @@ -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) { @@ -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) { @@ -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()

Loading…
Cancel
Save