logo
Expand description

A full-featured framework that empowers you to easily build Telegram bots using Rust. It handles all the difficult stuff so you can focus only on your business logic.

For a high-level overview, see our GitHub repository.

[examples/throw_dice.rs]

use teloxide::prelude::*;

pretty_env_logger::init();
log::info!("Starting throw dice bot...");

let bot = Bot::from_env().auto_send();

teloxide::repl(bot, |message: Message, bot: AutoSend<Bot>| async move {
    bot.send_dice(message.chat.id).await?;
    respond(())
})
.await;

Cargo features

FeatureDescription
redis-storageEnables the Redis storage support for dialogues.
sqlite-storageEnables the Sqlite storage support for dialogues.
cbor-serializerEnables the CBOR serializer for dialogues.
bincode-serializerEnables the Bincode serializer for dialogues.
macrosRe-exports macros from teloxide-macros.
native-tlsEnables the native-tls TLS implementation (enabled by default).
rustlsEnables the rustls TLS implementation.
ctrlc_handlerEnables the Dispatcher::setup_ctrlc_handler function.
auto-sendEnables the AutoSend bot adaptor.
throttleEnables the Throttle bot adaptor.
cache-meEnables the CacheMe bot adaptor.
trace-adaptorEnables the Trace bot adaptor.
erasedEnables the ErasedRequester bot adaptor.
fullEnables all the features except nightly.
nightlyEnables nightly-only features (see the teloxide-core features).

Re-exports

pub use teloxide_macros as macros;
pub use dptree;

Modules

Wrappers altering functionality of a bot.

An update dispatching model based on dptree.

Convenient error handling.

Possible error types.

Network-specific API.

Request data sent to Telegram.

Commonly used items.

Commonly used items.

Telegram API requests.

Telegram API types.

Some useful utilities.

Macros

enable_loggingDeprecated

Enables logging through pretty-env-logger.

Enables logging through pretty-env-logger with a custom filter for your program.

Filters an enumeration, passing its payload forwards.

Structs

A requests sender.

Enums

A kind of an API error.

An error caused by downloading a file.

An error caused by sending a request to Telegram.

Functions

commands_replctrlc_handler

A REPL for commands.

Like commands_repl, but with a custom UpdateListener.

Returns a handler that accepts a parsed command C.

replctrlc_handler

A REPL for messages.

repl_with_listenerctrlc_handler

Like repl, but with a custom UpdateListener.

A shortcut for ResponseResult::Ok(val).