mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
commit
f08abd3472
2 changed files with 90 additions and 2 deletions
|
@ -3,7 +3,7 @@ use serde::Serialize;
|
||||||
use crate::{
|
use crate::{
|
||||||
net,
|
net,
|
||||||
requests::{Request, ResponseResult},
|
requests::{Request, ResponseResult},
|
||||||
types::{ChatId, Message, PollType, ReplyMarkup},
|
types::{ChatId, Message, ParseMode, PollType, ReplyMarkup},
|
||||||
Bot,
|
Bot,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ pub struct SendPoll {
|
||||||
poll_type: Option<PollType>,
|
poll_type: Option<PollType>,
|
||||||
allows_multiple_answers: Option<bool>,
|
allows_multiple_answers: Option<bool>,
|
||||||
correct_option_id: Option<i32>,
|
correct_option_id: Option<i32>,
|
||||||
|
explanation: Option<String>,
|
||||||
|
explanation_parse_mode: Option<ParseMode>,
|
||||||
|
open_period: Option<i32>,
|
||||||
|
close_date: Option<i32>,
|
||||||
is_closed: Option<bool>,
|
is_closed: Option<bool>,
|
||||||
disable_notification: Option<bool>,
|
disable_notification: Option<bool>,
|
||||||
reply_to_message_id: Option<i32>,
|
reply_to_message_id: Option<i32>,
|
||||||
|
@ -56,10 +60,14 @@ impl SendPoll {
|
||||||
poll_type: None,
|
poll_type: None,
|
||||||
allows_multiple_answers: None,
|
allows_multiple_answers: None,
|
||||||
correct_option_id: None,
|
correct_option_id: None,
|
||||||
|
explanation: None,
|
||||||
|
explanation_parse_mode: None,
|
||||||
is_closed: None,
|
is_closed: None,
|
||||||
disable_notification: None,
|
disable_notification: None,
|
||||||
reply_to_message_id: None,
|
reply_to_message_id: None,
|
||||||
reply_markup: None,
|
reply_markup: None,
|
||||||
|
close_date: None,
|
||||||
|
open_period: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +139,41 @@ impl SendPoll {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
pub fn explanation<T>(mut self, val: T) -> Self
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
self.explanation = Some(val.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mode for parsing entities in the explanation. See [formatting options]
|
||||||
|
/// for more details.
|
||||||
|
///
|
||||||
|
/// [formatting options]: https://core.telegram.org/bots/api#formatting-options
|
||||||
|
pub fn explanation_parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
|
self.explanation_parse_mode = Some(val);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Amount of time in seconds the poll will be active after creation, 5-600.
|
||||||
|
/// Can't be used together with `close_date`.
|
||||||
|
pub fn open_period(mut self, val: i32) -> Self {
|
||||||
|
self.open_period = Some(val);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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`.
|
||||||
|
pub fn close_date(mut self, val: i32) -> Self {
|
||||||
|
self.close_date = Some(val);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Pass `true`, if the poll needs to be immediately closed.
|
/// Pass `true`, if the poll needs to be immediately closed.
|
||||||
///
|
///
|
||||||
/// This can be useful for poll preview.
|
/// This can be useful for poll preview.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::types::PollType;
|
use crate::types::{MessageEntity, PollType};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// This object contains information about a poll.
|
/// This object contains information about a poll.
|
||||||
|
@ -37,6 +37,21 @@ pub struct Poll {
|
||||||
/// polls in the quiz mode, which are closed, or was sent (not
|
/// polls in the quiz mode, which are closed, or was sent (not
|
||||||
/// forwarded) by the bot or to the private chat with the bot.
|
/// forwarded) by the bot or to the private chat with the bot.
|
||||||
pub correct_option_id: Option<i32>,
|
pub correct_option_id: Option<i32>,
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
pub explanation: Option<String>,
|
||||||
|
|
||||||
|
/// Special entities like usernames, URLs, bot commands, etc. that appear in
|
||||||
|
/// the explanation.
|
||||||
|
pub explanation_entities: Option<Vec<MessageEntity>>,
|
||||||
|
|
||||||
|
/// Amount of time in seconds the poll will be active after creation.
|
||||||
|
open_period: Option<i32>,
|
||||||
|
|
||||||
|
/// Point in time (Unix timestamp) when the poll will be automatically
|
||||||
|
/// closed.
|
||||||
|
close_date: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Poll {
|
impl Poll {
|
||||||
|
@ -66,6 +81,10 @@ impl Poll {
|
||||||
poll_type,
|
poll_type,
|
||||||
allows_multiple_answers,
|
allows_multiple_answers,
|
||||||
correct_option_id: None,
|
correct_option_id: None,
|
||||||
|
explanation: None,
|
||||||
|
explanation_entities: None,
|
||||||
|
open_period: None,
|
||||||
|
close_date: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +143,32 @@ impl Poll {
|
||||||
self.correct_option_id = Some(val);
|
self.correct_option_id = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn explanation<S>(mut self, val: S) -> Self
|
||||||
|
where
|
||||||
|
S: Into<String>,
|
||||||
|
{
|
||||||
|
self.explanation = Some(val.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn explanation_entities<S>(mut self, val: S) -> Self
|
||||||
|
where
|
||||||
|
S: Into<Vec<MessageEntity>>,
|
||||||
|
{
|
||||||
|
self.explanation_entities = Some(val.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn open_period(mut self, val: i32) -> Self {
|
||||||
|
self.open_period = Some(val);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn close_date(mut self, val: i32) -> Self {
|
||||||
|
self.close_date = Some(val);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This object contains information about one answer option in a poll.
|
/// This object contains information about one answer option in a poll.
|
||||||
|
|
Loading…
Add table
Reference in a new issue