Telegram TL v0.0.3-alpha TL
This library allows you to serialize and deserialize elements of the TL Language. It was originally designed to be used by telegram-mt-elixir.
Summary
Functions
Build a TL object. See core.telegram.org/schema/mtproto and core.telegram.org/schema
Deserialize an object given its type. Available types
Decode a TL object. See core.telegram.org/schema/mtproto and core.telegram.org/schema
Serialize an object given its type. Available types
Functions
Build a TL object. See core.telegram.org/schema/mtproto and core.telegram.org/schema.
Example
iex> TL.build "ping", %{:ping_id => 666}
<<236, 119, 190, 122, 154, 2, 0, 0, 0, 0, 0, 0>>
Deserialize an object given its type. Available types :
:meta32
:meta64
:int
:int64
:int128
:int256
:long
:float
:string
:bytes
:vector
@TODO:boxed
@TODO
Example
iex(12)> TL.deserialize(<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 91, 205, 21>>, :int128)
123456789
Decode a TL object. See core.telegram.org/schema/mtproto and core.telegram.org/schema.
Examples
iex> TL.parse 0x7abe77ec, <<154, 2, 0, 0, 0, 0, 0, 0>>
{%{name: "ping", ping_id: 666}, ""}
iex> TL.parse 0x7abe77ec, <<154, 2, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4>>
{%{name: "ping", ping_id: 666}, <<1, 2, 3, 4>>}
Serialize an object given its type. Available types :
:meta32
:meta64
:int
:int64
:int128
:int256
:long
:float
:string
:bytes
:vector
NOT_YET_IMPLEMENTED
Examples
iex> TL.serialize(123456789, :int128)
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 91, 205, 21>>
iex> TL.serialize("Hello world!", :string)
<<12, 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33, 0, 0, 0>>