agala v2.5.1 Agala.Bot
This module represents main Bot supervisor.
Bot is a complex module, that can retreive information, handle it and send either to recepient or to another Bot module.
Defining new Bot requires only name
, provider
and handler
.
When the Bot is starting it will automaticly make supervision tree for next modules:
Agala.Bot.Receiver
- module which gets new data from the recepient defined as aprovider
Agala.Bot.Handler
- module which is handling messages, that are incoming to thebot
Agala.Bot.Responser
- module, that converts your application responses into form, acceptable by the recepientAgala.Bot.Storage
[OPTIONALY] - module with Storage behaviour, that helps with keeping cross-crashing data for providers
Starting your bot
You can start as many bots as you want. They should be differ from each other only by name.
Thus, they can have similar provider, handler and whatever you want. To specify bot instance,
use Agala.BotParams
- they should be passed as an argument to start new bot.
Example
# Starting 2 bots with different providers:
Supervisor.start_link([
{Agala.Bot, %{name: "telegram", provider: Agala.Provider.Telegram, handler: ...}},
{Agala.Bot, %{name: "vk", provider: Agala.Provider.Vk, handler: ...}},
])