merge/1 takes a nonempty list of markov chains to merge
merge/2 takes two markov chains of the same order and sums their weights
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Markov chains each have their own process keeping it updated and
synchronized. The markov plugin has been upgraded to account for this.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Markov chains will train and generate chains correctly now
* Implement Markov.save_chains/0
* Add a couple more utils that help accomplish the above
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Wordbot does not IO.inspect() the winners of the round
* Split Omnibot.Plugin.base_children/1 into base_children_before/1 and
base_children_after/1 for plugins that come before and after the
children in the module
* Other minor changes
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Plugins all derive from Omnibot.Plugin. There still is a base plugin,
in case we want to have another plugin backend instead of a GenServer
* All plugins are monitored by a unique Plugin.Supervisor, which is in
turn started by the PluginSupervisor (yes this is confusing, yes it
needs to be renamed)
* Any other auxiliary child processes may be started through the
Plugin.children/1 function.
* By default, plugins have a CfgState process which is an Agent that
keeps track of the plugin's configuration and state
* Plugin API is now called through the GenServer backend for better
synchronicity.
* Very few changes to the front-facing Plugin API, which is nice
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* using Plugin.GenServer now uses Plugin.Base so that is not required
* Remove Omnibot.Plugin because all it did was include Plugin.GenServer
and Plugin.Base
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Both markov and wordbot have some auxiliary processes that run to keep
track of things. Previously, they both had custom supervisors grafted on
to the Plugin.Base - now, this grafting is automated with
Plugin.Supervisor.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Markov chains record words correctly from a single line to the end of
their line with a couple of exceptions.
* Start working on using ETS for storing markov chains, and saving it as
a DETS periodically
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* train/2 takes a chain and a list of words to train them on
* add_weight/4 takes a chain, a list of words (the key), the word it
points to, and an optional increment which will increment the value of
a weight, or insert the weight.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
For some reason there doesn't appear to be a binary search function in
Elixir's standard library, so this implements that.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Linkbot titles now check the "meta" tags for either "og:title" or
"title" attributes. This is usually a more accurate/correct title than
using the "title" tag, but this is checked as a last resort.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Nicknames that are sent by wordbot for the leaderboard command and the
end-of-game scoreboard are split up by zero-width space characters, to
avoid pinging the users at random times.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
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>
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>
Linkbot will now block addresses that attempt to use localhost, *.local,
*.home, *.localdomain, hosts that don't have a dot in them, and IP
addresses. This is to avoid exposing the bot to local addresses on the
host computer.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
- Using the @default_config attribute in a module will fill out a default
value.
- cfg[:timeout] sets the timeout for the task for this module to finish.
- Update Omnibot.Irc.route_msg/2 to have each task spawn a second task,
while the first task waits for its child to finish, otherwise killing
it.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Linkbot listens for http:// and https:// links, and attempts to get
their titles.
This also adds the "tesla" dependency to mix.exs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
The problem:
When we're going through the list of modules to send messages to based
on the channels they're a part of, it was being done so through the
config. Since the config doesn't (and shouldn't) list all of the core
modules that get included, any core modules that were loaded and running
under the ModuleSupervisor would not get included in the router's
attempt to send messages to a module.
Now, the Config.all_channels and Config.channel_modules functions live
in State, and State has a new "add_loaded_module" function where loaded
modules are registered. The aforementioned moved functions will use this
as the "source of truth" when deciding where to send messages for
modules to handle.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Modules are now defined using on_{msg,channel_msg,join,part,kick}.
Additionally, commands can be defined using a convenient macro.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
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>