summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorMatthias Hecker <mail@apoc.cc>2020-04-15 20:26:54 +0200
committerMatthias Hecker <mail@apoc.cc>2020-04-15 20:26:54 +0200
commitff6d7e5d043da99b2da36f628d52b7b5df47119d (patch)
treefe513113e54536ff32cdd6ad66faf0e0a020792c /data
parent77540358a94db4c1fe21462c5f821692eb140df7 (diff)
refactor: wordlist shouldn't use bot singleton #35
also related to #41 and #6
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/games/azgame.rb6
-rw-r--r--data/rbot/plugins/games/hangman.rb2
-rw-r--r--data/rbot/plugins/games/shiritori.rb5
3 files changed, 6 insertions, 7 deletions
diff --git a/data/rbot/plugins/games/azgame.rb b/data/rbot/plugins/games/azgame.rb
index ca67881c..b4dbabc1 100644
--- a/data/rbot/plugins/games/azgame.rb
+++ b/data/rbot/plugins/games/azgame.rb
@@ -157,9 +157,9 @@ class AzGamePlugin < Plugin
lang = params[:lang]
addlang = params[:addlang]
autoadd = @autoadd_base + addlang.to_s
- if Wordlist.exist?(lang)
+ if Wordlist.exist?(@bot, lang)
# wordlists are assumed to be UTF-8, but we need to strip the BOM, if present
- words = Wordlist.get(lang)
+ words = Wordlist.get(@bot, lang)
if addlang and File.exist?(autoadd)
word += File.readlines(autoadd).map {|line| line.sub("\xef\xbb\xbf",'').strip}
end
@@ -600,7 +600,7 @@ class AzGamePlugin < Plugin
return _("az => start a game if none is running, show the current word range otherwise; you can say 'az <language>' if you want to play in a language different from the current bot default")
end
langs = @rules.keys
- wls = Wordlist.list
+ wls = Wordlist.list(@bot)
return [
_("az topics: play, rules, cancel, manage, check"),
_("available languages: %{langs}") % { :langs => langs.join(", ") },
diff --git a/data/rbot/plugins/games/hangman.rb b/data/rbot/plugins/games/hangman.rb
index 0177a348..890f821a 100644
--- a/data/rbot/plugins/games/hangman.rb
+++ b/data/rbot/plugins/games/hangman.rb
@@ -253,7 +253,7 @@ class HangmanPlugin < Plugin
params[:word].join(" ")
elsif params[:wordlist]
begin
- wordlist = Wordlist.get(params[:wordlist].join("/"), :spaces => true)
+ wordlist = Wordlist.get(@bot, params[:wordlist].join("/"), :spaces => true)
rescue
raise _("no such wordlist")
end
diff --git a/data/rbot/plugins/games/shiritori.rb b/data/rbot/plugins/games/shiritori.rb
index 3cb3c7b5..9ca23f9a 100644
--- a/data/rbot/plugins/games/shiritori.rb
+++ b/data/rbot/plugins/games/shiritori.rb
@@ -389,9 +389,8 @@ class ShiritoriPlugin < Plugin
unless ruleset.has_key?(:words)
if ruleset.has_key?(:wordlist_file)
begin
- ruleset[:words] =
- File.new(datafile(ruleset[:wordlist_file])).grep(
- ruleset[:listen]) {|l| ruleset[:normalize].call l.chomp}
+ ruleset[:words] = Wordlist.get(@bot, ruleset[:wordlist_file], :spaces => true)
+ .grep(ruleset[:listen]) {|l| ruleset[:normalize].call l.chomp}
rescue
raise "unable to load word list"
end