Skip to main content

ronami_core/payloads/
send_poll.rs

1//! Generated by `codegen_payloads`, do not edit by hand.
2
3use chrono::{DateTime, Utc};
4use serde::Serialize;
5
6use crate::types::BusinessConnectionId;
7use crate::types::EffectId;
8use crate::types::InputPollMedia;
9use crate::types::InputPollOption;
10use crate::types::Message;
11use crate::types::MessageEntity;
12use crate::types::ParseMode;
13use crate::types::PollType;
14use crate::types::Recipient;
15use crate::types::ReplyMarkup;
16use crate::types::ReplyParameters;
17use crate::types::ThreadId;
18
19impl_payload! {
20    /// Use this method to send a native poll. On success, the sent [`Message`] is returned.
21    ///
22    /// [`Message`]: crate::types::Message
23    #[derive(Debug, PartialEq, Clone, Serialize)]
24    pub SendPoll (SendPollSetters) => Message {
25        required {
26            /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
27            pub chat_id: Recipient [into],
28            /// Poll question, 1-300 characters
29            pub question: String [into],
30            /// A JSON-serialized list of 2-10 answer options
31            pub options: Vec<InputPollOption> [collect],
32        }
33        optional {
34            /// Unique identifier of the business connection on behalf of which the message will be sent
35            pub business_connection_id: BusinessConnectionId,
36            /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
37            pub message_thread_id: ThreadId,
38            /// Mode for parsing entities in the question. See [formatting options] for more details. Currently, only custom emoji entities are allowed
39            ///
40            /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
41            pub question_parse_mode: ParseMode,
42            /// A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of _question\_parse\_mode_
43            pub question_entities: Vec<MessageEntity> [collect],
44            /// True, if the poll needs to be anonymous, defaults to True
45            pub is_anonymous: bool,
46            /// Poll type, “quiz” or “regular”, defaults to “regular”
47            #[serde(rename = "type")]
48            pub type_: PollType,
49            /// True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
50            pub allows_multiple_answers: bool,
51            /// True, if the poll allows to change the chosen answer options, defaults to False
52            pub allows_revoting: bool,
53            /// Pass True, if the options should be shuffled, defaults to False
54            pub shuffle_options: bool,
55            /// Pass True, if other users should be allowed to add options to the poll, defaults to False
56            pub allow_adding_options: bool,
57            /// Pass True, if the poll results should be hidden until the poll is closed, defaults to False
58            pub hide_results_until_closes: bool,
59            /// Pass True, if the poll is not available for users, that are not in the chat; for supergroups only
60            pub members_only: bool,
61            /// A JSON-serialized list of countries in the [ISO 3166-1 alpha-2] format for which the poll can be voted in by regular users
62            pub country_codes: Vec<String> [collect],
63            /// 0-based identifiers of the correct answer options, required for polls in quiz mode
64            pub correct_option_ids: Vec<u8> [collect],
65            /// Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
66            pub explanation: String [into],
67            /// Mode for parsing entities in the message text. See [formatting options] for more details.
68            ///
69            /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
70            pub explanation_parse_mode: ParseMode,
71            /// List of special entities that appear in the poll explanation, which can be specified instead of _parse\_mode_
72            pub explanation_entities: Vec<MessageEntity> [collect],
73            /// A JSON-serialized object for the media in the explanation to be sent
74            pub explanation_media: InputPollMedia,
75            /// Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with close_date.
76            pub open_period: u32,
77            /// Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 2628000 seconds in the future. Can't be used together with open_period.
78            #[serde(with = "crate::types::serde_opt_date_from_unix_timestamp")]
79            pub close_date: DateTime<Utc> [into],
80            /// Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
81            pub is_closed: bool,
82            /// Description of the poll, 0-1024 characters after entities parsing
83            pub description: String [into],
84            /// Mode for parsing entities in the poll description. See [formatting options] for more details.
85            ///
86            /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
87            pub description_parse_mode: ParseMode,
88            /// List of special entities that appear in the poll description, which can be specified instead of _description\_parse\_mode_
89            pub description_entities: Vec<MessageEntity> [collect],
90            /// A JSON-serialized object for the media added to the poll description
91            pub media: InputPollMedia,
92            /// Sends the message [silently]. Users will receive a notification with no sound.
93            ///
94            /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
95            pub disable_notification: bool,
96            /// Protects the contents of sent messages from forwarding and saving
97            pub protect_content: bool,
98            /// Pass `true` to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
99            pub allow_paid_broadcast: bool,
100            /// Unique identifier of the message effect to be added to the message; for private chats only
101            pub message_effect_id: EffectId,
102            /// Description of the message to reply to
103            pub reply_parameters: ReplyParameters,
104            /// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account.
105            ///
106            /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
107            /// [custom reply keyboard]: https://core.telegram.org/bots#keyboards
108            pub reply_markup: ReplyMarkup [into],
109        }
110    }
111}