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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! An asynchronous framework for the Telegram Bot API written in Rust.
//!
//! `telers` makes it easy to create Telegram bots: it provides a system of routers, middlewares,
//! filters and handlers (inspired by [`aiogram`]), and an extractor system for handler arguments
//! similar to the ones in `axum` and `actix`.
//! Types and methods mirror the [Telegram Bot API] documentation: the same objects with the same
//! fields, plus generated helper methods and builders.
//!
//! # Quick start
//!
//! An echo bot (reads the token from the `BOT_TOKEN` environment variable):
//!
//! ```no_run
//! use telers::{
//! enums::UpdateType,
//! event::telegram::{Handler, HandlerResult},
//! types::Message,
//! Bot, Dispatcher, Router,
//! };
//!
//! async fn echo_handler(bot: Bot, message: Message) -> HandlerResult<()> {
//! bot.send(message.to_copy_message(message.chat().id()))
//! .await?;
//! Ok(())
//! }
//!
//! #[tokio::main(flavor = "current_thread")]
//! async fn main() {
//! let bot = Bot::from_env();
//!
//! let router = Router::new("main")
//! .on_message(|observer| observer.register(Handler::new(echo_handler)));
//!
//! let dispatcher = Dispatcher::builder()
//! .main_router(router.configure_default())
//! .bot(bot)
//! .allowed_update(UpdateType::Message)
//! .build();
//!
//! dispatcher.run_polling().await.expect("Polling failed");
//! }
//! ```
//!
//! # Where to go next
//!
//! - [`router`] — how events are routed to observers and handlers, controlled by [`EventReturn`](event::EventReturn)
//! - [`dispatcher`] — polling, allowed updates, startup/shutdown events
//! - [`middlewares`] — outer and inner middlewares
//! - [`filters`] — ready-made and custom filters, including the [`SmartFilter`](filters::SmartFilter)
//! - [`extractor`] — extracting handler arguments from events and the [`Context`]
//! - [`fsm`] — finite state machine (conversations) with pluggable storage
//! - [`types`] and [`methods`] — generated Telegram Bot API objects and requests
//! - [`utils`] — text formatting and rendering helpers, and more
//!
//! More examples can be found in the [examples directory].
//!
//! [`aiogram`]: https://github.com/aiogram/aiogram/
//! [Telegram Bot API]: https://core.telegram.org/bots/api
//! [examples directory]: https://github.com/Desiders/telers/tree/dev-1.x/examples
extern crate self as telers;
pub
pub
pub use ;
pub use Bot;
pub use Context;
pub use ;
pub use Either;
pub use ;
pub use Extractor;
pub use ;
pub use Context as FSMContext;
pub use Request;
pub use ;