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>
This commit is contained in:
2020-07-02 16:23:38 -07:00
parent 67ba7a5847
commit 7f8a886550
8 changed files with 222 additions and 22 deletions

View File

@@ -18,6 +18,11 @@ defmodule Omnibot.Contrib.Linkbot do
plug Tesla.Middleware.FollowRedirects, max_redirects: 10
plug Tesla.Middleware.Compression, format: "gzip"
# TODO instead of checking for <title> exclusively, do this:
# 1. check for "meta" tag (in the header) with a "property" attribute of "og:title", and fetch the "content" attribute of that tag
# 2. check for meta tag with attribute "name" == "title", and fetch "content" attribute
# 3. Fall back to the <title>
@title_regex ~r"<title>(?<title>.+)</title>"i
def get_title(url) do
@@ -50,4 +55,5 @@ defmodule Omnibot.Contrib.Linkbot do
|> Enum.map(fn url -> Client.get_title(url) end)
|> Enum.each(fn title -> Irc.send_to(irc, channel, title) end)
end
end