|
|
|
@ -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) { |
|
|
|
@ -179,7 +181,7 @@ func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) {
@@ -179,7 +181,7 @@ func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) {
|
|
|
|
|
func guildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) { |
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
go runPurge(s) |
|
|
|
|
banned:= false |
|
|
|
|
banned := false |
|
|
|
|
for uid, join := range config.Probations { |
|
|
|
|
if time.Since(join) < 2*time.Hour { |
|
|
|
|
if m.User.ID == uid { |
|
|
|
@ -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() |
|
|
|
@ -300,7 +318,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -300,7 +318,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
handlePM(s, m) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if m.ChannelID != config.MonitorChann && time.Since(config.BumpTime) > 2 * time.Hour && !strings.Contains(m.Content, "!d bump") { |
|
|
|
|
if m.ChannelID != config.MonitorChann && time.Since(config.BumpTime) > 2*time.Hour && !strings.Contains(m.Content, "!d bump") { |
|
|
|
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention())) |
|
|
|
|
} |
|
|
|
|
for role := range m.Member.Roles { |
|
|
|
@ -318,7 +336,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -318,7 +336,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if strings.HasPrefix(m.Content, "!d bump") { |
|
|
|
|
if time.Since(config.BumpTime) < 2 * time.Hour { |
|
|
|
|
if time.Since(config.BumpTime) < 2*time.Hour { |
|
|
|
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|