From 0d5efcbdf10e4e502c0680b6189c8727b87e61f8 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 28 Apr 2022 03:08:25 +0600 Subject: [PATCH 01/11] Improve `README.md` Former-commit-id: 2d2be5759e98f6d5924f4ca0ec009918650f1670 --- README.md | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 3d53f0d1..32b7d8fa 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,15 @@ - + - A full-featured framework that empowers you to easily build [Telegram bots](https://telegram.org/blog/bot-revolution) using the [`async`/`.await`](https://rust-lang.github.io/async-book/01_getting_started/01_chapter.html) syntax in [Rust](https://www.rust-lang.org/). It handles all the difficult stuff so you can focus only on your business logic. + A full-featured framework that empowers you to easily build [Telegram bots](https://telegram.org/blog/bot-revolution) using [Rust](https://www.rust-lang.org/). It handles all the difficult stuff so you can focus only on your business logic. ## Highlights - - **Declarative design.** teloxide is based upon [`dptree`], a functional-style [chain of responsibility] pattern that allows you to express pipelines of message processing in a highly declarative and extensible style. + - **Declarative design.** teloxide is based upon [`dptree`], a functional [chain of responsibility] pattern that allows you to express pipelines of message processing in a highly declarative and extensible style. [`dptree`]: https://github.com/p0lunin/dptree [chain of responsibility]: https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern @@ -84,7 +84,7 @@ tokio = { version = "1.8", features = ["rt-multi-thread", "macros"] } This bot replies with a dice throw to each received message: -([Full](examples/throw_dice.rs)) +[[`examples/throw_dice.rs`](examples/throw_dice.rs)] ```rust,no_run use teloxide::prelude::*; @@ -121,7 +121,7 @@ Commands are strongly typed and defined declaratively, similar to how we define [structopt]: https://docs.rs/structopt/0.3.9/structopt/ [serde-json]: https://github.com/serde-rs/json -([Full](examples/command.rs)) +[[`examples/command.rs`](examples/command.rs)] ```rust,no_run use teloxide::{prelude::*, utils::command::BotCommands}; @@ -188,7 +188,7 @@ A dialogue is typically described by an enumeration where each variant is one po Below is a bot that asks you three questions and then sends the answers back to you: -([Full](examples/dialogue.rs)) +[[`examples/dialogue.rs`](examples/dialogue.rs)] ```rust,ignore use teloxide::{dispatching::dialogue::InMemStorage, prelude::*}; @@ -341,28 +341,28 @@ A: Yes, see [`examples/purchase.rs`](examples/purchase.rs). Feel free to propose your own bot to our collection! - - [WaffleLapkin/crate_upd_bot](https://github.com/WaffleLapkin/crate_upd_bot) -- A bot that notifies about crate updates. - - [mxseev/logram](https://github.com/mxseev/logram) -- Utility that takes logs from anywhere and sends them to Telegram. - - [alexkonovalov/PedigreeBot](https://github.com/alexkonovalov/PedigreeBot) -- A Telegram bot for building family trees. - - [Hermitter/tepe](https://github.com/Hermitter/tepe) -- A CLI to command a bot to send messages and files over Telegram. - - [mattrighetti/GroupActivityBot](https://github.com/mattrighetti/group-activity-bot-rs) -- Telegram bot that keeps track of user activity in groups. - - [mattrighetti/libgen-bot-rs](https://github.com/mattrighetti/libgen-bot-rs) -- Telgram bot to interface with libgen - - [dracarys18/grpmr-rs](https://github.com/dracarys18/grpmr-rs) -- A Telegram group manager bot with variety of extra features. - - [steadylearner/subreddit_reader](https://github.com/steadylearner/Rust-Full-Stack/tree/master/commits/teloxide/subreddit_reader) -- A bot that shows the latest posts at Rust subreddit. - - [myblackbeard/basketball-betting-bot](https://github.com/myblackbeard/basketball-betting-bot) -- The bot lets you bet on NBA games against your buddies. - - [ArtHome12/vzmuinebot](https://github.com/ArtHome12/vzmuinebot) -- Telegram bot for food menu navigate. - - [ArtHome12/cognito_bot](https://github.com/ArtHome12/cognito_bot) -- The bot is designed to anonymize messages to a group. - - [pro-vim/tg-vimhelpbot](https://github.com/pro-vim/tg-vimhelpbot) -- Link `:help` for Vim in Telegram. - - [sschiz/janitor-bot](https://github.com/sschiz/janitor-bot) -- A bot that removes users trying to join to a chat that is designed for comments. - - [slondr/BeerHolderBot](https://gitlab.com/slondr/BeerHolderBot) -- A bot that holds your beer. - - [MustafaSalih1993/Miss-Vodka-Telegram-Bot](https://github.com/MustafaSalih1993/Miss-Vodka-Telegram-Bot) -- A Telegram bot written in rust using "Teloxide" library. - - [x13a/tg-prompt](https://github.com/x13a/tg-prompt) -- Telegram prompt. - - [magnickolas/remindee-bot](https://github.com/magnickolas/remindee-bot) -- Telegram bot for managing reminders. - - [cyberknight777/knight-bot](https://gitlab.com/cyberknight777/knight-bot) -- A Telegram bot with variety of fun features. - - [wa7sa34cx/the-black-box-bot](https://github.com/wa7sa34cx/the-black-box-bot) -- This is the Black Box Telegram bot. You can hold any items in it. - - [crapstone/hsctt](https://codeberg.org/crapstones-bots/hsctt) -- A Telegram bot that searches for HTTP status codes in all messages and replies with the text form. - - [alenpaul2001/AurSearchBot](https://gitlab.com/alenpaul2001/aursearchbot) -- Telegram bot for searching AUR in inline mode. - - [studiedlist/EddieBot](https://gitlab.com/studiedlist/eddie-bot) -- Chatting bot with several entertainment features + - [WaffleLapkin/crate_upd_bot](https://github.com/WaffleLapkin/crate_upd_bot) — A bot that notifies about crate updates. + - [mxseev/logram](https://github.com/mxseev/logram) — Utility that takes logs from anywhere and sends them to Telegram. + - [alexkonovalov/PedigreeBot](https://github.com/alexkonovalov/PedigreeBot) — A Telegram bot for building family trees. + - [Hermitter/tepe](https://github.com/Hermitter/tepe) — A CLI to command a bot to send messages and files over Telegram. + - [mattrighetti/GroupActivityBot](https://github.com/mattrighetti/group-activity-bot-rs) — Telegram bot that keeps track of user activity in groups. + - [mattrighetti/libgen-bot-rs](https://github.com/mattrighetti/libgen-bot-rs) — Telgram bot to interface with libgen + - [dracarys18/grpmr-rs](https://github.com/dracarys18/grpmr-rs) — A Telegram group manager bot with variety of extra features. + - [steadylearner/subreddit_reader](https://github.com/steadylearner/Rust-Full-Stack/tree/master/commits/teloxide/subreddit_reader) — A bot that shows the latest posts at Rust subreddit. + - [myblackbeard/basketball-betting-bot](https://github.com/myblackbeard/basketball-betting-bot) — The bot lets you bet on NBA games against your buddies. + - [ArtHome12/vzmuinebot](https://github.com/ArtHome12/vzmuinebot) — Telegram bot for food menu navigate. + - [ArtHome12/cognito_bot](https://github.com/ArtHome12/cognito_bot) — The bot is designed to anonymize messages to a group. + - [pro-vim/tg-vimhelpbot](https://github.com/pro-vim/tg-vimhelpbot) — Link `:help` for Vim in Telegram. + - [sschiz/janitor-bot](https://github.com/sschiz/janitor-bot) — A bot that removes users trying to join to a chat that is designed for comments. + - [slondr/BeerHolderBot](https://gitlab.com/slondr/BeerHolderBot) — A bot that holds your beer. + - [MustafaSalih1993/Miss-Vodka-Telegram-Bot](https://github.com/MustafaSalih1993/Miss-Vodka-Telegram-Bot) — A Telegram bot written in rust using "Teloxide" library. + - [x13a/tg-prompt](https://github.com/x13a/tg-prompt) — Telegram prompt. + - [magnickolas/remindee-bot](https://github.com/magnickolas/remindee-bot) — Telegram bot for managing reminders. + - [cyberknight777/knight-bot](https://gitlab.com/cyberknight777/knight-bot) — A Telegram bot with variety of fun features. + - [wa7sa34cx/the-black-box-bot](https://github.com/wa7sa34cx/the-black-box-bot) — This is the Black Box Telegram bot. You can hold any items in it. + - [crapstone/hsctt](https://codeberg.org/crapstones-bots/hsctt) — A Telegram bot that searches for HTTP status codes in all messages and replies with the text form. + - [alenpaul2001/AurSearchBot](https://gitlab.com/alenpaul2001/aursearchbot) — Telegram bot for searching AUR in inline mode. + - [studiedlist/EddieBot](https://gitlab.com/studiedlist/eddie-bot) — Chatting bot with several entertainment features. ## Contributing From dd2feb179fba1017c50a030b6743e69d509e36f7 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 5 May 2022 16:17:47 +0400 Subject: [PATCH 02/11] Remove mentions of the removed "frunk" feature --- src/features.txt | 1 - src/utils/mod.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/features.txt b/src/features.txt index 7edd2f39..32d737b3 100644 --- a/src/features.txt +++ b/src/features.txt @@ -15,7 +15,6 @@ | `cache-me` | Enables the [`CacheMe`](adaptors::CacheMe) bot adaptor. | | `trace-adaptor` | Enables the [`Trace`](adaptors::Trace) bot adaptor. | | `erased` | Enables the [`ErasedRequester`](adaptors::ErasedRequester) bot adaptor. | -| `frunk` | Enables [`teloxide::utils::UpState`]. | | `full` | Enables all the features except `nightly`. | | `nightly` | Enables nightly-only features (see the [teloxide-core features]). | diff --git a/src/utils/mod.rs b/src/utils/mod.rs index d83e0dbb..c7738637 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -6,6 +6,3 @@ pub mod markdown; pub(crate) mod shutdown_token; pub use teloxide_core::net::client_from_env; - -#[cfg(feature = "frunk")] -pub use up_state::UpState; From 93c78ce0bee3086ea0441f98a22067a2c0173202 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 5 May 2022 16:16:25 +0400 Subject: [PATCH 03/11] Switch to a new module naming system Former-commit-id: f02eb2b679a68a572e6c9c6912273f97f99bee5f --- src/{dispatching/mod.rs => dispatching.rs} | 0 src/dispatching/{dialogue/mod.rs => dialogue.rs} | 0 src/dispatching/dialogue/{storage/mod.rs => storage.rs} | 0 src/dispatching/{repls/mod.rs => repls.rs} | 0 src/{utils/mod.rs => utils.rs} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/{dispatching/mod.rs => dispatching.rs} (100%) rename src/dispatching/{dialogue/mod.rs => dialogue.rs} (100%) rename src/dispatching/dialogue/{storage/mod.rs => storage.rs} (100%) rename src/dispatching/{repls/mod.rs => repls.rs} (100%) rename src/{utils/mod.rs => utils.rs} (100%) diff --git a/src/dispatching/mod.rs b/src/dispatching.rs similarity index 100% rename from src/dispatching/mod.rs rename to src/dispatching.rs diff --git a/src/dispatching/dialogue/mod.rs b/src/dispatching/dialogue.rs similarity index 100% rename from src/dispatching/dialogue/mod.rs rename to src/dispatching/dialogue.rs diff --git a/src/dispatching/dialogue/storage/mod.rs b/src/dispatching/dialogue/storage.rs similarity index 100% rename from src/dispatching/dialogue/storage/mod.rs rename to src/dispatching/dialogue/storage.rs diff --git a/src/dispatching/repls/mod.rs b/src/dispatching/repls.rs similarity index 100% rename from src/dispatching/repls/mod.rs rename to src/dispatching/repls.rs diff --git a/src/utils/mod.rs b/src/utils.rs similarity index 100% rename from src/utils/mod.rs rename to src/utils.rs From f2bf104bce01a1e9e3c2b7bf20631575f51207a9 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:20:32 +0600 Subject: [PATCH 04/11] Update the documentation of `BotCommands` Former-commit-id: ee819548c08b5c4c8d202a05ddce02781ea17694 --- src/utils/command.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/command.rs b/src/utils/command.rs index e6491697..8d29ee7b 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -160,8 +160,10 @@ pub use teloxide_macros::BotCommands; /// All variant attributes override the corresponding `enum` attributes. /// /// 1. `#[command(rename = "rule")]` -/// Rename one command by a rule. Allowed rules are `lowercase`, `%some_name%`, -/// where `%some_name%` is any string, a new name. +/// Rename one command by a rule. Allowed rules are `lowercase`, `UPPERCASE`, +/// `PascalCase`, `camelCase`, `snake_case`, `SCREAMING_SNAKE_CASE`, +/// `kebab-case`, `SCREAMING-KEBAB-CASE`, and `%some_name%`, where `%some_name%` +/// is any string, a new name. /// /// 2. `#[command(description = "description")]` /// Give your command a description. Write `"off"` for `"description"` to hide a @@ -323,7 +325,7 @@ impl<'a> CommandDescriptions<'a> { /// assert_eq!( /// descriptions.username("username_of_the_bot").to_string(), /// "/start@username_of_the_bot — start this bot\n/help@username_of_the_bot — show this \ - /// message" + /// message" /// ); /// ``` pub fn username(self, bot_username: &'a str) -> Self { From b7cfd7f666e18392a673cbac90880aa0b21731e4 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:26:53 +0600 Subject: [PATCH 05/11] Update other doc places Former-commit-id: 5b2b7c23f7bf65fa9ac3c84a8262405a3ce1171f --- README.md | 2 +- src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 32b7d8fa..0e758242 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ - **Declarative design.** teloxide is based upon [`dptree`], a functional [chain of responsibility] pattern that allows you to express pipelines of message processing in a highly declarative and extensible style. -[`dptree`]: https://github.com/p0lunin/dptree +[`dptree`]: https://github.com/teloxide/dptree [chain of responsibility]: https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern - **Dialogues management subsystem.** Our dialogues management subsystem is simple and easy-to-use, and, furthermore, is agnostic of how/where dialogues are stored. For example, you can just replace a one line to achieve [persistence]. Out-of-the-box storages include [Redis] and [Sqlite]. diff --git a/src/lib.rs b/src/lib.rs index f25e81a9..f53ed5c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,10 @@ //! A full-featured framework that empowers you to easily build [Telegram bots] -//! using the [`async`/`.await`] syntax in [Rust]. It handles all the difficult -//! stuff so you can focus only on your business logic. +//! 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](https://github.com/teloxide/teloxide). //! -//! ([Full](https://github.com/teloxide/teloxide/blob/master/examples/throw_dice.rs)) +//! [[`examples/throw_dice.rs`](https://github.com/teloxide/teloxide/blob/master/examples/throw_dice.rs)] //! ```no_run //! use teloxide::prelude::*; //! @@ -25,7 +25,7 @@ //! //!
//! -//! +//! //! //!
//! From 93dfb00b5c862273d9a487c4d299ac17c0de6a1d Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:38:19 +0600 Subject: [PATCH 06/11] Update the `nightly` toolchain (CI) Former-commit-id: 898ef3ab6217a53ed9b4b44fcf02f5623dc82cd9 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b60d7eb..e990ad6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-02-02 + toolchain: nightly-2022-05-06 override: true components: rustfmt @@ -37,7 +37,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-02-02 + toolchain: nightly-2022-05-06 override: true components: clippy @@ -65,7 +65,7 @@ jobs: toolchain: beta features: "--features full" - rust: nightly - toolchain: nightly-2022-01-17 + toolchain: nightly-2022-05-06 features: "--all-features" - rust: msrv toolchain: "1.58.0" From 965515eec4885d14c921c0a6e3816044b47fea27 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:40:40 +0600 Subject: [PATCH 07/11] Update `rust-toolchain.toml` Former-commit-id: 2a0f8260bd86424acc380122ea285c730ec6713a --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7158d75f..43d17c19 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2022-02-02" +channel = "nightly-2022-05-06" components = ["rustfmt", "clippy"] profile = "minimal" From 74b246a98819faf88aa09d866ea53a48fa4c413a Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:48:43 +0600 Subject: [PATCH 08/11] Test the `rename` attribute Former-commit-id: 4494acda885f9ed4cb8e5b0889a24074333a5b2a --- Cargo.toml | 2 +- tests/command.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 25c9bde4..8ac124e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ full = [ [dependencies] teloxide-core = { version = "0.6.0", default-features = false } -teloxide-macros = { version = "0.6.1", optional = true } +teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", rev = "e344b11dcc0466d1cbbef1139e8cd0646e776188", optional = true } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } diff --git a/tests/command.rs b/tests/command.rs index a522b2a3..b3e6609e 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -218,6 +218,8 @@ fn rename_rules() { GggGgg, #[command(rename = "SCREAMING-KEBAB-CASE")] HhhHhh, + #[command(rename = "Bar")] + Foo, } assert_eq!(DefaultCommands::AaaAaa, DefaultCommands::parse("/aaaaaa", "").unwrap()); @@ -228,9 +230,10 @@ fn rename_rules() { assert_eq!(DefaultCommands::FffFff, DefaultCommands::parse("/FFF_FFF", "").unwrap()); assert_eq!(DefaultCommands::GggGgg, DefaultCommands::parse("/ggg-ggg", "").unwrap()); assert_eq!(DefaultCommands::HhhHhh, DefaultCommands::parse("/HHH-HHH", "").unwrap()); + assert_eq!(DefaultCommands::Foo, DefaultCommands::parse("/Bar", "").unwrap()); assert_eq!( - "/aaaaaa\n/BBBBBB\n/CccCcc\n/dddDdd\n/eee_eee\n/FFF_FFF\n/ggg-ggg\n/HHH-HHH", + "/aaaaaa\n/BBBBBB\n/CccCcc\n/dddDdd\n/eee_eee\n/FFF_FFF\n/ggg-ggg\n/HHH-HHH\n/Bar", DefaultCommands::descriptions().to_string() ); } From e2159c7676fcb19373740775ddbf00cc2773b314 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 26 May 2022 23:53:01 +0600 Subject: [PATCH 09/11] Update the changelog Former-commit-id: 1fcf44d380eaec1a7a9bc4f8b550cd97cde1f369 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec99c9a7..3a36f5f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## unreleased +### Fixed + + - Fix `#[command(rename = "...")]` for custom command names ([issue 633](https://github.com/teloxide/teloxide/issues/633)). + ## 0.9.0 - 2022-04-27 ### Added From 41f670d369a350b7f1361ea00b2379d3a4e89301 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Fri, 27 May 2022 00:12:03 +0600 Subject: [PATCH 10/11] Update `teloxide-macros` to v0.6.2 Former-commit-id: e7de79b97584ec84b011e16402bd82f7ac9a71a3 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8ac124e2..0fe4cc3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ full = [ [dependencies] teloxide-core = { version = "0.6.0", default-features = false } -teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", rev = "e344b11dcc0466d1cbbef1139e8cd0646e776188", optional = true } +teloxide-macros = { version = "0.6.2", optional = true } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } From 2a43683cf5d1c6b6beca2c02b7119aa5a5663d0f Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Fri, 27 May 2022 00:27:57 +0600 Subject: [PATCH 11/11] Release v0.9.1 Former-commit-id: 1c02e38293650ce7bc3f08b83e06b7b226bd0718 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a36f5f4..821e928f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## unreleased +## 0.9.1 - 2022-05-27 + ### Fixed - Fix `#[command(rename = "...")]` for custom command names ([issue 633](https://github.com/teloxide/teloxide/issues/633)). diff --git a/Cargo.toml b/Cargo.toml index 0fe4cc3d..f5f91e99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "teloxide" -version = "0.9.0" +version = "0.9.1" edition = "2021" description = "An elegant Telegram bots framework for Rust" repository = "https://github.com/teloxide/teloxide"