Add "ignore" list to wordbot plugin
Wordbot can now ignore users who send messages to the channel. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ defmodule Omnibot.Contrib.Wordbot do
|
||||
alias Omnibot.{Contrib.Wordbot, State, Util}
|
||||
require Logger
|
||||
|
||||
@default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5
|
||||
@default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5, ignore: []
|
||||
|
||||
@impl true
|
||||
def children(cfg) do
|
||||
@@ -148,6 +148,7 @@ defmodule Omnibot.Contrib.Wordbot do
|
||||
|
||||
@impl true
|
||||
def on_channel_msg(irc, channel, nick, msg) do
|
||||
if nick not in cfg[:ignore] do
|
||||
words = Regex.split(@split_pattern, msg) |> MapSet.new()
|
||||
game_words = Wordbot.Db.unmatched_words(channel) |> MapSet.new()
|
||||
MapSet.intersection(words, game_words)
|
||||
@@ -156,6 +157,7 @@ defmodule Omnibot.Contrib.Wordbot do
|
||||
Irc.send_to(irc, channel, "#{nick}: Congrats! '#{word}' is good for 1 point.")
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def on_join(irc, channel, who) do
|
||||
|
||||
@@ -13,7 +13,7 @@ config = %Config {
|
||||
]},
|
||||
{Omnibot.Contrib.Linkbot, channels: :all},
|
||||
{Omnibot.Contrib.Fortune, channels: :all},
|
||||
{Omnibot.Contrib.Wordbot, channels: ["#idleville"]},
|
||||
{Omnibot.Contrib.Wordbot, channels: ["#idleville"], ignore: ["username"]},
|
||||
],
|
||||
|
||||
#module_paths: [{"modules", recurse: true}]
|
||||
|
||||
Reference in New Issue
Block a user