Matrigram code¶
Bot¶
-
class
matrigram.bot.
MatrigramBot
(*args, **kwargs)[source]¶ -
_get_chat_id
(client)[source]¶ Get telegram id associated with client.
Parameters: client (MatrigramClient) – The client to be queried. Returns: The chat_id associated to the client. Return type: str
-
_get_client
(chat_id)[source]¶ Get matrigram client.
Parameters: chat_id – Telegram user id. Returns: The client associated to the telegram user with chat_id. Return type: MatrigramClient
-
login
(msg, match)[source]¶ Perform login.
Parameters: - msg – The message object received from telegram user.
- match – Match object containing extracted data.
-
on_callback_query
(msg)[source]¶ Handle callback queries.
Route queries using
self.callback_query_routes
.Parameters: msg – The message object received from telegram user.
-
on_chat_message
(msg)[source]¶ Main entry point.
This function is our main entry point to the bot. Messages will be routed according to their content type.
Parameters: msg – The message object received from telegram user.
-
on_text_message
(msg)[source]¶ Handle text messages.
Route text messages using
self.routes
.Parameters: msg – The message object received from telegram user.
-
send_message
(sender, msg, client)[source]¶ Send message to telegram user.
Parameters: - sender (str) – Name of the sender.
- msg (str) – Text message.
- client (MatrigramClient) – The client the message is originated in.
Returns:
-
Client¶
-
class
matrigram.client.
MatrigramClient
(server, tb, username)[source]¶ -
_get_rooms_updated
()[source]¶ Return rooms dictionary with updated aliases.
Returns (dict): Return rooms dictionary with updated aliases.
-
_room_alias_to_id
(alias)[source]¶ Convert room alias to id.
Parameters: alias (str) – Room alias. Returns (str): Room id.
-
Helper¶
-
matrigram.helper.
config_filled
()[source]¶ Check if the user filled the config file.
Returns: True if config is filled, else False. Return type: bool
-
matrigram.helper.
get_config
()[source]¶ Query config file.
Returns: The config dictionary. Return type: dict
-
matrigram.helper.
list_to_nice_lines
(l)[source]¶ Convert a string list to lines ready to printed.
Parameters: l (list) – List of strings to be printed Returns: A line separated string that can be printed. Return type: str