mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
added new fields to sendPoll
This commit is contained in:
parent
347ea9320f
commit
fb3f0558c2
3 changed files with 64 additions and 0 deletions
|
@ -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<String>,
|
||||
is_anonymous: Option<bool>,
|
||||
poll_type: Option<PollType>,
|
||||
allows_multiple_answers: Option<bool>,
|
||||
correct_option_id: Option<i32>,
|
||||
is_closed: Option<bool>,
|
||||
disable_notification: Option<bool>,
|
||||
reply_to_message_id: Option<i32>,
|
||||
reply_markup: Option<ReplyMarkup>,
|
||||
|
@ -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<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<bool>,
|
||||
{
|
||||
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<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<bool>,
|
||||
{
|
||||
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<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<i32>,
|
||||
{
|
||||
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<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<bool>,
|
||||
{
|
||||
self.is_closed = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sends the message [silently]. Users will receive a notification with no
|
||||
/// sound.
|
||||
///
|
||||
|
|
|
@ -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;
|
||||
|
|
8
src/types/poll_type.rs
Normal file
8
src/types/poll_type.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum PollType {
|
||||
Quiz,
|
||||
Regular,
|
||||
}
|
Loading…
Reference in a new issue