telers/types/
inline_query_result_game.rs

1use super::InlineKeyboardMarkup;
2
3use serde::{Deserialize, Serialize};
4use serde_with::skip_serializing_none;
5
6/// Represents a [`Game`](https://core.telegram.org/bots/api#games).
7/// # Notes
8/// This will only work in Telegram versions released after October 1, 2016. Older clients will not display any inline results if a game result is among them.
9/// # Documentation
10/// <https://core.telegram.org/bots/api#inlinequeryresultgame>
11#[skip_serializing_none]
12#[derive(Debug, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)]
13pub struct InlineQueryResultGame {
14    /// Unique identifier for this result, 1-64 Bytes
15    pub id: String,
16    /// Short name of the game
17    pub game_short_name: String,
18    /// [`Inline keyboard`](https://core.telegram.org/bots/features#inline-keyboards) attached to the message
19    pub reply_markup: Option<InlineKeyboardMarkup>,
20}
21
22impl InlineQueryResultGame {
23    #[must_use]
24    pub fn new(id: impl Into<String>, game_short_name: impl Into<String>) -> Self {
25        Self {
26            id: id.into(),
27            game_short_name: game_short_name.into(),
28            reply_markup: None,
29        }
30    }
31
32    #[must_use]
33    pub fn id(self, val: impl Into<String>) -> Self {
34        Self {
35            id: val.into(),
36            ..self
37        }
38    }
39
40    #[must_use]
41    pub fn game_short_name(self, val: impl Into<String>) -> Self {
42        Self {
43            game_short_name: val.into(),
44            ..self
45        }
46    }
47
48    #[must_use]
49    pub fn reply_markup(self, val: impl Into<InlineKeyboardMarkup>) -> Self {
50        Self {
51            reply_markup: Some(val.into()),
52            ..self
53        }
54    }
55}
56
57impl InlineQueryResultGame {
58    #[must_use]
59    pub fn reply_markup_option(self, val: Option<impl Into<InlineKeyboardMarkup>>) -> Self {
60        Self {
61            reply_markup: val.map(Into::into),
62            ..self
63        }
64    }
65}