Expand description
Application framework for Telegram bots.
rust-tg-bot-ext provides the high-level handler/filter/persistence layer
on top of rust_tg_bot_raw. It is modeled after Python’s
python-telegram-bot extension package and offers:
- Handlers:
CommandHandler,MessageHandler,CallbackQueryHandler, etc. - Filters: composable with
&,|,^,!operators viaF. - Persistence (feature
persistence): in-memory (DictPersistence) and JSON-file (JsonFilePersistence). - Application: the main dispatch loop (
Application).
§Quick start
ⓘ
use rust_tg_bot_ext::prelude::*;
async fn start(update: Update, context: Context) -> HandlerResult {
context.reply_text(&update, "Hello!").await?;
Ok(())
}
let app = ApplicationBuilder::new("BOT_TOKEN").build().await;
app.add_handler(CommandHandler::new("start", start), 0).await;
app.run_polling().await?;Modules§
- application
- The core
Applicationthat dispatches updates to registered handlers. The core Application that dispatches updates to registered handlers. - builder
- Builder for constructing an
Applicationwith custom configuration. Typestate builder forApplication. - callback_
data_ cache - Cache for arbitrary callback-data payloads attached to inline keyboards. Arbitrary callback data cache.
- context
- The
CallbackContextpassed to handler callbacks. Callback context passed to handlers and error handlers. - context_
types - Configuration types for context data categories. Customisable context type factories.
- defaults
- User-configurable defaults for outgoing API calls. Default parameter values for bot methods.
- ext_bot
- Extended bot wrapping the raw
Botwith defaults, callback-data cache, and rate-limiter support. Extended bot with convenience features. - filters
- Composable filters for routing updates to handlers. Filters for routing Telegram updates to handlers.
- handlers
- Update handler trait and concrete handler implementations. Update handler framework.
- prelude
- Convenient re-exports for writing clean bot code. Convenient re-exports for writing clean Telegram bot code.
- update_
processor - Base update processor abstraction. Semaphore-based concurrent update processing.
- updater
- The polling/webhook updater that feeds updates into the application. Fetches updates via long polling or webhook and pushes them into a channel.
- utils
- Internal utility types and helpers.