Telegram MT v0.0.1-alpha MTProto
MTProto implementation for Elixir. At this time, the project is still far from complete : expect things to break.
Other resources
A demo client is avaible on github. You may also want to take a look to the README page of the project, where you can find more detailed informations and examples.
Overview
This library allows you to handle mutiple users, which is fondamental since
it was originally designed in order to build bridges between Telegram
and other messaging services. Each session is equivalent to an user and has
its own connection to Telegram’s servers. Note that you have to set
(see MTProto.Session.set_client/2
) a process to be notified of incoming
messages for every session.
MTProto
(this module) - provides a “friendly” way to interact with ‘low-level’ methods. It allow you to connect/login/logout/send messages.MTProto.API
(and submodules) - implementation of the Telegram API, as explained here and here.MTProto.Session
: Provides manual control over sessions.- Many modules [1] are not designed to be used by the “standard” user hence are not documented here. You’re welcome to take a look/contribute : everything is on github.
[1] : MTProto.Session.Brain
, MTProto.Session.Handler
,
MTProto.Session.HandlerSupervisor
, MTProto.Session.Listener
,
MTProto.Session.ListenerSupervisor
, MTProto.Auth
, MTProto.Crypto
,
MTProto.DC
, MTProto.Method
, MTProto.Payload
, MTProto.Registry
,
MTProto.Supervisor
and MTProto.TCP
.
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
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
)
Send a text message to an user/group
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/2
and 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. Automatically started
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.
Returns {:ok, session_id}
.
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
).
Send a text message to an user/group.
session_id
dst_id
- ID (integer) of the recipient of the messagecontent
- content of the message (string)type
- type of the recipient, either an user (:contact
) or a group (:chat
)
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/2
and 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.