Commit Graph

25 Commits

Author SHA1 Message Date
e2a746709d Update Plugin.GenServer to match the same pattern that Plugin.Supervisor does, remove Omnibot.Plugin
* 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>
2020-07-11 16:01:57 -07:00
9a8c6f2472 Finish up Plugin.Supervisor, replace markov and wordbot implementations with it
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>
2020-07-11 15:43:07 -07:00
8cddd8e78e Move markov to be a supervisor plugin
This is probably going to be necessary to avoid race conditions in the
ETS storage

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-09 14:51:33 -07:00
9c69ca7b72 Markov chains appear to be training correctly
* 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>
2020-07-08 17:25:26 -07:00
1a73a62a2c Add train/2 and add_weight/4 implementations to Markov Chain
* 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>
2020-07-08 12:59:34 -07:00
6d503089e4 Add binary search to Util
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>
2020-07-08 11:29:13 -07:00
d1428623a6 Add OnConnect plugin
Use this plugin to run IRC commands upon connecting to the server.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-06 17:01:29 -07:00
d73dabef43 Rename lib/contrib/wordbot.ex -> lib/contrib/wordbot/wordbot.ex
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:50:34 -07:00
4d7073cfcd Rename Module -> Plugin with basic find/replace
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:23:24 -07:00
fcfdb17daa Format and add some comments to the linkbot module
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:14:38 -07:00
e3f30d30c1 Make linkbot title parsing more robust
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>
2020-07-02 18:09:09 -07:00
67192f2c5e Fix small bug with wordbot word score choice
The game ID was accidentally being added as a word to the wordlist. This
is no longer the case.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:04:13 -07:00
d56c0bf75c Update wordbot leaderboard and scoreboard to use "denotified" nicks
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>
2020-07-02 17:23:29 -07:00
9b11c1c44d Remove old TODO
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 16:35:52 -07:00
0c15496579 Implement wordbot leaderboard command
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 16:35:19 -07:00
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
67ba7a5847 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>
2020-07-01 12:04:51 -07:00
7f6a5e8a90 Fix small bug with linkbot where Regex.scan() would return a list of lists, instead of a list of strings
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-06-14 18:10:10 -04:00
f12bc13e13 Remove test code and add hostname blacklist to Linkbot
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>
2020-06-14 16:41:40 -04:00
4083b5b858 Add default_config, and cfg[:timeout] for tasks
- 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>
2020-06-13 21:47:46 -04:00
9dc00562fd Add linkbot contrib module
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>
2020-06-13 20:59:58 -04:00
304a8d4164 WIP: Move Config.all_channels/0 and Config.channel_modules/1 logic into State; add State.add_loaded_module/2
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>
2020-06-13 17:13:05 -04:00
ed22d1bf0f Update modules to be more egonomic, add command macro
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>
2020-06-13 15:20:00 -04:00
e2e7ae22b8 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>
2020-06-12 18:24:11 -04:00
6340936895 Initial commit with IRC and bot example.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-06-12 17:29:35 -04:00