From 6b92467d1f931560499e4b3f66c8e724685e5dd8 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Tue, 6 Apr 2021 09:07:51 -0400 Subject: [PATCH] Updated status and added verification retrieval --- main.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 450c30a..6a90a2d 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "net/url" "os" "os/signal" + "path/filepath" "strings" "syscall" "time" @@ -33,6 +34,8 @@ 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" + gitCommit string ) func init() { @@ -157,7 +160,7 @@ func runPurge(s *discordgo.Session) { func ready(s *discordgo.Session, event *discordgo.Ready) { // Set the playing status. - s.UpdateGameStatus(0, "DreamDaddy v2.5 NOHEIC") + s.UpdateGameStatus(0, fmt.Spritnf("DreamDaddy v%+v %+v", version, gitCommit)) } func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { @@ -391,6 +394,9 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { if strings.HasPrefix(m.Content, rebootToken) { exit(s) } + if strings.HasPrefix(m.Content, "!veri") { + findVerification(s, m) + } if strings.HasPrefix(m.Content, "!quote") { quotes = append(quotes, strings.ReplaceAll(m.Content, "!quote", "")) } @@ -404,3 +410,29 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { } } } + +func findVerification(s *discordgo.Session, m *discordgo.MessageCreate) { + parts := strings.Split(m.Content, " ") + discordId := parts[1] + matches, err := filepath.Glob(fmt.Sprintf("*%+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 + } + user, err := s.GuildMember(config.GuildID, discordId) + if err != nil { + log.LogErrorType(err) + } + msg := fmt.Sprintf("```%+v\nJoined: %+v\n", user.User.Username, user.JoinedAt) + s.ChannelFileSendWithMessage(m.ChannelID, msg, fmt.Sprintf("%+v Verification", discordId), verificationImage) +}