Merge pull request #1182 from LasterAlex/fix-inline-query-results-button-serializing

Fixed InlineQueryResultsButton serialization
This commit is contained in:
Lewis Pearson 2024-10-17 05:47:16 +00:00 committed by GitHub
commit 329e397900
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View file

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Now Vec<MessageId> in requests serializes into [number] instead of [ {message_id: number} ], `forward_messages`, `copy_messages` and `delete_messages` now work properly
- Now `InlineQueryResultsButton` serializes properly ([issue 1181](https://github.com/teloxide/teloxide/issues/1181))
## 0.13.0 - 2024-08-16

View file

@ -17,6 +17,7 @@ pub struct InlineQueryResultsButton {
}
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InlineQueryResultsButtonKind {
/// Description of the [Web App] that will be launched when the user presses
/// the button. The Web App will be able to switch back to the inline mode
@ -44,3 +45,19 @@ pub enum InlineQueryResultsButtonKind {
/// [switch_inline]: https://core.telegram.org/bots/api#inlinekeyboardmarkup
StartParameter(String),
}
#[cfg(test)]
mod tests {
use crate::types::{InlineQueryResultsButton, InlineQueryResultsButtonKind};
#[test]
fn inline_query_results_button() {
let button = InlineQueryResultsButton {
text: "test".into(),
kind: InlineQueryResultsButtonKind::StartParameter("bot".into()),
};
let expected = r#"{"text":"test","start_parameter":"bot"}"#;
let actual = serde_json::to_string(&button).unwrap();
assert_eq!(expected, actual);
}
}