@ -3,14 +3,9 @@ package main
@@ -3,14 +3,9 @@ package main
import (
"flag"
"fmt"
"io"
"math/rand"
"net/http"
"net/url"
"os"
"os/signal"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
@ -35,7 +30,7 @@ var (
@@ -35,7 +30,7 @@ var (
lastPM = make ( map [ string ] time . Time )
introMsg = make ( map [ string ] string )
quotes = [ ] string { "The hardest choices require the strongest wills." , "You're strong, but I could snap my fingers and you'd all cease to exist." , "Fun isn't something one considers when balancing the universe. But this... does put a smile on my face." , "Perfectly balanced, as all things should be." , "I am inevitable." }
version = "2.6 "
version = "2.7 "
gitCommit string
)
@ -86,7 +81,7 @@ func main() {
@@ -86,7 +81,7 @@ func main() {
log . LogInfo ( "Thanos is now running. Press CTRL-C to exit." )
go purgeTimer ( dg )
if time . Since ( config . BumpTime ) > 2 * time . Hour {
if time . Since ( config . BumpTime ) > 2 * time . Hour {
dg . ChannelMessageSend ( config . AdminChannel , "!d bump is ready" )
}
sc := make ( chan os . Signal , 1 )
@ -332,31 +327,6 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
@@ -332,31 +327,6 @@ func readReaction(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
log . LogInfo ( "%+v" , verification . prettyPrint ( ) )
delete ( config . Verifications , m . MessageID )
}
func storeVerification ( v Verification ) {
defer log . PanicSafe ( )
fileURL , _ := url . Parse ( v . Photo )
path := fileURL . Path
segments := strings . Split ( path , "/" )
fileName := segments [ len ( segments ) - 1 ]
file , _ := os . Create ( fmt . Sprintf ( "./verifications/%s-%s-%s" , v . UserID , v . Username , fileName ) )
client := http . Client {
CheckRedirect : func ( r * http . Request , via [ ] * http . Request ) error {
r . URL . Opaque = r . URL . Path
return nil
} ,
}
resp , err := client . Get ( v . Photo )
if err != nil {
log . LogError ( "Unable to download verification %s-%s-%s" , v . UserID , v . Username , fileName )
}
defer resp . Body . Close ( )
defer file . Close ( )
_ , err = io . Copy ( file , resp . Body )
if err != nil {
log . LogError ( "Unable to store verification %s-%s-%s" , v . UserID , v . Username , fileName )
}
}
func messageCreate ( s * discordgo . Session , m * discordgo . MessageCreate ) {
defer log . PanicSafe ( )
@ -414,37 +384,3 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
@@ -414,37 +384,3 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
}
}
}
func findVerification ( s * discordgo . Session , m * discordgo . MessageCreate ) {
defer log . PanicSafe ( )
parts := strings . Split ( m . Content , " " )
discordId := parts [ 1 ]
_ , err := strconv . Atoi ( discordId )
if err != nil {
discordId = idFromUsername ( discordId )
}
user , err := s . GuildMember ( config . GuildID , discordId )
if err != nil {
log . LogErrorType ( err )
}
matches , err := filepath . Glob ( fmt . Sprintf ( "./verifications/*%+v*" , discordId ) )
if err != nil {
log . LogErrorType ( err )
return
}
if len ( matches ) != 1 {
s . ChannelMessageSend ( m . ChannelID , fmt . Sprintf ( "Error finding verification for ID %+v" , discordId ) )
return
}
verificationImage , err := os . Open ( matches [ 0 ] )
if err != nil {
log . LogErrorType ( err )
return
}
msg := fmt . Sprintf ( "```%+v\nJoined: %+v\n```" , user . User . Username , user . JoinedAt )
s . ChannelFileSendWithMessage ( m . ChannelID , msg , fmt . Sprintf ( "%+v Verification" , discordId ) , verificationImage )
}