summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Gerus <arachnist@i.am-a.cat>2015-12-12 13:13:19 +0100
committerRobert Gerus <arachnist@i.am-a.cat>2015-12-12 13:13:19 +0100
commit2b86f24cecf86b62b9b3deb0807ba99204acc2b1 (patch)
treeaf9876ee0098fa0f4d9f85c0ce00a4eaef2b4d7e
parent54728173b269e2783bdd1ab790761d6bf4518dc0 (diff)
downloadgorepost-2b86f24cecf86b62b9b3deb0807ba99204acc2b1.tar.gz
gorepost-2b86f24cecf86b62b9b3deb0807ba99204acc2b1.tar.bz2
gorepost-2b86f24cecf86b62b9b3deb0807ba99204acc2b1.tar.xz
gorepost-2b86f24cecf86b62b9b3deb0807ba99204acc2b1.zip
Fix jan and papiez plugins.
Yay, more locks. I wonder if there's a better way…
-rw-r--r--bot/bot.go7
-rw-r--r--bot/jan.go4
-rw-r--r--bot/papiez.go4
-rw-r--r--bot/plugins_test.go4
4 files changed, 13 insertions, 6 deletions
diff --git a/bot/bot.go b/bot/bot.go
index 9d136d6..e5c1d50 100644
--- a/bot/bot.go
+++ b/bot/bot.go
@@ -2,10 +2,17 @@ package bot
import (
"github.com/arachnist/gorepost/config"
+ "sync"
)
var cfg *config.Config
+var cfgLock sync.Mutex
func Initialize(config *config.Config) {
cfg = config
+ cfgLock.Unlock()
+}
+
+func init() {
+ cfgLock.Lock()
}
diff --git a/bot/jan.go b/bot/jan.go
index 66ce125..de7274f 100644
--- a/bot/jan.go
+++ b/bot/jan.go
@@ -1,5 +1,3 @@
-// +build configfix
-//
// Copyright 2015 Robert S. Gerus. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@@ -52,6 +50,8 @@ func jan(output func(irc.Message), msg irc.Message) {
func lazyJanInit() {
defer janLock.Unlock()
+ cfgLock.Lock()
+ defer cfgLock.Unlock()
var err error
rand.Seed(time.Now().UnixNano())
objects, err = readLines(cfg.LookupString(nil, "DictionaryObjects"))
diff --git a/bot/papiez.go b/bot/papiez.go
index 4e68586..f38ee37 100644
--- a/bot/papiez.go
+++ b/bot/papiez.go
@@ -1,5 +1,3 @@
-// +build configfix
-//
// Copyright 2015 Robert S. Gerus. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@@ -35,6 +33,8 @@ func papiez(output func(irc.Message), msg irc.Message) {
func lazyPapiezInit() {
defer papiezLock.Unlock()
+ cfgLock.Lock()
+ defer cfgLock.Unlock()
var err error
rand.Seed(time.Now().UnixNano())
adjectives, err = readLines(cfg.LookupString(nil, "DictionaryAdjectives"))
diff --git a/bot/plugins_test.go b/bot/plugins_test.go
index 4f26abe..a786872 100644
--- a/bot/plugins_test.go
+++ b/bot/plugins_test.go
@@ -257,7 +257,7 @@ var eventTests = []struct {
},
},
},
- /* {
+ {
desc: "papież",
in: irc.Message{
Command: "PRIVMSG",
@@ -336,7 +336,7 @@ var eventTests = []struct {
Trailing: "Jan Paweł II predicate małe specified-object",
},
},
- }, */
+ },
{
desc: "roll multiple",
in: irc.Message{