2020-02-14 13:56:41 +06:00
|
|
|
//! A full-featured framework that empowers you to easily build [Telegram bots]
|
2022-05-26 23:26:53 +06:00
|
|
|
//! using [Rust]. It handles all the difficult stuff so you can focus only on
|
|
|
|
//! your business logic.
|
2020-02-14 13:56:41 +06:00
|
|
|
//!
|
2020-03-06 15:05:44 +06:00
|
|
|
//! For a high-level overview, see [our GitHub repository](https://github.com/teloxide/teloxide).
|
2020-02-14 13:56:41 +06:00
|
|
|
//!
|
2022-05-26 23:26:53 +06:00
|
|
|
//! [[`examples/throw_dice.rs`](https://github.com/teloxide/teloxide/blob/master/examples/throw_dice.rs)]
|
2020-07-30 19:07:58 +06:00
|
|
|
//! ```no_run
|
2022-03-24 17:25:42 +06:00
|
|
|
//! use teloxide::prelude::*;
|
2020-07-30 19:07:58 +06:00
|
|
|
//!
|
|
|
|
//! # #[tokio::main]
|
2022-02-03 20:27:45 +06:00
|
|
|
//! # async fn main() {
|
2022-03-21 19:42:55 +04:00
|
|
|
//! pretty_env_logger::init();
|
2022-04-27 00:56:51 +06:00
|
|
|
//! log::info!("Starting throw dice bot...");
|
2020-07-30 19:07:58 +06:00
|
|
|
//!
|
2022-09-29 09:37:20 +06:00
|
|
|
//! let bot = Bot::from_env();
|
2020-07-30 19:07:58 +06:00
|
|
|
//!
|
2022-10-03 17:54:06 +06:00
|
|
|
//! teloxide::repl(bot, |bot: Bot, msg: Message| async move {
|
|
|
|
//! bot.send_dice(msg.chat.id).await?;
|
2022-10-02 21:44:04 +06:00
|
|
|
//! Ok(())
|
2020-07-30 19:07:58 +06:00
|
|
|
//! })
|
|
|
|
//! .await;
|
|
|
|
//! # }
|
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! <div align="center">
|
|
|
|
//! <kbd>
|
2022-05-26 23:26:53 +06:00
|
|
|
//! <img src=https://github.com/teloxide/teloxide/raw/master/media/throw-dice.gif width=420px />
|
2020-07-30 19:07:58 +06:00
|
|
|
//! </kbd>
|
|
|
|
//! </div>
|
|
|
|
//!
|
2020-02-14 13:56:41 +06:00
|
|
|
//! [Telegram bots]: https://telegram.org/blog/bot-revolution
|
|
|
|
//! [`async`/`.await`]: https://rust-lang.github.io/async-book/01_getting_started/01_chapter.html
|
|
|
|
//! [Rust]: https://www.rust-lang.org/
|
|
|
|
|
2021-04-05 21:19:29 +06:00
|
|
|
// This hack is used to cancel formatting for a Markdown table. See [1], [2], and [3].
|
|
|
|
//
|
|
|
|
// [1]: https://github.com/rust-lang/rustfmt/issues/4210
|
|
|
|
// [2]: https://github.com/rust-lang/rustfmt/issues/4787
|
|
|
|
// [3]: https://github.com/rust-lang/rust/issues/82768#issuecomment-803935643
|
2022-07-01 23:27:46 +04:00
|
|
|
#![cfg_attr(feature = "nightly", cfg_attr(feature = "nightly", doc = include_str!("features.md")))]
|
2020-02-19 21:32:42 +06:00
|
|
|
// https://github.com/teloxide/teloxide/raw/master/logo.svg doesn't work in html_logo_url, I don't know why.
|
2019-12-13 10:20:49 +06:00
|
|
|
#![doc(
|
2020-02-19 21:32:42 +06:00
|
|
|
html_logo_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png",
|
2020-02-14 18:28:52 +06:00
|
|
|
html_favicon_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png"
|
2019-12-13 10:20:49 +06:00
|
|
|
)]
|
2020-10-25 17:55:04 +02:00
|
|
|
// To properly build docs of this crate run
|
|
|
|
// ```console
|
2022-07-03 14:33:46 +04:00
|
|
|
// $ cargo docs --open
|
2020-10-25 17:55:04 +02:00
|
|
|
// ```
|
2022-07-03 14:33:46 +04:00
|
|
|
// (docs is an alias from `.cargo/config.toml`)
|
2022-02-10 16:39:21 +03:00
|
|
|
#![cfg_attr(all(docsrs, feature = "nightly"), feature(doc_cfg, doc_auto_cfg))]
|
2022-01-25 20:25:19 +03:00
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
#![warn(rustdoc::broken_intra_doc_links)]
|
|
|
|
#![allow(clippy::match_bool)]
|
2021-05-18 18:42:33 +03:00
|
|
|
#![allow(clippy::redundant_pattern_matching)]
|
2021-07-04 00:22:11 +03:00
|
|
|
// https://github.com/rust-lang/rust-clippy/issues/7422
|
|
|
|
#![allow(clippy::nonstandard_macro_braces)]
|
2019-11-02 17:15:13 +03:00
|
|
|
|
2022-04-02 20:54:33 +06:00
|
|
|
#[cfg(feature = "ctrlc_handler")]
|
2020-07-31 00:56:39 +06:00
|
|
|
pub use dispatching::repls::{
|
2022-03-24 17:25:42 +06:00
|
|
|
commands_repl, commands_repl_with_listener, repl, repl_with_listener,
|
2020-07-31 00:56:39 +06:00
|
|
|
};
|
2019-10-01 13:15:03 +06:00
|
|
|
|
2019-10-20 22:52:48 +06:00
|
|
|
pub mod dispatching;
|
2020-02-19 04:54:41 +06:00
|
|
|
pub mod error_handlers;
|
2020-01-30 00:11:52 +06:00
|
|
|
pub mod prelude;
|
2022-09-09 21:14:44 +04:00
|
|
|
pub mod stop;
|
2020-01-02 22:26:25 +03:00
|
|
|
pub mod utils;
|
2020-01-18 15:14:31 +02:00
|
|
|
|
2021-03-15 09:22:10 +06:00
|
|
|
#[doc(inline)]
|
|
|
|
pub use teloxide_core::*;
|
2021-03-06 03:18:03 +06:00
|
|
|
|
2020-10-02 11:13:27 +02:00
|
|
|
#[cfg(feature = "macros")]
|
2021-03-21 18:34:23 +06:00
|
|
|
pub use teloxide_macros as macros;
|
|
|
|
|
2022-04-25 19:16:05 +06:00
|
|
|
pub use dispatching::filter_command;
|
2022-04-27 15:31:17 +06:00
|
|
|
pub use dptree::{self, case as handler};
|
2020-10-02 11:13:27 +02:00
|
|
|
|
2020-08-12 23:21:13 +03:00
|
|
|
#[cfg(all(feature = "nightly", doctest))]
|
2021-06-18 21:35:54 +06:00
|
|
|
#[cfg_attr(feature = "nightly", cfg_attr(feature = "nightly", doc = include_str!("../README.md")))]
|
2020-08-12 23:21:13 +03:00
|
|
|
enum ReadmeDocTests {}
|
2021-03-06 03:18:03 +06:00
|
|
|
|
2021-03-19 17:58:22 +06:00
|
|
|
use teloxide_core::requests::ResponseResult;
|
|
|
|
|
2021-03-06 03:18:03 +06:00
|
|
|
/// A shortcut for `ResponseResult::Ok(val)`.
|
|
|
|
pub fn respond<T>(val: T) -> ResponseResult<T> {
|
|
|
|
ResponseResult::Ok(val)
|
|
|
|
}
|