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
//! High-level bot framework built on top of \[`rustigram-api`\].
//!
//! This crate provides everything needed to receive and route Telegram updates:
//!
//! - [`Bot`] — entry point, owns the [`crate::bot::Bot::client`] field and creates a dispatcher
//! - [`Dispatcher`] — routes updates to handlers via composable filters
//! - [`Context`] — passed to every handler, provides access to the update and the API client
//! - [`filter`] — built-in and composable filter predicates
//! - [`handler`] — the [`handler::Handler`] trait and [`handler::handler_fn`] wrapper
//! - [`state`] — [`state::StateStorage`] for shared data and [`state::DialogueStorage`] for FSM
//! - [`update_listener`] — long-polling and axum-based webhook implementations
//!
//! # Quick start
//!
//! ```rust,ignore
//! use rustigram_bot::{Bot, Context, BotResult};
//! use rustigram_bot::filter::filters;
//! use rustigram_bot::handler::handler_fn;
//!
//! #[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(())
//! }
//! ```
//!
//! # Concurrency model
//!
//! Each incoming update is dispatched in its own [`tokio::spawn`] task.
//! Handlers run concurrently — a slow handler never blocks others.
//! The dispatcher evaluates routes in registration order and stops at the
//! first matching filter.
/// Entry-point type for creating and running a bot.
/// Handler context passed to every update handler.
/// Update dispatcher and routing.
/// Error types for the bot framework layer.
/// Composable update filters.
/// Handler trait and function wrapper.
/// Shared and per-user state storage.
/// Update listeners (long polling and webhook).
pub use Bot;
pub use Context;
pub use ;
pub use ;
pub use ;
pub use ;
pub use StateStorage;
pub use WebhookConfig;