agala v3.0.0 Agala.Bot.Common.Poller behaviour
You can use this behaviour for implementing your own Agala.Bot.Poller.
This poller has simple generic idea:
- In loop, it’s geting new messages via
get_updates/2
callback - Then, these messages are sent into chain one after one.
So, you actually can use Agala.Bot.Common.Poller
, and implement only one method -
get_updates/2
, which will get new messages.
Example
# Simple random numbers generator
defmodule Random.Poller do
use Agala.Bot.Common.Poller
def get_updates(bot_params) do
{[:rand.uniform], bot_params}
end
end
Link to this section Summary
Link to this section Types
Link to this section Callbacks
Link to this callback
bootstrap(bot_params)
bootstrap(bot_params :: Agala.BotParams.t()) :: {:ok, Agala.BotParams.t()} | {:error, any()}
This function is called inside init/1
callback of a GenServer
in order
to bootstrap initial params for a bot.
:private
and :common
params can be modified here
Link to this callback
get_updates(bot_params)
get_updates(bot_params :: Agala.BotParams.t()) :: {list(), Agala.BotParams.t()}
TODO: Docs