From 7f6a5e8a905936e992bac12b9c01a9cef7a61b9d Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sun, 14 Jun 2020 18:10:10 -0400 Subject: [PATCH] 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 --- lib/contrib/linkbot.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/contrib/linkbot.ex b/lib/contrib/linkbot.ex index 75f2e8d..70ebb81 100644 --- a/lib/contrib/linkbot.ex +++ b/lib/contrib/linkbot.ex @@ -3,7 +3,6 @@ defmodule Omnibot.Contrib.Linkbot do require Logger @default_config timeout: 30_000 - @hostname_blacklist ~r/(^localhost$|\.local$|\.localdomain$|\.home$|^[^.]+$|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$)/i def blacklisted?(url) do @@ -23,6 +22,7 @@ defmodule Omnibot.Contrib.Linkbot do def get_title(url) do if should_get?(url) do + Logger.info("Fetching #{url}") resp = get!(url) %{"title" => title} = Regex.named_captures(@title_regex, resp.body) title @@ -46,6 +46,7 @@ defmodule Omnibot.Contrib.Linkbot do @impl true def on_channel_msg(irc, channel, _nick, line) do Regex.scan(@url_regex, line) + |> Enum.flat_map(& &1) |> Enum.map(fn url -> Client.get_title(url) end) |> Enum.each(fn title -> Irc.send_to(irc, channel, title) end) end