Browse Source

Cleaning incoming message processing

master
Gregory Rudolph 3 years ago
parent
commit
7aa9372eaf
  1. 19
      discordMessage.go

19
discordMessage.go

@ -11,6 +11,10 @@ import (
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
defer log.PanicSafe() defer log.PanicSafe()
if m.GuildID == "" {
handlePM(s, m)
return
}
if m.Author.ID == "302050872383242240" && len(m.Embeds) > 0 && strings.Contains(m.Embeds[0].Description, "minutes until the server can be bumped") { if m.Author.ID == "302050872383242240" && len(m.Embeds) > 0 && strings.Contains(m.Embeds[0].Description, "minutes until the server can be bumped") {
log.LogDebug("Failed bump detected") log.LogDebug("Failed bump detected")
re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped") re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped")
@ -22,22 +26,21 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
Parts: strings.Split(m.Content, " ")[2:], Parts: strings.Split(m.Content, " ")[2:],
}) })
} }
if m.Author.ID == s.State.User.ID || m.Author.Bot { if m.Author.Bot {
return return
} }
if m.GuildID == "" {
handlePM(s, m) if isAdmin(m.Member) {
return adminInteraction(s, m.Author.ID)
} }
if m.ChannelID == config.MonitorChann {
if m.ChannelID == config.MonitorChann && !isAdmin(m.Member) {
if strings.Contains(m.Content, "erif") && !m.Author.Bot { if strings.Contains(m.Content, "erif") && !m.Author.Bot {
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v send me a private message for verification.", m.Author.Mention())) s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v send me a private message for verification.", m.Author.Mention()))
} }
return return
} }
if isAdmin(m.Member) {
adminInteraction(s, m.Author.ID)
}
if m.ChannelID != config.AdminChannel { if m.ChannelID != config.AdminChannel {
lastActiveChan = m.ChannelID lastActiveChan = m.ChannelID
lastActiveTime = time.Now() lastActiveTime = time.Now()

Loading…
Cancel
Save