mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-21 22:15:13 +01:00
Merge pull request #1176 from MrAliSalehi/master
improving `reply_keyboard_markup`
This commit is contained in:
commit
985a820e7b
2 changed files with 22 additions and 2 deletions
|
@ -65,11 +65,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Wrap `Public` variant of `ChatKind` in `Box`
|
||||
- Replaced `user_ids` with `users` in `UsersShared` struct
|
||||
|
||||
- Remove a useless generic type in the `KeyboardMarkup::selective` function ([#1176][pr1176])
|
||||
|
||||
[pr1131]: https://github.com/teloxide/teloxide/pull/1131
|
||||
[pr1134]: https://github.com/teloxide/teloxide/pull/1134
|
||||
[pr1146]: https://github.com/teloxide/teloxide/pull/1146
|
||||
[pr1147]: https://github.com/teloxide/teloxide/pull/1147
|
||||
[pr1151]: https://github.com/teloxide/teloxide/pull/1151
|
||||
[pr1176]: https://github.com/teloxide/teloxide/pull/1176
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ impl KeyboardMarkup {
|
|||
/// Sets [`selective`] to `true`.
|
||||
///
|
||||
/// [`selective`]: KeyboardMarkup::selective
|
||||
pub fn selective<T>(self) -> Self {
|
||||
pub fn selective(self) -> Self {
|
||||
Self { selective: true, ..self }
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,23 @@ mod tests {
|
|||
"selective": false
|
||||
}
|
||||
"#;
|
||||
serde_json::from_str::<KeyboardMarkup>(data).unwrap();
|
||||
assert!(serde_json::from_str::<KeyboardMarkup>(data).is_ok())
|
||||
}
|
||||
#[test]
|
||||
fn serialize() {
|
||||
let keyboard = vec![vec![
|
||||
KeyboardButton::new("a"),
|
||||
KeyboardButton::new("b"),
|
||||
KeyboardButton::new("c"),
|
||||
KeyboardButton::new("d"),
|
||||
]];
|
||||
let keyboard_markup = KeyboardMarkup::new(keyboard)
|
||||
.persistent()
|
||||
.resize_keyboard()
|
||||
.selective()
|
||||
.one_time_keyboard();
|
||||
let expected = r#"{"keyboard":[[{"text":"a"},{"text":"b"},{"text":"c"},{"text":"d"}]],"is_persistent":true,"resize_keyboard":true,"one_time_keyboard":true,"selective":true}"#;
|
||||
|
||||
assert!(serde_json::ser::to_string(&keyboard_markup).is_ok_and(|s| s.eq(expected)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue