teloxide_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::{
7    BusinessConnectionId, EffectId, InputPollOption, Message, MessageEntity, ParseMode, PollType,
8    Recipient, ReplyMarkup, ReplyParameters, ThreadId,
9};
10
11impl_payload! {
12    /// Use this method to send a native poll. On success, the sent [`Message`] is returned.
13    ///
14    /// [`Message`]: crate::types::Message
15    #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
16    pub SendPoll (SendPollSetters) => Message {
17        required {
18            /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
19            pub chat_id: Recipient [into],
20            /// Poll question, 1-300 characters
21            pub question: String [into],
22            /// A JSON-serialized list of 2-10 answer options
23            pub options: Vec<InputPollOption> [collect],
24        }
25        optional {
26            /// Unique identifier of the business connection on behalf of which the message will be sent
27            pub business_connection_id: BusinessConnectionId,
28            /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
29            pub message_thread_id: ThreadId,
30            /// Mode for parsing entities in the question. See [formatting options] for more details. Currently, only custom emoji entities are allowed
31            ///
32            /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
33            pub question_parse_mode: ParseMode,
34            /// A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of _question\_parse\_mode_
35            pub question_entities: Vec<MessageEntity> [collect],
36            /// True, if the poll needs to be anonymous, defaults to True
37            pub is_anonymous: bool,
38            /// Poll type, “quiz” or “regular”, defaults to “regular”
39            #[serde(rename = "type")]
40            pub type_: PollType,
41            /// True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
42            pub allows_multiple_answers: bool,
43            /// 0-based identifier of the correct answer option, required for polls in quiz mode
44            pub correct_option_id: u8,
45            /// 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
46            pub explanation: String [into],
47            /// Mode for parsing entities in the message text. See [formatting options] for more details.
48            ///
49            /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
50            pub explanation_parse_mode: ParseMode,
51            /// List of special entities that appear in the poll explanation, which can be specified instead of _parse\_mode_
52            pub explanation_entities: Vec<MessageEntity> [collect],
53            /// Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
54            pub open_period: u16,
55            /// Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period.
56            #[serde(with = "crate::types::serde_opt_date_from_unix_timestamp")]
57            pub close_date: DateTime<Utc> [into],
58            /// Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
59            pub is_closed: bool,
60            /// Sends the message [silently]. Users will receive a notification with no sound.
61            ///
62            /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
63            pub disable_notification: bool,
64            /// Protects the contents of sent messages from forwarding and saving
65            pub protect_content: bool,
66            /// 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
67            pub allow_paid_broadcast: bool,
68            /// Unique identifier of the message effect to be added to the message; for private chats only
69            pub message_effect_id: EffectId,
70            /// Description of the message to reply to
71            pub reply_parameters: ReplyParameters,
72            /// 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.
73            ///
74            /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
75            /// [custom reply keyboard]: https://core.telegram.org/bots#keyboards
76            pub reply_markup: ReplyMarkup [into],
77        }
78    }
79}