diff --git a/src/types/mod.rs b/src/types/mod.rs index 2c6410f8..053c3fc4 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -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; diff --git a/src/types/poll_answer.rs b/src/types/poll_answer.rs new file mode 100644 index 00000000..21ccb330 --- /dev/null +++ b/src/types/poll_answer.rs @@ -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, +} \ No newline at end of file diff --git a/src/types/update.rs b/src/types/update.rs index 31e6db9c..45b61afc 100644 --- a/src/types/update.rs +++ b/src/types/update.rs @@ -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 } }