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
//! Async Rust framework for the [Telegram Bot API](https://core.telegram.org/bots/api).
//!
//! rustigram re-exports all sub-crates through a single dependency and a
//! convenient [`prelude`] module covering the most common types.
//!
//! # Getting started
//!
//! Add to `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! rustigram = "0.9"
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! ```rust,ignore
//! use rustigram::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let bot = Bot::new(std::env::var("BOT_TOKEN")?)?;
//!
//! bot.dispatcher()
//! .on(filters::command("start"), handler_fn(start))
//! .on(filters::message(), handler_fn(echo))
//! .build()
//! .polling()
//! .await?;
//!
//! Ok(())
//! }
//!
//! async fn start(ctx: Context) -> BotResult<()> {
//! if let Some(r) = ctx.reply("Hello!") { r.await?; }
//! Ok(())
//! }
//!
//! async fn echo(ctx: Context) -> BotResult<()> {
//! if let (Some(text), Some(chat_id)) = (ctx.text(), ctx.chat_id()) {
//! ctx.bot.send_message(chat_id, text).await?;
//! }
//! Ok(())
//! }
//! ```
//!
//! # Crate structure
//!
//! | Crate | Purpose |
//! |---|---|
//! | [`api`] | HTTP client and typed method builders |
//! | [`bot`] | Dispatcher, filters, handlers, FSM |
//! | [`types`] | All Bot API type definitions |
//!
pub use rustigram_api as api;
pub use rustigram_bot as bot;
pub use rustigram_types as types;
/// Commonly used types and traits from all sub-crates.