Files
omnibot/lib/contrib/wordbot.ex
Alek Ratzloff 7f8a886550 Polish off wordbot implementation, add Omnibot.Module.GenServer
Wordbot implementation now uses the new Omnibot.Module.GenServer module,
which uses a GenServer instead of an Agent. This way, the module can
receive messages and makes storage a little easier.

Beyond that, minor changes all around.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 16:23:38 -07:00

29 lines
819 B
Elixir

defmodule Omnibot.Contrib.Wordbot do
use Omnibot.Module.Base
use Supervisor
require Logger
alias Omnibot.Contrib.Wordbot
@default_config wordbot_source: "words.txt", wordbot_db: "wordbot.db", words_per_round: 300, hours_per_round: 5
def start_link(opts) do
Supervisor.start_link(__MODULE__, opts[:cfg], opts)
end
@impl true
def init(cfg) do
children = [
{Task.Supervisor, name: Omnibot.Contrib.Wordbot.Watchers, strategy: :one_for_one},
Wordbot.Db.child_spec(cfg[:wordbot_db]),
{Wordbot.Bot, cfg: cfg, name: Omnibot.Contrib.Wordbot.Bot},
]
Supervisor.init(children, strategy: :one_for_all)
end
def on_msg(irc, msg), do: Wordbot.Bot.on_msg(irc, msg)
def on_channel_msg(irc, channel, nick, msg), do: Wordbot.Bot.on_channel_msg(irc, channel, nick, msg)
end