Skip to content
Snippets Groups Projects
Commit f200233e authored by Ophestra's avatar Ophestra
Browse files

fix the thing in the thing

parent af29d83b
Branches master
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"os" "os"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
) )
...@@ -24,8 +25,15 @@ var conf = struct { ...@@ -24,8 +25,15 @@ var conf = struct {
MessageOverride map[string]string `json:"message_override"` MessageOverride map[string]string `json:"message_override"`
}{} }{}
var uid string var (
var gid map[string]bool uid string
gid map[string]bool
)
var (
state = make(map[string]bool)
lock = sync.RWMutex{}
)
// Setup reads configuration file and sets up disboard parser and reminder. // Setup reads configuration file and sets up disboard parser and reminder.
//goland:noinspection GoUnusedExportedFunction //goland:noinspection GoUnusedExportedFunction
...@@ -92,6 +100,8 @@ func disboardCreateHandler(context *multiplexer.Context) { ...@@ -92,6 +100,8 @@ func disboardCreateHandler(context *multiplexer.Context) {
if bonker == nil { if bonker == nil {
return return
} }
} else {
return
} }
if !context.HandleError(context.Session.ChannelTyping(context.Channel.ID)) { if !context.HandleError(context.Session.ChannelTyping(context.Channel.ID)) {
...@@ -104,6 +114,16 @@ func disboardCreateHandler(context *multiplexer.Context) { ...@@ -104,6 +114,16 @@ func disboardCreateHandler(context *multiplexer.Context) {
} }
func bonkTimer(guild string, user *discordgo.User, messageSend func(message string) *discordgo.Message) { func bonkTimer(guild string, user *discordgo.User, messageSend func(message string) *discordgo.Message) {
lock.RLock()
if state[guild] {
return
}
lock.RUnlock()
lock.Lock()
state[guild] = true
lock.Unlock()
log.Infof("User %s bonked in jail %s.", user.ID, guild) log.Infof("User %s bonked in jail %s.", user.ID, guild)
time.Sleep(120 * time.Minute) time.Sleep(120 * time.Minute)
...@@ -112,4 +132,8 @@ func bonkTimer(guild string, user *discordgo.User, messageSend func(message stri ...@@ -112,4 +132,8 @@ func bonkTimer(guild string, user *discordgo.User, messageSend func(message stri
message = "%s BONK!" message = "%s BONK!"
} }
messageSend(fmt.Sprintf(message, user.Mention())) messageSend(fmt.Sprintf(message, user.Mention()))
lock.Lock()
state[guild] = false
lock.Unlock()
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment