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:
@@ -20,6 +20,9 @@ defmodule Omnibot.Module do
|
||||
@impl true
|
||||
def on_init(_cfg), do: nil
|
||||
|
||||
@impl true
|
||||
def default_config(), do: @default_config
|
||||
|
||||
def commands(), do: MapSet.to_list(@commands)
|
||||
end
|
||||
end
|
||||
@@ -97,6 +100,7 @@ defmodule Omnibot.Module do
|
||||
defoverridable Module
|
||||
|
||||
@commands MapSet.new()
|
||||
@default_config []
|
||||
@before_compile Omnibot.Module.Hooks
|
||||
end
|
||||
end
|
||||
@@ -114,6 +118,7 @@ defmodule Omnibot.Module do
|
||||
@callback on_part(irc :: pid(), channel :: String.t(), nick :: String.t()) :: any
|
||||
@callback on_kick(irc :: pid(), channel :: String.t(), nick :: String.t(), target :: String.t()) :: any
|
||||
@callback on_init(cfg :: any) :: any
|
||||
@callback default_config() :: any
|
||||
|
||||
defmacro command(cmd, opts) do
|
||||
quote generated: true do
|
||||
|
||||
Reference in New Issue
Block a user