WIP: Wordbot
Wordbot is a little more complex of a bot module and I've been working on it here. Other than wordbot module, a few minor tweaks have been added all around that don't really affect anything. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
28
lib/contrib/wordbot.ex
Normal file
28
lib/contrib/wordbot.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
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"
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user