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:
2020-07-16 17:54:34 -07:00
parent 4c93b42fdc
commit 02470bcf1d
2 changed files with 11 additions and 9 deletions

View File

@@ -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,6 +148,7 @@ 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
if nick not in cfg[:ignore] do
words = Regex.split(@split_pattern, msg) |> MapSet.new() words = Regex.split(@split_pattern, msg) |> MapSet.new()
game_words = Wordbot.Db.unmatched_words(channel) |> MapSet.new() game_words = Wordbot.Db.unmatched_words(channel) |> MapSet.new()
MapSet.intersection(words, game_words) 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.") Irc.send_to(irc, channel, "#{nick}: Congrats! '#{word}' is good for 1 point.")
end) end)
end end
end
@impl true @impl true
def on_join(irc, channel, who) do def on_join(irc, channel, who) do

View File

@@ -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}]