Crate grammers_client

Source
Expand description

This library is a high-level implementation to access Telegram’s API, which essentially lets you automate everything you can do with official Telegram clients and more from Rust, or even control bot accounts, making it a viable alternative to using the Telegram Bot API.

In order to create an application with the library for people to use, you will need to obtain a developer API ID first. You can embed it as a constant in your binary and ship that to users (anyone can login, including yourself and bots, with the developer API ID; they do not need to provide their own API ID).

Once that’s ready, create a new Client instance with its Client::connect method and start making API calls.

When a method is said to be “expensive”, this often means that calling it too much in a certain period of time will result in the API returning “flood wait” errors, meaning that the method cannot be called again for a certain amount of seconds (trying to do so will continue to return the flood wait error for that duration).

On the other hand, a “cheap” method can be called a lot and is unlikely to result in a flood wait error. However, all methods can potentially cause a flood wait, so some care is still required.

There is nothing wrong with causing the API to return flood wait errors, but it might be a good idea to try and not hit them.

A flood wait error is different from a peer flood error. A peer flood error means the flood limitation is applied account-wide, and its duration is undefined. This often means that the account spammed, or a young account tried to contact too many peers.

The grammers-tl-types crate is re-exported and a lot of fields using it are public. You can use this re-export to Client::invoke any function supported by Telegram’s API. This is only recommended when there isn’t any convenience method on the Client that does what you need it to do, as the API is far less friendly and not covered by SemVer.

Re-exports§

pub use client::Client;
pub use client::Config;
pub use client::InitParams;
pub use client::SignInError;
pub use types::button;
pub use types::reply_markup;
pub use types::ChatMap;
pub use types::InputMedia;
pub use types::InputMessage;
pub use types::Update;
pub use grammers_session as session;
pub use grammers_tl_types;

Modules§

client
parsers
This module is currently public even though it directly uses grammers-tl-types. This will probably change before the 1.0 release.
transport
Implementation of the several MTProto transports. This layer is responsible for taking serialized messages from the MTP and packing them in a format that can be sent over a protocol, such as TCP, HTTP or UDP.
types
Custom types extending those provided by Telegram.

Structs§

FixedReconnect
simple Fixed sized implementation for the ReconnectionPolicy trait.
NoReconnect
the default implementation of the ReconnectionPolicy.

Enums§

InvocationError
This error occurs when a Remote Procedure call was unsuccessful.

Traits§

ReconnectionPolicy
a simple Reconnection Handler.