diff --git a/src/requests/all/send_poll.rs b/src/requests/all/send_poll.rs index 940ade12..ce90fa1f 100644 --- a/src/requests/all/send_poll.rs +++ b/src/requests/all/send_poll.rs @@ -7,6 +7,7 @@ use crate::{ types::{ChatId, Message, ReplyMarkup}, Bot, }; +use crate::types::PollType; /// Use this method to send a native poll. A native poll can't be sent to a /// private chat. @@ -20,6 +21,11 @@ pub struct SendPoll<'a> { chat_id: ChatId, question: String, options: Vec, + is_anonymous: Option, + poll_type: Option, + allows_multiple_answers: Option, + correct_option_id: Option, + is_closed: Option, disable_notification: Option, reply_to_message_id: Option, reply_markup: Option, @@ -60,6 +66,11 @@ impl<'a> SendPoll<'a> { chat_id, question, options, + is_anonymous: None, + poll_type: None, + allows_multiple_answers: None, + correct_option_id: None, + is_closed: None, disable_notification: None, reply_to_message_id: None, reply_markup: None, @@ -96,6 +107,49 @@ impl<'a> SendPoll<'a> { self } + /// True, if the poll needs to be anonymous, defaults to True + pub fn is_anonymous(mut self, val: T) -> Self + where + T: Into, + { + self.is_anonymous = Some(val.into()); + self + } + + /// Poll type, “quiz” or “regular”, defaults to “regular” + pub fn poll_type(mut self, val: PollType) -> Self + { + self.poll_type = Some(val); + self + } + + /// True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False + pub fn allows_multiple_answers(mut self, val: T) -> Self + where + T: Into, + { + self.allows_multiple_answers = Some(val.into()); + self + } + + /// 0-based identifier of the correct answer option, required for polls in quiz mode + pub fn correct_option_id(mut self, val: T) -> Self + where + T: Into, + { + self.correct_option_id = Some(val.into()); + self + } + + /// Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. + pub fn is_closed(mut self, val: T) -> Self + where + T: Into, + { + self.is_closed = Some(val.into()); + self + } + /// Sends the message [silently]. Users will receive a notification with no /// sound. /// diff --git a/src/types/mod.rs b/src/types/mod.rs index 01a6f2ae..edb6835a 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -62,6 +62,7 @@ pub use passport_data::*; pub use passport_element_error::*; pub use passport_file::*; pub use photo_size::*; +pub use poll_type::*; pub use poll::*; pub use pre_checkout_query::*; pub use reply_keyboard_markup::*; @@ -122,6 +123,7 @@ mod order_info; mod parse_mode; mod photo_size; mod poll; +mod poll_type; mod pre_checkout_query; mod reply_keyboard_markup; mod reply_keyboard_remove; diff --git a/src/types/poll_type.rs b/src/types/poll_type.rs new file mode 100644 index 00000000..89e56017 --- /dev/null +++ b/src/types/poll_type.rs @@ -0,0 +1,8 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum PollType { + Quiz, + Regular, +} \ No newline at end of file