mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Merge pull request #639 from teloxide/dev
Merge v0.9.1
Former-commit-id: ec1d41220c
This commit is contained in:
commit
8f70513e8b
14 changed files with 54 additions and 47 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-02-02
|
toolchain: nightly-2022-05-06
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-02-02
|
toolchain: nightly-2022-05-06
|
||||||
override: true
|
override: true
|
||||||
components: clippy
|
components: clippy
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ jobs:
|
||||||
toolchain: beta
|
toolchain: beta
|
||||||
features: "--features full"
|
features: "--features full"
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
toolchain: nightly-2022-01-17
|
toolchain: nightly-2022-05-06
|
||||||
features: "--all-features"
|
features: "--all-features"
|
||||||
- rust: msrv
|
- rust: msrv
|
||||||
toolchain: "1.58.0"
|
toolchain: "1.58.0"
|
||||||
|
|
|
@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## unreleased
|
## unreleased
|
||||||
|
|
||||||
|
## 0.9.1 - 2022-05-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix `#[command(rename = "...")]` for custom command names ([issue 633](https://github.com/teloxide/teloxide/issues/633)).
|
||||||
|
|
||||||
## 0.9.0 - 2022-04-27
|
## 0.9.0 - 2022-04-27
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "teloxide"
|
name = "teloxide"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "An elegant Telegram bots framework for Rust"
|
description = "An elegant Telegram bots framework for Rust"
|
||||||
repository = "https://github.com/teloxide/teloxide"
|
repository = "https://github.com/teloxide/teloxide"
|
||||||
|
@ -57,7 +57,7 @@ full = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
teloxide-core = { version = "0.6.0", default-features = false }
|
teloxide-core = { version = "0.6.0", default-features = false }
|
||||||
teloxide-macros = { version = "0.6.1", optional = true }
|
teloxide-macros = { version = "0.6.2", optional = true }
|
||||||
|
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
58
README.md
58
README.md
|
@ -18,17 +18,17 @@
|
||||||
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.0%20(inclusively)-green.svg">
|
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.0%20(inclusively)-green.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://t.me/teloxide">
|
<a href="https://t.me/teloxide">
|
||||||
<img src="https://img.shields.io/badge/official%20chat-t.me%2Fteloxide-blueviolet">
|
<img src="https://img.shields.io/badge/support-t.me%2Fteloxide-blueviolet">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
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.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Highlights
|
## 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
|
[`dptree`]: https://github.com/teloxide/dptree
|
||||||
[chain of responsibility]: https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern
|
[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].
|
- **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].
|
||||||
|
@ -84,7 +84,7 @@ tokio = { version = "1.8", features = ["rt-multi-thread", "macros"] }
|
||||||
|
|
||||||
This bot replies with a dice throw to each received message:
|
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
|
```rust,no_run
|
||||||
use teloxide::prelude::*;
|
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/
|
[structopt]: https://docs.rs/structopt/0.3.9/structopt/
|
||||||
[serde-json]: https://github.com/serde-rs/json
|
[serde-json]: https://github.com/serde-rs/json
|
||||||
|
|
||||||
([Full](examples/command.rs))
|
[[`examples/command.rs`](examples/command.rs)]
|
||||||
|
|
||||||
```rust,no_run
|
```rust,no_run
|
||||||
use teloxide::{prelude::*, utils::command::BotCommands};
|
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:
|
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
|
```rust,ignore
|
||||||
use teloxide::{dispatching::dialogue::InMemStorage, prelude::*};
|
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!
|
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.
|
- [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.
|
- [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.
|
- [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.
|
- [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/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
|
- [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.
|
- [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.
|
- [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.
|
- [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/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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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.
|
- [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
|
- [studiedlist/EddieBot](https://gitlab.com/studiedlist/eddie-bot) — Chatting bot with several entertainment features.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-02-02"
|
channel = "nightly-2022-05-06"
|
||||||
components = ["rustfmt", "clippy"]
|
components = ["rustfmt", "clippy"]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
| `cache-me` | Enables the [`CacheMe`](adaptors::CacheMe) bot adaptor. |
|
| `cache-me` | Enables the [`CacheMe`](adaptors::CacheMe) bot adaptor. |
|
||||||
| `trace-adaptor` | Enables the [`Trace`](adaptors::Trace) bot adaptor. |
|
| `trace-adaptor` | Enables the [`Trace`](adaptors::Trace) bot adaptor. |
|
||||||
| `erased` | Enables the [`ErasedRequester`](adaptors::ErasedRequester) bot adaptor. |
|
| `erased` | Enables the [`ErasedRequester`](adaptors::ErasedRequester) bot adaptor. |
|
||||||
| `frunk` | Enables [`teloxide::utils::UpState`]. |
|
|
||||||
| `full` | Enables all the features except `nightly`. |
|
| `full` | Enables all the features except `nightly`. |
|
||||||
| `nightly` | Enables nightly-only features (see the [teloxide-core features]). |
|
| `nightly` | Enables nightly-only features (see the [teloxide-core features]). |
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//! A full-featured framework that empowers you to easily build [Telegram bots]
|
//! A full-featured framework that empowers you to easily build [Telegram bots]
|
||||||
//! using the [`async`/`.await`] syntax in [Rust]. It handles all the difficult
|
//! using [Rust]. It handles all the difficult stuff so you can focus only on
|
||||||
//! stuff so you can focus only on your business logic.
|
//! your business logic.
|
||||||
//!
|
//!
|
||||||
//! For a high-level overview, see [our GitHub repository](https://github.com/teloxide/teloxide).
|
//! 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
|
//! ```no_run
|
||||||
//! use teloxide::prelude::*;
|
//! use teloxide::prelude::*;
|
||||||
//!
|
//!
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
//!
|
//!
|
||||||
//! <div align="center">
|
//! <div align="center">
|
||||||
//! <kbd>
|
//! <kbd>
|
||||||
//! <img src=https://github.com/teloxide/teloxide/raw/master/media/DICES_BOT.gif />
|
//! <img src=https://github.com/teloxide/teloxide/raw/master/media/throw-dice.gif width=420px />
|
||||||
//! </kbd>
|
//! </kbd>
|
||||||
//! </div>
|
//! </div>
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -6,6 +6,3 @@ pub mod markdown;
|
||||||
pub(crate) mod shutdown_token;
|
pub(crate) mod shutdown_token;
|
||||||
|
|
||||||
pub use teloxide_core::net::client_from_env;
|
pub use teloxide_core::net::client_from_env;
|
||||||
|
|
||||||
#[cfg(feature = "frunk")]
|
|
||||||
pub use up_state::UpState;
|
|
|
@ -160,8 +160,10 @@ pub use teloxide_macros::BotCommands;
|
||||||
/// All variant attributes override the corresponding `enum` attributes.
|
/// All variant attributes override the corresponding `enum` attributes.
|
||||||
///
|
///
|
||||||
/// 1. `#[command(rename = "rule")]`
|
/// 1. `#[command(rename = "rule")]`
|
||||||
/// Rename one command by a rule. Allowed rules are `lowercase`, `%some_name%`,
|
/// Rename one command by a rule. Allowed rules are `lowercase`, `UPPERCASE`,
|
||||||
/// where `%some_name%` is any string, a new name.
|
/// `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")]`
|
/// 2. `#[command(description = "description")]`
|
||||||
/// Give your command a description. Write `"off"` for `"description"` to hide a
|
/// Give your command a description. Write `"off"` for `"description"` to hide a
|
||||||
|
@ -323,7 +325,7 @@ impl<'a> CommandDescriptions<'a> {
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// descriptions.username("username_of_the_bot").to_string(),
|
/// descriptions.username("username_of_the_bot").to_string(),
|
||||||
/// "/start@username_of_the_bot — start this bot\n/help@username_of_the_bot — show this \
|
/// "/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 {
|
pub fn username(self, bot_username: &'a str) -> Self {
|
||||||
|
|
|
@ -218,6 +218,8 @@ fn rename_rules() {
|
||||||
GggGgg,
|
GggGgg,
|
||||||
#[command(rename = "SCREAMING-KEBAB-CASE")]
|
#[command(rename = "SCREAMING-KEBAB-CASE")]
|
||||||
HhhHhh,
|
HhhHhh,
|
||||||
|
#[command(rename = "Bar")]
|
||||||
|
Foo,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(DefaultCommands::AaaAaa, DefaultCommands::parse("/aaaaaa", "").unwrap());
|
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::FffFff, DefaultCommands::parse("/FFF_FFF", "").unwrap());
|
||||||
assert_eq!(DefaultCommands::GggGgg, DefaultCommands::parse("/ggg-ggg", "").unwrap());
|
assert_eq!(DefaultCommands::GggGgg, DefaultCommands::parse("/ggg-ggg", "").unwrap());
|
||||||
assert_eq!(DefaultCommands::HhhHhh, DefaultCommands::parse("/HHH-HHH", "").unwrap());
|
assert_eq!(DefaultCommands::HhhHhh, DefaultCommands::parse("/HHH-HHH", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Foo, DefaultCommands::parse("/Bar", "").unwrap());
|
||||||
|
|
||||||
assert_eq!(
|
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()
|
DefaultCommands::descriptions().to_string()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue