tg_flows/types/
bot_command.rs

1use serde::{Deserialize, Serialize};
2
3/// This object represents a bot command.
4///
5/// [The official docs](https://core.telegram.org/bots/api#botcommand).
6#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
7pub struct BotCommand {
8    /// Text of the command, 1-32 characters.
9    ///
10    /// Can contain only lowercase English letters, digits and underscores.
11    pub command: String,
12
13    /// Description of the command, 3-256 characters.
14    pub description: String,
15}
16
17impl BotCommand {
18    pub fn new<S1, S2>(command: S1, description: S2) -> Self
19    where
20        S1: Into<String>,
21        S2: Into<String>,
22    {
23        Self { command: command.into(), description: description.into() }
24    }
25
26    pub fn command<S>(mut self, val: S) -> Self
27    where
28        S: Into<String>,
29    {
30        self.command = val.into();
31        self
32    }
33
34    pub fn description<S>(mut self, val: S) -> Self
35    where
36        S: Into<String>,
37    {
38        self.description = val.into();
39        self
40    }
41}