Alexia.Governor (alexia v0.8.1)
The Governor module provides certain utilities to be used by bots.
Link to this section Summary
Functions
Add specific bot information to the ETS table
Assigns a bot id to a bot which will be used throughout the application
Default Text Command
Given the bot_token
it hashes it and returns the bot_matcher_pid or nil if it doesn't exist.
Given an update (either from getUpdates or webhook) it extracts the chat_id
Given the bot
map it takes the token and hashes it. If the webhook is set up then it
sets the correct webhook URL with the hashed token.
Hashes the bot token against an unique random string called :secret_mix
Used internally to route bot information
Link to this section Functions
add_bot_info(bot_token, type, data)
Add specific bot information to the ETS table
assign_bot_id(bot)
Assigns a bot id to a bot which will be used throughout the application
Default Text Command
get_bot_id(bot_name)
get_bot_info(bot_id, type \\ :matcher)
Given the bot_token
it hashes it and returns the bot_matcher_pid or nil if it doesn't exist.
Args:
bot_token
- Hashed bot tokentype
- Type of info, defaults to :matcher Returns the bot Alexia.Governor.Matcher pid OR the specified type stored previously
get_chat_id(update)
Given an update (either from getUpdates or webhook) it extracts the chat_id
It can be from an inline_query, callback_query, message, edited message or channel post.
get_from_id(update)
get_token(bot_id)
setup_bot_webhook(bot)
Given the bot
map it takes the token and hashes it. If the webhook is set up then it
sets the correct webhook URL with the hashed token.
Args:
bot
- Bot map containing bot_name, token and other settings. Returns the bot bot_matcher_pid
token_to_hash(token)
Hashes the bot token against an unique random string called :secret_mix
Used internally to route bot information