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

Link to this function

add_bot_info(bot_token, type, data)

Add specific bot information to the ETS table

Link to this function

assign_bot_id(bot)

Assigns a bot id to a bot which will be used throughout the application

Link to this macro

expect(command, list)

(macro)

Default Text Command

Link to this function

get_bot_id(bot_name)

Link to this function

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 token
  • type - Type of info, defaults to :matcher Returns the bot Alexia.Governor.Matcher pid OR the specified type stored previously
Link to this function

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.

Link to this function

get_from_id(update)

Link to this function

get_token(bot_id)

Link to this macro

say(message)

(macro)
Link to this function

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
Link to this function

token_to_hash(token)

Hashes the bot token against an unique random string called :secret_mix Used internally to route bot information

Link to this function

token_to_hash(token, atom)