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, InputPollMedia, InputPollOption, Message, MessageEntity,
8 ParseMode, PollType, Recipient, ReplyMarkup, ReplyParameters, Seconds, 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, 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 1-12 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, defaults to False
42 pub allows_multiple_answers: bool,
43 /// Pass True if the poll allows to change the chosen answer options
44 pub allows_revoting: bool,
45 /// Pass True if the poll options must be shown in random order
46 pub shuffle_options: bool,
47 /// Pass True if answer options can be added to the poll after creation; not supported for anonymous polls and quizzes
48 pub allow_adding_options: bool,
49 /// Pass True if poll results must be shown only after the poll closes
50 pub hide_results_until_closes: bool,
51 /// Pass _True_, if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours; for channel chats only
52 pub members_only: bool,
53 /// A JSON-serialized list of 0-12 two-letter [ISO 3166-1 alpha-2] country codes indicating the countries from which users can vote in the poll; for channel chats only. Use “FT” as a country code to allow users with anonymous numbers to vote. If omitted or empty, then users from any country can participate in the poll.
54 ///
55 /// [ISO 3166-1 alpha-2]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
56 pub country_codes: Vec<String> [collect],
57 /// A JSON-serialized list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode
58 pub correct_option_ids: Vec<u8> [collect],
59 /// 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
60 pub explanation: String [into],
61 /// Mode for parsing entities in the message text. See [formatting options] for more details.
62 ///
63 /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
64 pub explanation_parse_mode: ParseMode,
65 /// List of special entities that appear in the poll explanation, which can be specified instead of _parse\_mode_
66 pub explanation_entities: Vec<MessageEntity> [collect],
67 /// Media added to the quiz explanation
68 pub explanation_media: InputPollMedia,
69 /// Description of the poll to be sent, 0-1024 characters after entities parsing
70 pub description: String [into],
71 /// Mode for parsing entities in the poll description. See [formatting options] for more details.
72 ///
73 /// [formatting options]: https://core.telegram.org/bots/api#formatting-options
74 pub description_parse_mode: ParseMode,
75 /// A JSON-serialized list of special entities that appear in the poll description, which can be specified instead of description_parse_mode
76 pub description_entities: Vec<MessageEntity> [collect],
77 /// Media added to the poll description
78 pub media: InputPollMedia,
79 /// Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with close_date.
80 pub open_period: Seconds,
81 /// 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.
82 #[serde(with = "crate::types::serde_opt_date_from_unix_timestamp")]
83 pub close_date: DateTime<Utc> [into],
84 /// Pass True, if the poll needs to be immediately closed. This can be useful for poll preview.
85 pub is_closed: bool,
86 /// Sends the message [silently]. Users will receive a notification with no sound.
87 ///
88 /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
89 pub disable_notification: bool,
90 /// Protects the contents of sent messages from forwarding and saving
91 pub protect_content: bool,
92 /// 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
93 pub allow_paid_broadcast: bool,
94 /// Unique identifier of the message effect to be added to the message; for private chats only
95 pub message_effect_id: EffectId,
96 /// Description of the message to reply to
97 pub reply_parameters: ReplyParameters,
98 /// 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.
99 ///
100 /// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
101 /// [custom reply keyboard]: https://core.telegram.org/bots#keyboards
102 pub reply_markup: ReplyMarkup [into],
103 }
104 }
105}