grammers_client/lib.rs
1// Copyright 2020 - developers of the `grammers` project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9#![deny(unsafe_code)]
10
11//! This library is a high-level implementation to access [Telegram's API], which essentially
12//! lets you automate everything you can do with official Telegram clients and more from Rust,
13//! or even control bot accounts, making it a viable alternative to using the [Telegram Bot API].
14//!
15//! In order to create an application with the library for people to use, you will need to
16//! [obtain a developer API ID] first. You can embed it as a constant in your binary and ship
17//! that to users (anyone can login, including yourself and bots, with the developer API ID;
18//! they do *not* need to provide their own API ID).
19//!
20//! Once that's ready, create a new [`Client`] instance with its [`Client::new`]
21//! method and start making API calls.
22//!
23//! When a method is said to be "expensive", this often means that calling it too much in a
24//! certain period of time will result in the API returning "flood wait" errors, meaning that
25//! the method cannot be called again for a certain amount of seconds (trying to do so will
26//! continue to return the flood wait error for that duration).
27//!
28//! On the other hand, a "cheap" method can be called a lot and is unlikely to result in a flood
29//! wait error. However, all methods can potentially cause a flood wait, so some care is still
30//! required.
31//!
32//! There is nothing wrong with causing the API to return flood wait errors, but it might be a
33//! good idea to try and not hit them.
34//!
35//! A flood wait error is different from a peer flood error. A peer flood error means the flood
36//! limitation is applied account-wide, and its duration is undefined. This often means that the
37//! account spammed, or a young account tried to contact too many peers.
38//!
39//! The `grammers-tl-types` crate is re-exported and a lot of fields using it are public.
40//! You can use this re-export to [`Client::invoke`] any function supported by Telegram's API.
41//! This is only recommended when there isn't any convenience method on the [`Client`] that
42//! does what you need it to do, as the API is far less friendly and not covered by SemVer.
43//!
44//! [Telegram's API]: https://core.telegram.org/#telegram-api
45//! [Telegram Bot API]: https://core.telegram.org/bots/api
46//! [obtain a developer API ID]: https://my.telegram.org/auth
47pub mod client;
48pub mod parsers;
49pub mod types;
50pub(crate) mod utils;
51
52pub use client::{Client, ClientConfiguration, SignInError, UpdatesConfiguration};
53pub use types::{InputMedia, InputMessage, PeerMap, Update, button, reply_markup};
54
55pub use grammers_mtsender::InvocationError;
56pub use grammers_session as session;
57pub use grammers_tl_types;