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:
2020-07-01 12:04:51 -07:00
parent 871b7771fe
commit 67ba7a5847
13 changed files with 332 additions and 5 deletions

28
lib/contrib/wordbot.ex Normal file
View 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