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>
This commit is contained in:
@@ -2,6 +2,8 @@ defmodule Omnibot.Contrib.Linkbot do
|
||||
use Omnibot.Module
|
||||
require Logger
|
||||
|
||||
@default_config timeout: 30_000
|
||||
|
||||
defmodule Client do
|
||||
use Tesla
|
||||
|
||||
@@ -13,6 +15,7 @@ defmodule Omnibot.Contrib.Linkbot do
|
||||
|
||||
def get_title(url) do
|
||||
if should_get?(url) do
|
||||
Process.sleep(11_000)
|
||||
resp = get!(url)
|
||||
%{"title" => title} = Regex.named_captures(@title_regex, resp.body)
|
||||
title
|
||||
|
||||
Reference in New Issue
Block a user