Telegram MT v0.1.1-alpha MTProto View Source

MTProto implementation for Elixir. Base module.

This module provides “high-level” functions for common tasks.

Link to this section Summary

Functions

Connect and create a session on the specified DC. If dc_id is not provided, connect to a random DC (out of the 5 available DC.) If there is no authorization key related to the DC, the authorization key generation will be initiated

Fetch the the contact list

Launch the Authorization Key computation sequence

Send an encrypted message to Telegram on the session sid. Similar (alias) to MTProto.Session.send(sid, msg, :encrypted)

Initiate the authentification procedure by sending a message to the account linked to the provided phone number on the session session_id (generated with connect/1)

Initilize the connection (if not initialized yet) with default values and the version of API layer to use

Sign in given the phone number and the code received from Telegram (by SMS, call, or via an open client). phone_code_hash is returned in the response to MTProto.send_code/2and is stored in the session. You don’t need to provide it, but you can override the phone_code_hash stored in the session by providing it here

Log out the user

Start the supervision tree and set default values in the registry

Link to this section Functions

Link to this function connect(dc_id \\ :random) View Source

Connect and create a session on the specified DC. If dc_id is not provided, connect to a random DC (out of the 5 available DC.) If there is no authorization key related to the DC, the authorization key generation will be initiated.

Returns {:ok, session_id}.

Link to this function get_contacts(session_id) View Source

Fetch the the contact list.

Link to this function request_authkey(session_id) View Source

Launch the Authorization Key computation sequence.

Send an encrypted message to Telegram on the session sid. Similar (alias) to MTProto.Session.send(sid, msg, :encrypted).

Link to this function send_code(session_id, phone) View Source

Initiate the authentification procedure by sending a message to the account linked to the provided phone number on the session session_id (generated with connect/1).

Link to this function send_message(session_id, dst_id, content, type \\ :contact) View Source

Send a text message to an user/group.

  • session_id
  • dst_id - ID (integer) of the recipient of the message
  • content - content of the message (string)
  • type - type of the recipient, either an user (:contact) or a group (:chat)
Link to this function send_with_initialization(session_id, msg) View Source

Initilize the connection (if not initialized yet) with default values and the version of API layer to use.

Link to this function sign_in(session_id, phone, code, code_hash \\ :session) View Source

Sign in given the phone number and the code received from Telegram (by SMS, call, or via an open client). phone_code_hash is returned in the response to MTProto.send_code/2and is stored in the session. You don’t need to provide it, but you can override the phone_code_hash stored in the session by providing it here.

Log out the user.

Start the supervision tree and set default values in the registry.