mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
added new type poll_answer
This commit is contained in:
parent
357e2640f4
commit
95b190e573
3 changed files with 23 additions and 1 deletions
|
@ -64,6 +64,7 @@ pub use passport_element_error::*;
|
|||
pub use passport_file::*;
|
||||
pub use photo_size::*;
|
||||
pub use poll_type::*;
|
||||
pub use poll_answer::*;
|
||||
pub use poll::*;
|
||||
pub use pre_checkout_query::*;
|
||||
pub use reply_keyboard_markup::*;
|
||||
|
@ -125,6 +126,7 @@ mod order_info;
|
|||
mod parse_mode;
|
||||
mod photo_size;
|
||||
mod poll;
|
||||
mod poll_answer;
|
||||
mod poll_type;
|
||||
mod pre_checkout_query;
|
||||
mod reply_keyboard_markup;
|
||||
|
|
14
src/types/poll_answer.rs
Normal file
14
src/types/poll_answer.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use crate::types::User;
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PollAnswer {
|
||||
/// Unique poll identifier
|
||||
pub poll_id: String,
|
||||
|
||||
/// The user, who changed the answer to the poll
|
||||
pub user: User,
|
||||
|
||||
/// 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
|
||||
pub option_ids: Vec<i32>,
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{CallbackQuery, ChosenInlineResult, InlineQuery, Message, Poll, PreCheckoutQuery, ShippingQuery, User, Sender, Chat};
|
||||
use crate::types::{CallbackQuery, ChosenInlineResult, InlineQuery, Message, Poll, PreCheckoutQuery, ShippingQuery, User, Sender, Chat, PollAnswer};
|
||||
|
||||
/// This [object] represents an incoming update.
|
||||
///
|
||||
|
@ -68,6 +68,9 @@ pub enum UpdateKind {
|
|||
/// New poll state. Bots receive only updates about stopped polls and
|
||||
/// polls, which are sent by the bot.
|
||||
Poll(Poll),
|
||||
|
||||
/// A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
|
||||
PollAnswer(PollAnswer)
|
||||
}
|
||||
|
||||
impl Update {
|
||||
|
@ -100,6 +103,9 @@ impl Update {
|
|||
UpdateKind::PreCheckoutQuery(query) => {
|
||||
Some(&query.from)
|
||||
}
|
||||
UpdateKind::PollAnswer(answer) => {
|
||||
Some(&answer.user)
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue