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}
|
alias Omnibot.{Contrib.Wordbot, State, Util}
|
||||||
require Logger
|
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
|
@impl true
|
||||||
def children(cfg) do
|
def children(cfg) do
|
||||||
@@ -148,13 +148,15 @@ defmodule Omnibot.Contrib.Wordbot do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def on_channel_msg(irc, channel, nick, msg) do
|
def on_channel_msg(irc, channel, nick, msg) do
|
||||||
words = Regex.split(@split_pattern, msg) |> MapSet.new()
|
if nick not in cfg[:ignore] do
|
||||||
game_words = Wordbot.Db.unmatched_words(channel) |> MapSet.new()
|
words = Regex.split(@split_pattern, msg) |> MapSet.new()
|
||||||
MapSet.intersection(words, game_words)
|
game_words = Wordbot.Db.unmatched_words(channel) |> MapSet.new()
|
||||||
|> Enum.each(fn word ->
|
MapSet.intersection(words, game_words)
|
||||||
Wordbot.Db.add_score(channel, nick, word, msg)
|
|> Enum.each(fn word ->
|
||||||
Irc.send_to(irc, channel, "#{nick}: Congrats! '#{word}' is good for 1 point.")
|
Wordbot.Db.add_score(channel, nick, word, msg)
|
||||||
end)
|
Irc.send_to(irc, channel, "#{nick}: Congrats! '#{word}' is good for 1 point.")
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ config = %Config {
|
|||||||
]},
|
]},
|
||||||
{Omnibot.Contrib.Linkbot, channels: :all},
|
{Omnibot.Contrib.Linkbot, channels: :all},
|
||||||
{Omnibot.Contrib.Fortune, channels: :all},
|
{Omnibot.Contrib.Fortune, channels: :all},
|
||||||
{Omnibot.Contrib.Wordbot, channels: ["#idleville"]},
|
{Omnibot.Contrib.Wordbot, channels: ["#idleville"], ignore: ["username"]},
|
||||||
],
|
],
|
||||||
|
|
||||||
#module_paths: [{"modules", recurse: true}]
|
#module_paths: [{"modules", recurse: true}]
|
||||||
|
|||||||
Reference in New Issue
Block a user