From 32d2c83a11dd3fd89df0ef906cb5c146df7c61d5 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Thu, 29 Oct 2020 11:51:12 -0400 Subject: [PATCH] Auto grab Unverified people, and remove verifications after the user leaves --- main.go | 19 ++++++++++++++++--- types.go | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 96a6cdb..535c651 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,7 @@ func main() { defer log.PanicSafe() startupTime = time.Now() lastActiveTime = time.Now() - lastActiveChan = "627620309754839070" + lastActiveChan = config.AdminChannel if token == "" { log.LogPanic("No token provided. Please run: disgord-thanos -t ") } @@ -154,12 +154,20 @@ func runPurge(s *discordgo.Session) { s.ChannelMessageDelete(config.MonitorChann, message.ID) } } + saveConfig() } func ready(s *discordgo.Session, event *discordgo.Ready) { // Set the playing status. - s.UpdateStatus(0, "DreamDaddy v0.8") + s.UpdateStatus(0, "DreamDaddy v0.9") +} + +func guildMemberRoleAdd(s *discordgo.Session, m *discordgo.GuildMemberRoleAdd) { + defer log.PanicSafe() + config.Unverified[m.User.ID] = time.Now() + config.Probations[m.User.ID] = time.Now() + saveConfig() } func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) { @@ -168,6 +176,7 @@ func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) { config.Probations[m.User.ID] = time.Now() s.GuildMemberRoleAdd(config.GuildID, m.User.ID, config.MonitorRole) s.ChannelMessageSend(config.MonitorChann, fmt.Sprintf("Welcome %+v, you may PM me your verification, or I will ban you in an hour!\nSay \"!rules\" in this channel, without quotes for the rules. You may private/direct message me for verification instructions.\n\nYou will not be able to read/see other channels or users until you verify.", m.User.Mention())) + saveConfig() } func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) { @@ -177,6 +186,7 @@ func guildMemberBanned(s *discordgo.Session, m *discordgo.GuildBanAdd) { delete(config.Probations, uid) } } + saveConfig() } func guildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) { @@ -194,7 +204,10 @@ func guildMemberRemove(s *discordgo.Session, m *discordgo.GuildMemberRemove) { delete(config.Probations, uid) } } + delete(config.Unverified, m.User.ID) s.ChannelMessageSend(config.AdminChannel, fmt.Sprintf("%+v (@%+v) has left, ban: %+v", m.User.ID, m.User.Username, banned)) + saveConfig() + } func verifyMember(s *discordgo.Session, u discordgo.User) { @@ -203,7 +216,7 @@ func verifyMember(s *discordgo.Session, u discordgo.User) { s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole) st, _ := s.UserChannelCreate(u.ID) s.ChannelMessageSend(st.ID, "Your verification has been accepted, welcome!") - s.ChannelMessageSend("627620309754839070", fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention())) + s.ChannelMessageSend(config.IntroChann, fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention())) } func rejectVerification(s *discordgo.Session, u discordgo.User) { diff --git a/types.go b/types.go index c574d72..02989db 100644 --- a/types.go +++ b/types.go @@ -8,6 +8,7 @@ type Config struct { AdminChannel string AdminRole string MonitorRole string + IntroChann string MonitorChann string VerifiedRole string BumpTime time.Time