1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//! A Telegram [MTProto](https://core.telegram.org/mtproto) client for users and bots, written from scratch: it
//! talks to Telegram's main API directly, as a user account or as a bot (an alternative to the Bot API), with its
//! own transport, auth key exchange and encrypted session, generated types for the whole API layer, and a
//! friendly API of methods, handlers and filters on top.
//!
//! ```no_run
//! use vaegram::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let app = Client::builder("my_bot", 12345, "0123456789abcdef0123456789abcdef")
//! .bot_token("123456:ABC-DEF")
//! .start()
//! .await?;
//!
//! app.on_message(filters::command("start") & filters::private(), |msg| async move {
//! msg.answer("Hello from vaegram!").await?;
//! Ok(())
//! });
//!
//! app.run().await
//! }
//! ```
//!
//! The `api_id` and `api_hash` come from <https://my.telegram.org>. Without `.bot_token(..)`, `start` asks on stdin
//! for a phone number, the login code and the two-step verification password. The first run writes
//! `my_bot.session`, and later runs log in from it: see [`ClientBuilder`] for other storage and settings. Anything
//! without a friendly method can be called with [`Client::invoke`] and the TL types in [`raw`]. The [`prelude`]
//! brings in the client, filters, and the types and enums most bots use, with one `use`.
//!
//! # Cargo features
//!
//! None is on by default.
//!
//! - `json`: `ToJson` for every TL type and function, and JSON for raw updates and recordings.
//! - `unstable-raw`: the TL objects behind raw updates (`RawUpdate::raw()`, `raw_users()`, `raw_chats()`),
//! `Incoming::into_updates()` and `UploadedFile::into_raw()`, and the session plumbing below `Client`
//! (`connection::Connection`, `session::{Session, UpdatesRx, Incoming, Events}`). Experimental: may change or
//! go away in any release.
//! - Storage engines: `sqlite` (`SqliteStorage`), `redb` (`RedbStorage`), `redis` (`RedisStorage`), `mongodb`
//! (`MongoStorage`), `postgres` (`PostgresStorage`), `s3` (`S3Storage`, an S3-compatible object store) and
//! `vault` (`VaultStorage`, the login in HashiCorp Vault).
//! - Observability: `metrics` and `opentelemetry`, request observers in the `observe` module.
//! - `regex`: `filters::regex` and `filters::matches`.
//! - Transports over TLS: `websocket` (`ClientBuilder::websocket`), `dns-config` (`ClientBuilder::dns_fallback`
//! to Telegram's DNS config) and `web-proxy` (`Proxy::Web`, an MTProxy behind an HTTPS relay).
// Declares a struct `pub` with the `unstable-raw` feature and `pub(crate)` without it: the session plumbing under
// `Client` is experimental, so only that feature lets callers name it.