@ -8,64 +8,12 @@ import (
@@ -8,64 +8,12 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/bwmarrin/discordgo"
)
func status ( s * discordgo . Session ) {
defer log . PanicSafe ( )
status := fmt . Sprintf ( "Uptime: %+v\n" , time . Since ( startupTime ) )
status += fmt . Sprintf ( "Last bump: %+v\n" , time . Since ( config . BumpTime ) )
status += fmt . Sprintf ( "Last bumper: <@%+v>\n" , userFromID ( config . LastBumper ) . Username )
status += fmt . Sprintf ( "Bump needed: %+v\n" , bump )
if len ( config . Unverified ) > 0 {
status += "Unverified users:\n```"
for k , v := range config . Unverified {
uvUser := userFromID ( k )
status += fmt . Sprintf ( "\n%+v will be removed in %+v" , uvUser . Username , time . Until ( v . Add ( 1 * time . Hour ) ) )
}
status += "```"
} else {
status += "There are no unverified users.\n"
}
if len ( config . Verifications ) > 0 {
status += "Pending verifications:\n"
status += "```"
for _ , v := range config . Verifications {
status += fmt . Sprintf ( "%+v has submitted a verification." , v . Username )
}
status += "```"
} else {
status += "There are no pending verifications."
}
if len ( config . Probations ) > 0 {
status += "\nThe following users are on probation: \n```"
for uid , join := range config . Probations {
probationUser := userFromID ( uid )
status += fmt . Sprintf ( "%+v for another %+v\n" , probationUser . Username , time . Until ( join . Add ( 2 * time . Hour ) ) )
}
status += "```"
}
s . ChannelMessageSend ( config . AdminChannel , status )
statistics := "```"
for k , v := range config . Stats {
adminUser , err := s . GuildMember ( config . GuildID , k )
if err == nil {
statistics += fmt . Sprintf ( "\n%+v: %+v" , adminUser . User . Username , v + 1 )
} else {
log . LogErrorType ( err )
}
}
statistics += "\n```"
log . LogInfo ( "Private statistics: %+v" , statistics )
go runPurge ( s )
return
}
func rebootBump ( ) {
time . Sleep ( time . Until ( config . BumpTime . Add ( 2 * time . Hour ) ) )
dg . ChannelMessageSend ( config . AdminChannel , "!d bump is ready" )
@ -141,48 +89,6 @@ func saveConfig() {
@@ -141,48 +89,6 @@ func saveConfig() {
}
}
func bumpSetTime ( s * discordgo . Session , m * discordgo . MessageCreate ) {
bump = false
parts := strings . Split ( m . Content , " " )
timer , err := strconv . Atoi ( parts [ 1 ] )
if err != nil {
s . ChannelMessageSend ( m . ChannelID , fmt . Sprintf ( "Unable to decode timer: %+v" , parts [ 1 ] ) )
}
config . BumpTime = time . Now ( ) . Add ( time . Duration ( timer ) * time . Minute ) . Add ( - 2 * time . Hour )
s . ChannelMessageSend ( m . ChannelID , fmt . Sprintf ( "New bump time: %+v, expecting bump at %+v" , config . BumpTime , config . BumpTime . Add ( 2 * time . Hour ) ) )
}
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 )
}
func bumpTimer ( s * discordgo . Session ) {
if ! bump {
return