From a103e364952dd3d8feb121a6a0e16720d3fbdae0 Mon Sep 17 00:00:00 2001 From: Rudi Date: Thu, 31 Mar 2022 22:09:01 -0400 Subject: [PATCH] changes for new server --- discord.go | 54 +--------------------------------------------------- minecraft.go | 2 +- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/discord.go b/discord.go index 7b31abb..d989995 100644 --- a/discord.go +++ b/discord.go @@ -26,7 +26,7 @@ func configureDiscord() { dg.AddHandler(ready) dg.AddHandler(readReaction) dg.AddHandler(messageCreate) - dg.AddHandler(guildMemberAdd) + //dg.AddHandler(guildMemberAdd) session = dg err = dg.Open() @@ -144,58 +144,7 @@ func alphaOnly(s string) bool { } return true } -func handlePM(s *discordgo.Session, m *discordgo.MessageCreate) { - defer log.PanicSafe() - for k, v := range pendingV { - if v.DiscordID == m.Author.ID { - parts := strings.Split(m.Content, " ") - - if strings.HasPrefix(m.Content, "!sitnet") { - if len(parts) != 2 || !alphaOnly(parts[1]) || len(parts[1]) > 12 { - s.ChannelMessageSend(m.ChannelID, "You have sent an invalid SITNET ID. Your SITNET ID is your SUNY Poly email address, up until the @sunypoly.edu. For example, urbanc@sunypoly.edu would have a SITNET ID of urbanc. He would say `!sitnet urbanc`") - return - } - v.SITNET = parts[1] - v.sendEmail() - pendingV[k] = v - s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Thanks! I have sent an email to %+v@sunypoly.edu from %+v with further instructions.", v.SITNET, config.MyEmail)) - } - if strings.HasPrefix(m.Content, "!verify") { - if len(parts) != 3 { - s.ChannelMessageSend(m.ChannelID, "You have sent an invalid verification, please ensure you are sending ```!verify $code $minecraftID``` Please ensure there are no extra spaces, also your minecraftID is case sensitive.") - return - } - if parts[1] != v.Code { - s.ChannelMessageSend(m.ChannelID, "You have sent an invalid verification code, please verify using the code from your email.") - return - } - var u User - u.DiscordID = v.DiscordID - u.Email = v.SITNET - u.McUser = strings.Replace(parts[2], "$", "", -1) - if v.SITNET == parts[2] { - s.ChannelMessageSend(m.ChannelID, "SITNET Can not be the same as Minecraft Username. Please append a dollar sign to the end of your minecraft username if it actually is the same as your sitnet. For example urbanc would put urbanc$ as his minecraft username to dismiss this message.") - return - } - log.LogDebug(fmt.Sprintf("Attempting to write %+v from verification %+v", u, v)) - err := u.Write() - if err != nil { - s.ChannelMessageSend(m.ChannelID, "There was an issue with your verification. Please check in with an administrator in the #unverified channel.") - return - } - u.McWhitelist() - s.ChannelMessageSend(m.ChannelID, "Welcome! You have successfully verified. The server address is polymc.cs.sunyit.edu - see you there!") - s.GuildMemberRoleRemove(config.GuildID, u.DiscordID, config.MonitorRole) - s.GuildMemberRoleAdd(config.GuildID, u.DiscordID, config.VerifiedRole) - s.GuildMemberNickname(config.GuildID, u.DiscordID, v.SITNET) - pendingV[k] = pendingV[len(pendingV)-1] // Copy last element to index i. - pendingV = pendingV[:len(pendingV)-1] // Truncate slice. - } - } - } - -} func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { defer log.PanicSafe() @@ -203,7 +152,6 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { return } if m.GuildID == "" { - handlePM(s, m) return } if m.ChannelID == config.MonitorChan && strings.HasPrefix(m.Content, "!verify") { diff --git a/minecraft.go b/minecraft.go index 018a678..46caec0 100644 --- a/minecraft.go +++ b/minecraft.go @@ -26,7 +26,7 @@ func (u User) McWhitelist() { func configureMinecraft() { log.LogInfo("Starting MinecraftServer") - server := exec.Command("java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-Xms4G", "-Xmx8G", "-Dsun.rmi.dgc.server.gcInterval=2147483646", "-XX:G1NewSizePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M", "-jar", "/opt/minecraft/paper/server.jar", "nogui") + server := exec.Command("screen", "-r", "1234") mcIn, _ = server.StdinPipe() mcOut, _ = server.StdoutPipe() mcErr, _ := server.StderrPipe()