changes for new server
This commit is contained in:
54
discord.go
54
discord.go
@ -26,7 +26,7 @@ func configureDiscord() {
|
|||||||
dg.AddHandler(ready)
|
dg.AddHandler(ready)
|
||||||
dg.AddHandler(readReaction)
|
dg.AddHandler(readReaction)
|
||||||
dg.AddHandler(messageCreate)
|
dg.AddHandler(messageCreate)
|
||||||
dg.AddHandler(guildMemberAdd)
|
//dg.AddHandler(guildMemberAdd)
|
||||||
session = dg
|
session = dg
|
||||||
|
|
||||||
err = dg.Open()
|
err = dg.Open()
|
||||||
@ -144,58 +144,7 @@ func alphaOnly(s string) bool {
|
|||||||
}
|
}
|
||||||
return true
|
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) {
|
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
defer log.PanicSafe()
|
defer log.PanicSafe()
|
||||||
@ -203,7 +152,6 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.GuildID == "" {
|
if m.GuildID == "" {
|
||||||
handlePM(s, m)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.ChannelID == config.MonitorChan && strings.HasPrefix(m.Content, "!verify") {
|
if m.ChannelID == config.MonitorChan && strings.HasPrefix(m.Content, "!verify") {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ func (u User) McWhitelist() {
|
|||||||
|
|
||||||
func configureMinecraft() {
|
func configureMinecraft() {
|
||||||
log.LogInfo("Starting MinecraftServer")
|
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()
|
mcIn, _ = server.StdinPipe()
|
||||||
mcOut, _ = server.StdoutPipe()
|
mcOut, _ = server.StdoutPipe()
|
||||||
mcErr, _ := server.StderrPipe()
|
mcErr, _ := server.StderrPipe()
|
||||||
|
|||||||
Reference in New Issue
Block a user