Skip to main content

rust_tg_bot_ext/
lib.rs

1//! Application framework for Telegram bots.
2//!
3//! `rust-tg-bot-ext` provides the high-level handler/filter/persistence layer
4//! on top of [`rust_tg_bot_raw`].  It is modeled after Python's
5//! `python-telegram-bot` extension package and offers:
6//!
7//! - **Handlers**: [`CommandHandler`](handlers::command::CommandHandler),
8//!   [`MessageHandler`](handlers::message::MessageHandler),
9//!   [`CallbackQueryHandler`](handlers::callback_query::CallbackQueryHandler), etc.
10//! - **Filters**: composable with `&`, `|`, `^`, `!` operators via [`F`](filters::base::F).
11//! - **Persistence** *(feature `persistence`)*: in-memory
12//!   ([`DictPersistence`](persistence::dict::DictPersistence)) and JSON-file
13//!   ([`JsonFilePersistence`](persistence::json_file::JsonFilePersistence)).
14//! - **Application**: the main dispatch loop ([`Application`](application::Application)).
15//!
16//! # Quick start
17//!
18//! ```rust,ignore
19//! use rust_tg_bot_ext::prelude::*;
20//!
21//! async fn start(update: Update, context: Context) -> HandlerResult {
22//!     context.reply_text(&update, "Hello!").await?;
23//!     Ok(())
24//! }
25//!
26//! let app = ApplicationBuilder::new("BOT_TOKEN").build().await;
27//! app.add_handler(CommandHandler::new("start", start), 0).await;
28//! app.run_polling().await?;
29//! ```
30
31#![warn(missing_docs)]
32#![forbid(unsafe_code)]
33
34/// The core [`Application`](application::Application) that dispatches updates
35/// to registered handlers.
36pub mod application;
37/// Builder for constructing an [`Application`](application::Application) with
38/// custom configuration.
39pub mod builder;
40/// Cache for arbitrary callback-data payloads attached to inline keyboards.
41pub mod callback_data_cache;
42/// The [`CallbackContext`](context::CallbackContext) passed to handler callbacks.
43pub mod context;
44/// Configuration types for context data categories.
45pub mod context_types;
46/// User-configurable defaults for outgoing API calls.
47pub mod defaults;
48/// Extended bot wrapping the raw [`Bot`](rust_tg_bot_raw::bot::Bot) with
49/// defaults, callback-data cache, and rate-limiter support.
50pub mod ext_bot;
51/// Composable filters for routing updates to handlers.
52pub mod filters;
53/// Update handler trait and concrete handler implementations.
54pub mod handlers;
55/// Scheduled and repeating job execution.
56///
57/// Requires the `job-queue` feature.
58#[cfg(feature = "job-queue")]
59pub mod job_queue;
60/// Persistence backends for storing user/chat/bot data across restarts.
61///
62/// Requires the `persistence` feature.
63#[cfg(feature = "persistence")]
64pub mod persistence;
65/// Convenient re-exports for writing clean bot code.
66pub mod prelude;
67/// Rate-limiter support.
68///
69/// Requires the `rate-limiter` feature.
70#[cfg(feature = "rate-limiter")]
71pub mod rate_limiter;
72/// Base update processor abstraction.
73pub mod update_processor;
74/// The polling/webhook updater that feeds updates into the application.
75pub mod updater;
76/// Internal utility types and helpers.
77pub mod utils;