Add Omnibot.Module

Modules can easily be defined with `use Omnibot.Module`.
Omnibot.Contrib.Fortune has been updated to use this.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-06-12 18:24:11 -04:00
parent 6340936895
commit e2e7ae22b8
4 changed files with 95 additions and 30 deletions

View File

@@ -22,12 +22,16 @@ defmodule Omnibot.Irc do
def send_msg(irc, command, param), do: send_msg(irc, command, [param])
def send_to(channel, text), do: send_to(__MODULE__, channel, text)
def send_to(irc, channel, text), do: send_msg(irc, "PRIVMSG", [channel, text])
def join(channel), do: join(__MODULE__, channel)
def join(irc, channel), do: send_msg(irc, "JOIN", channel)
def part(channel), do: part(__MODULE__, channel)
def part(irc, channel), do: send_msg(irc, "PART", channel)
def sync_channels(), do: sync_channels(__MODULE__)
def sync_channels(irc), do: GenServer.cast(irc, :sync_channels)
## Server callbacks