Update types (tba API 5.0)

See more: https://core.telegram.org/bots/api#november-4-2020
This commit is contained in:
Waffle 2021-03-14 17:10:06 +03:00
parent 68913d7d48
commit 20c67a18c5
33 changed files with 567 additions and 53 deletions

View file

@ -9,6 +9,7 @@ pub use callback_query::*;
pub use chat::*;
pub use chat_action::*;
pub use chat_id::*;
pub use chat_location::*;
pub use chat_member::*;
pub use chat_permissions::*;
pub use chat_photo::*;
@ -61,6 +62,7 @@ pub use mask_position::*;
pub use me::*;
pub use message::*;
pub use message_entity::*;
pub use message_id::*;
pub use order_info::*;
pub use parse_mode::*;
pub use passport_data::*;
@ -71,6 +73,7 @@ pub use poll::*;
pub use poll_answer::*;
pub use poll_type::*;
pub use pre_checkout_query::*;
pub use proximity_alert_triggered::*;
pub use reply_keyboard_markup::*;
pub use reply_keyboard_remove::*;
pub use reply_markup::*;
@ -102,6 +105,7 @@ mod callback_query;
mod chat;
mod chat_action;
mod chat_id;
mod chat_location;
mod chat_member;
mod chat_permissions;
mod chat_photo;
@ -130,6 +134,7 @@ mod mask_position;
mod me;
mod message;
mod message_entity;
mod message_id;
mod order_info;
mod parse_mode;
mod photo_size;
@ -137,6 +142,7 @@ mod poll;
mod poll_answer;
mod poll_type;
mod pre_checkout_query;
mod proximity_alert_triggered;
mod reply_keyboard_markup;
mod reply_keyboard_remove;
mod reply_markup;

View file

@ -27,6 +27,9 @@ pub struct Audio {
/// A title of the audio as defined by sender or by audio tags.
pub title: Option<String>,
/// Original filename as defined by sender
pub file_name: Option<String>,
/// A MIME type of the file as defined by a sender.
#[serde(with = "crate::types::non_telegram_types::mime::opt_deser")]
pub mime_type: Option<Mime>,
@ -75,6 +78,7 @@ mod tests {
height: 320,
file_size: Some(3452),
}),
file_name: None,
};
let actual = serde_json::from_str::<Audio>(&json).unwrap();
assert_eq!(actual, expected)

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{ChatPermissions, ChatPhoto, Message};
use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message};
/// This object represents a chat.
///
@ -22,6 +22,12 @@ pub struct Chat {
///
/// [`GetChat`]: crate::payloads::GetChat
pub photo: Option<ChatPhoto>,
/// The most recent pinned message (by sending date). Returned only in
/// [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub pinned_message: Option<Box<Message>>,
}
#[serde_with_macros::skip_serializing_none]
@ -58,16 +64,10 @@ pub struct ChatPublic {
///
/// [`GetChat`]: crate::payloads::GetChat
pub invite_link: Option<String>,
/// Pinned message, for groups, supergroups and channels. Returned only
/// in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub pinned_message: Option<Box<Message>>,
}
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChatPrivate {
/// A dummy field. Used to ensure that the `type` field is equal to
/// `private`.
@ -84,10 +84,15 @@ pub struct ChatPrivate {
/// A last name of the other party in a private chat.
pub last_name: Option<String>,
/// Bio of the other party in a private chat. Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub bio: Option<String>,
}
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "type")]
pub enum PublicChatKind {
@ -97,14 +102,20 @@ pub enum PublicChatKind {
}
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct PublicChatChannel {
/// A username, for private chats, supergroups and channels if available.
pub username: Option<String>,
/// Unique identifier for the linked chat, i.e. the discussion group
/// identifier for a channel and vice versa. Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub linked_chat_id: Option<i64>,
}
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct PublicChatGroup {
/// A default chat member permissions, for groups and supergroups. Returned
/// only from [`GetChat`].
@ -114,7 +125,7 @@ pub struct PublicChatGroup {
}
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PublicChatSupergroup {
/// A username, for private chats, supergroups and channels if
/// available.
@ -143,6 +154,18 @@ pub struct PublicChatSupergroup {
///
/// [`GetChat`]: crate::payloads::GetChat
pub slow_mode_delay: Option<i32>,
/// Unique identifier for the linked chat, i.e. the discussion group
/// identifier for a channel and vice versa. Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub linked_chat_id: Option<i64>,
/// The location to which the supergroup is connected. Returned only in
/// [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub location: ChatLocation,
}
struct PrivateChatKindVisitor;
@ -223,12 +246,13 @@ mod tests {
title: None,
kind: PublicChatKind::Channel(PublicChatChannel {
username: Some("channelname".into()),
linked_chat_id: None,
}),
description: None,
invite_link: None,
pinned_message: None,
}),
photo: None,
pinned_message: None,
};
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#).unwrap();
assert_eq!(expected, actual);
@ -244,8 +268,10 @@ mod tests {
username: Some("username".into()),
first_name: Some("Anon".into()),
last_name: None,
bio: None,
}),
photo: None,
pinned_message: None,
},
from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#)
.unwrap()

View file

@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
use crate::types::Location;
/// Represents a location to which a chat is connected.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChatLocation {
/// The location to which the supergroup is connected. Can't be a live
/// location.
pub location: Location,
/// Location address; 1-64 characters, as defined by the chat owner.
pub address: String,
}

View file

@ -32,6 +32,9 @@ pub enum ChatMemberKind {
pub struct Creator {
/// Custom title for this user.
pub custom_title: Option<String>,
/// True, if the user's presence in the chat is hidden
pub is_anonymous: bool,
}
/// Administrator of the group. This struct is part of the [`ChatMemberKind`]
@ -41,6 +44,9 @@ pub struct Administrator {
/// Custom title for this user.
pub custom_title: Option<String>,
/// True, if the user's presence in the chat is hidden
pub is_anonymous: bool,
/// `true`, if the bot is allowed to edit
/// administrator privileges of that user.
pub can_be_edited: bool,
@ -368,7 +374,8 @@ mod tests {
"can_invite_users":true,
"can_restrict_members":true,
"can_pin_messages":true,
"can_promote_members":true
"can_promote_members":true,
"is_anonymous":false,
}"#;
let expected = ChatMember {
user: User {
@ -390,6 +397,7 @@ mod tests {
can_restrict_members: true,
can_pin_messages: Some(true),
can_promote_members: true,
is_anonymous: false,
}),
};
let actual = serde_json::from_str::<ChatMember>(&json).unwrap();

View file

@ -13,4 +13,12 @@ pub enum DiceEmoji {
/// Values from 1-5.
#[serde(rename = "🏀")]
Basketball,
/// Values 1-5
#[serde(rename = "")]
Football,
/// Values 1-64
#[serde(rename = "🎰")]
SlotMachine,
}

View file

@ -66,6 +66,7 @@ mod tests {
audio_file_id: String::from("audio_file_id"),
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
});
@ -88,7 +89,9 @@ mod tests {
message_text: String::from("message_text"),
parse_mode: Some(ParseMode::MarkdownV2),
disable_web_page_preview: Some(true),
entities: None,
})),
caption_entities: None,
});
let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#;

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to an MP3 audio file. By default, this audio file will be
/// sent by the user.
@ -32,6 +32,10 @@ pub struct InlineQueryResultAudio {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Performer.
pub performer: Option<String>,
@ -60,6 +64,7 @@ impl InlineQueryResultAudio {
title: title.into(),
caption: None,
parse_mode: None,
caption_entities: None,
performer: None,
audio_duration: None,
reply_markup: None,
@ -104,6 +109,14 @@ impl InlineQueryResultAudio {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn performer<S>(mut self, val: S) -> Self
where
S: Into<String>,

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to an MP3 audio file stored on the Telegram servers.
///
@ -29,6 +29,10 @@ pub struct InlineQueryResultCachedAudio {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -50,6 +54,7 @@ impl InlineQueryResultCachedAudio {
caption: None,
parse_mode: None,
reply_markup: None,
caption_entities: None,
input_message_content: None,
}
}
@ -83,6 +88,14 @@ impl InlineQueryResultCachedAudio {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a file stored on the Telegram servers.
///
@ -35,6 +35,10 @@ pub struct InlineQueryResultCachedDocument {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -58,6 +62,7 @@ impl InlineQueryResultCachedDocument {
description: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -108,6 +113,14 @@ impl InlineQueryResultCachedDocument {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to an animated GIF file stored on the Telegram servers.
///
@ -33,6 +33,10 @@ pub struct InlineQueryResultCachedGif {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -54,6 +58,7 @@ impl InlineQueryResultCachedGif {
title: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -96,6 +101,14 @@ impl InlineQueryResultCachedGif {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a video animation (H.264/MPEG-4 AVC video without
/// sound) stored on the Telegram servers.
@ -33,6 +33,10 @@ pub struct InlineQueryResultCachedMpeg4Gif {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -55,6 +59,7 @@ impl InlineQueryResultCachedMpeg4Gif {
caption: None,
parse_mode: None,
reply_markup: None,
caption_entities: None,
input_message_content: None,
}
}
@ -88,6 +93,14 @@ impl InlineQueryResultCachedMpeg4Gif {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a photo stored on the Telegram servers.
///
@ -35,6 +35,10 @@ pub struct InlineQueryResultCachedPhoto {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -57,6 +61,7 @@ impl InlineQueryResultCachedPhoto {
description: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -107,6 +112,14 @@ impl InlineQueryResultCachedPhoto {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a video file stored on the Telegram servers.
///
@ -35,6 +35,10 @@ pub struct InlineQueryResultCachedVideo {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -58,6 +62,7 @@ impl InlineQueryResultCachedVideo {
description: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -108,6 +113,14 @@ impl InlineQueryResultCachedVideo {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a voice message stored on the Telegram servers.
///
@ -32,6 +32,10 @@ pub struct InlineQueryResultCachedVoice {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -54,6 +58,7 @@ impl InlineQueryResultCachedVoice {
title: title.into(),
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -96,6 +101,14 @@ impl InlineQueryResultCachedVoice {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,7 +1,7 @@
use mime::Mime;
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a file.
///
@ -31,6 +31,10 @@ pub struct InlineQueryResultDocument {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// A valid URL for the file.
pub document_url: String,
@ -88,6 +92,14 @@ impl InlineQueryResultDocument {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn document_url<S>(mut self, val: S) -> Self
where
S: Into<String>,

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to an animated GIF file.
///
@ -44,6 +44,10 @@ pub struct InlineQueryResultGif {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -72,6 +76,7 @@ impl InlineQueryResultGif {
parse_mode: None,
reply_markup: None,
input_message_content: None,
caption_entities: None,
}
}
@ -135,6 +140,14 @@ impl InlineQueryResultGif {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -24,10 +24,22 @@ pub struct InlineQueryResultLocation {
/// Location title.
pub title: String,
/// The radius of uncertainty for the location, measured in meters; 0-1500
pub horizontal_accuracy: Option<f64>,
/// Period in seconds for which the location can be updated, should be
/// between 60 and 86400.
pub live_period: Option<i32>,
/// For live locations, a direction in which the user is moving, in degrees.
/// Must be between 1 and 360 if specified.
pub heading: Option<u16>,
/// For live locations, a maximum distance for proximity alerts about
/// approaching another chat member, in meters. Must be between 1 and 100000
/// if specified.
pub proximity_alert_radius: Option<u32>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -40,10 +52,10 @@ pub struct InlineQueryResultLocation {
pub thumb_url: Option<String>,
/// Thumbnail width.
pub thumb_width: Option<i32>,
pub thumb_width: Option<u32>,
/// Thumbnail height.
pub thumb_height: Option<i32>,
pub thumb_height: Option<u32>,
}
impl InlineQueryResultLocation {
@ -63,6 +75,9 @@ impl InlineQueryResultLocation {
thumb_url: None,
thumb_width: None,
thumb_height: None,
horizontal_accuracy: None,
heading: None,
proximity_alert_radius: None,
}
}
@ -92,11 +107,26 @@ impl InlineQueryResultLocation {
self
}
pub fn horizontal_accuracy<S>(mut self, val: f64) -> Self {
self.horizontal_accuracy = Some(val);
self
}
pub fn live_period(mut self, val: i32) -> Self {
self.live_period = Some(val);
self
}
pub fn heading(mut self, val: u16) -> Self {
self.heading = Some(val);
self
}
pub fn proximity_alert_radius(mut self, val: u32) -> Self {
self.proximity_alert_radius = Some(val);
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self
@ -115,12 +145,12 @@ impl InlineQueryResultLocation {
self
}
pub fn thumb_width(mut self, val: i32) -> Self {
pub fn thumb_width(mut self, val: u32) -> Self {
self.thumb_width = Some(val);
self
}
pub fn thumb_height(mut self, val: i32) -> Self {
pub fn thumb_height(mut self, val: u32) -> Self {
self.thumb_height = Some(val);
self
}

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a video animation (H.264/MPEG-4 AVC video without
/// sound).
@ -45,6 +45,10 @@ pub struct InlineQueryResultMpeg4Gif {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -71,6 +75,7 @@ impl InlineQueryResultMpeg4Gif {
title: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -136,6 +141,14 @@ impl InlineQueryResultMpeg4Gif {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a photo.
///
@ -45,6 +45,10 @@ pub struct InlineQueryResultPhoto {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -71,6 +75,7 @@ impl InlineQueryResultPhoto {
description: None,
caption: None,
parse_mode: None,
caption_entities: None,
reply_markup: None,
input_message_content: None,
}
@ -139,6 +144,14 @@ impl InlineQueryResultPhoto {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -35,6 +35,14 @@ pub struct InlineQueryResultVenue {
/// `food/icecream`.)
pub foursquare_type: Option<String>,
/// Google Places identifier of the venue.
pub google_place_id: Option<String>,
/// Google Places type of the venue. (See [supported types].)
///
/// [supported types]: https://developers.google.com/places/web-service/supported_types
pub google_place_type: Option<String>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
@ -68,6 +76,8 @@ impl InlineQueryResultVenue {
address: address.into(),
foursquare_id: None,
foursquare_type: None,
google_place_id: None,
google_place_type: None,
reply_markup: None,
input_message_content: None,
thumb_url: None,
@ -126,6 +136,22 @@ impl InlineQueryResultVenue {
self
}
pub fn google_place_id<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.google_place_id = Some(val.into());
self
}
pub fn google_place_type<S>(mut self, val: S) -> Self
where
S: Into<String>,
{
self.google_place_type = Some(val.into());
self
}
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
self.reply_markup = Some(val);
self

View file

@ -1,7 +1,7 @@
use mime::Mime;
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a page containing an embedded video player or a video
/// file.
@ -41,6 +41,10 @@ pub struct InlineQueryResultVideo {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Video width.
pub video_width: Option<i32>,
@ -89,6 +93,7 @@ impl InlineQueryResultVideo {
title: title.into(),
caption: None,
parse_mode: None,
caption_entities: None,
video_width: None,
video_height: None,
video_duration: None,
@ -148,6 +153,14 @@ impl InlineQueryResultVideo {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn video_width(mut self, val: i32) -> Self {
self.video_width = Some(val);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
/// Represents a link to a voice recording in an .ogg container encoded with
/// OPUS.
@ -33,6 +33,10 @@ pub struct InlineQueryResultVoice {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Recording duration in seconds.
pub voice_duration: Option<i32>,
@ -58,6 +62,7 @@ impl InlineQueryResultVoice {
title: title.into(),
caption: None,
parse_mode: None,
caption_entities: None,
voice_duration: None,
reply_markup: None,
input_message_content: None,
@ -101,6 +106,14 @@ impl InlineQueryResultVoice {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub fn voice_duration(mut self, value: i32) -> Self {
self.voice_duration = Some(value);
self

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::{InputFile, ParseMode};
use crate::types::{InputFile, MessageEntity, ParseMode};
/// This object represents the content of a media message to be sent.
///
@ -35,6 +35,10 @@ pub struct InputMediaPhoto {
/// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
}
impl InputMediaPhoto {
@ -43,6 +47,7 @@ impl InputMediaPhoto {
media,
caption: None,
parse_mode: None,
caption_entities: None,
}
}
@ -92,6 +97,10 @@ pub struct InputMediaVideo {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Video width.
pub width: Option<u16>,
@ -112,6 +121,7 @@ impl InputMediaVideo {
thumb: None,
caption: None,
parse_mode: None,
caption_entities: None,
width: None,
height: None,
duration: None,
@ -142,6 +152,14 @@ impl InputMediaVideo {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub const fn width(mut self, val: u16) -> Self {
self.width = Some(val);
self
@ -191,6 +209,10 @@ pub struct InputMediaAnimation {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Animation width.
pub width: Option<u16>,
@ -211,6 +233,7 @@ impl InputMediaAnimation {
width: None,
height: None,
duration: None,
caption_entities: None,
}
}
@ -237,6 +260,14 @@ impl InputMediaAnimation {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub const fn width(mut self, val: u16) -> Self {
self.width = Some(val);
self
@ -280,6 +311,10 @@ pub struct InputMediaAudio {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Duration of the audio in seconds.
pub duration: Option<u16>,
@ -300,6 +335,7 @@ impl InputMediaAudio {
performer: None,
title: None,
duration: None,
caption_entities: None,
}
}
@ -326,6 +362,14 @@ impl InputMediaAudio {
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
pub const fn duration(mut self, val: u16) -> Self {
self.duration = Some(val);
self
@ -374,6 +418,15 @@ pub struct InputMediaDocument {
/// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in the caption, which can be
/// specified instead of `parse_mode`.
pub caption_entities: Option<Vec<MessageEntity>>,
/// Disables automatic server-side content type detection for files uploaded
/// using multipart/form-data. Always true, if the document is sent as part
/// of an album.
pub disable_content_type_detection: Option<bool>,
}
impl InputMediaDocument {
@ -383,6 +436,8 @@ impl InputMediaDocument {
thumb: None,
caption: None,
parse_mode: None,
disable_content_type_detection: None,
caption_entities: None,
}
}
@ -408,6 +463,14 @@ impl InputMediaDocument {
self.parse_mode = Some(val);
self
}
pub fn caption_entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.caption_entities = Some(val.into_iter().collect());
self
}
}
impl From<InputMedia> for InputFile {
@ -446,6 +509,7 @@ mod tests {
media: InputFile::FileId(String::from("123456")),
caption: None,
parse_mode: None,
caption_entities: None,
});
let actual_json = serde_json::to_string(&photo).unwrap();
@ -464,6 +528,7 @@ mod tests {
height: None,
duration: None,
supports_streaming: None,
caption_entities: None,
});
let actual_json = serde_json::to_string(&video).unwrap();
@ -481,6 +546,7 @@ mod tests {
width: None,
height: None,
duration: None,
caption_entities: None,
});
let actual_json = serde_json::to_string(&video).unwrap();
@ -498,6 +564,7 @@ mod tests {
duration: None,
performer: None,
title: None,
caption_entities: None,
});
let actual_json = serde_json::to_string(&video).unwrap();
@ -512,6 +579,8 @@ mod tests {
thumb: None,
caption: None,
parse_mode: None,
caption_entities: None,
disable_content_type_detection: None,
});
let actual_json = serde_json::to_string(&video).unwrap();

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use crate::types::ParseMode;
use crate::types::{MessageEntity, ParseMode};
/// This object represents the content of a message to be sent as a result of an
/// inline query.
@ -30,6 +30,10 @@ pub struct InputMessageContentText {
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
pub parse_mode: Option<ParseMode>,
/// List of special entities that appear in message text, which can be
/// specified instead of `parse_mode`.
pub entities: Option<Vec<MessageEntity>>,
/// Disables link previews for links in the sent message.
pub disable_web_page_preview: Option<bool>,
}
@ -43,6 +47,7 @@ impl InputMessageContentText {
message_text: message_text.into(),
parse_mode: None,
disable_web_page_preview: None,
entities: None,
}
}
@ -59,6 +64,14 @@ impl InputMessageContentText {
self
}
pub fn entities<C>(mut self, val: C) -> Self
where
C: IntoIterator<Item = MessageEntity>,
{
self.entities = Some(val.into_iter().collect());
self
}
pub fn disable_web_page_preview(mut self, val: bool) -> Self {
self.disable_web_page_preview = Some(val);
self
@ -76,9 +89,21 @@ pub struct InputMessageContentLocation {
/// Longitude of the location in degrees.
pub longitude: f64,
/// The radius of uncertainty for the location, measured in meters; 0-1500
pub horizontal_accuracy: Option<f64>,
/// Period in seconds for which the location can be updated, should be
/// between 60 and 86400.
pub live_period: Option<u32>,
/// For live locations, a direction in which the user is moving, in degrees.
/// Must be between 1 and 360 if specified.
pub heading: Option<u16>,
/// For live locations, a maximum distance for proximity alerts about
/// approaching another chat member, in meters. Must be between 1 and 100000
/// if specified.
pub proximity_alert_radius: Option<u32>,
}
impl InputMessageContentLocation {
@ -87,6 +112,9 @@ impl InputMessageContentLocation {
latitude,
longitude,
live_period: None,
horizontal_accuracy: None,
heading: None,
proximity_alert_radius: None,
}
}
@ -130,6 +158,14 @@ pub struct InputMessageContentVenue {
/// `arts_entertainment/default`, `arts_entertainment/aquarium`
/// or `food/icecream`.)
pub foursquare_type: Option<String>,
/// Google Places identifier of the venue.
pub google_place_id: Option<String>,
/// Google Places type of the venue. (See [supported types].)
///
/// [supported types]: https://developers.google.com/places/web-service/supported_types
pub google_place_type: Option<String>,
}
impl InputMessageContentVenue {
@ -145,6 +181,8 @@ impl InputMessageContentVenue {
address: address.into(),
foursquare_id: None,
foursquare_type: None,
google_place_id: None,
google_place_type: None,
}
}
@ -270,6 +308,7 @@ mod tests {
message_text: String::from("text"),
parse_mode: None,
disable_web_page_preview: None,
entities: None,
});
let actual_json = serde_json::to_string(&text_content).unwrap();
@ -283,6 +322,9 @@ mod tests {
latitude: 59.08,
longitude: 38.4326,
live_period: None,
horizontal_accuracy: None,
heading: None,
proximity_alert_radius: None,
});
let actual_json = serde_json::to_string(&location_content).unwrap();
@ -299,6 +341,8 @@ mod tests {
address: String::from("some address"),
foursquare_id: None,
foursquare_type: None,
google_place_id: None,
google_place_type: None,
});
let actual_json = serde_json::to_string(&venue_content).unwrap();

View file

@ -8,4 +8,19 @@ pub struct Location {
/// Latitude as defined by sender.
pub latitude: f64,
/// The radius of uncertainty for the location, measured in meters; 0-1500
pub horizontal_accuracy: Option<f64>,
/// Time relative to the message sending date, during which the location can
/// be updated, in seconds. For active live locations only.
pub live_period: Option<u32>,
/// The direction in which user is moving, in degrees; 1-360. For active
/// live locations only.
pub heading: Option<u16>,
/// Maximum distance for proximity alerts about approaching another chat
/// member, in meters. For sent live locations only.
pub proximity_alert_radius: Option<u32>,
}

View file

@ -5,8 +5,9 @@ use serde::{Deserialize, Serialize};
use crate::types::{
chat::{ChatKind, PublicChatKind},
Animation, Audio, Chat, ChatPublic, Contact, Dice, Document, Game, InlineKeyboardMarkup,
Invoice, Location, MessageEntity, PassportData, PhotoSize, Poll, PublicChatChannel,
PublicChatSupergroup, Sticker, SuccessfulPayment, True, User, Venue, Video, VideoNote, Voice,
Invoice, Location, MessageEntity, PassportData, PhotoSize, Poll, ProximityAlertTriggered,
PublicChatChannel, PublicChatSupergroup, Sticker, SuccessfulPayment, True, User, Venue, Video,
VideoNote, Voice,
};
/// This object represents a message.
@ -50,6 +51,7 @@ pub enum MessageKind {
ConnectedWebsite(MessageConnectedWebsite),
PassportData(MessagePassportData),
Dice(MessageDice),
ProximityAlertTriggered(MessageProximityAlertTriggered),
}
#[serde_with_macros::skip_serializing_none]
@ -58,6 +60,16 @@ pub struct MessageCommon {
/// Sender, empty for messages sent to channels.
pub from: Option<User>,
/// Sender of the message, sent on behalf of a chat. The channel itself for
/// channel messages. The supergroup itself for messages from anonymous
/// group administrators. The linked channel for messages automatically
/// forwarded to the discussion group
pub sender_chat: Option<Chat>,
/// Signature of the post author for messages in channels, or the custom
/// title of an anonymous group administrator.
pub author_signature: Option<String>,
#[serde(flatten)]
pub forward_kind: ForwardKind,
@ -426,27 +438,28 @@ pub struct MessageDice {
pub dice: Dice,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageProximityAlertTriggered {
/// Service message. A user in the chat triggered another user's proximity
/// alert while sharing Live Location.
pub proximity_alert_triggered: ProximityAlertTriggered,
}
mod getters {
use std::ops::Deref;
use crate::types::{
self,
message::{
ForwardKind::NonChannel,
MessageKind::{
ChannelChatCreated, Common, ConnectedWebsite, DeleteChatPhoto, GroupChatCreated,
Invoice, LeftChatMember, Migrate, NewChatMembers, NewChatPhoto, NewChatTitle,
PassportData, Pinned, SuccessfulPayment, SupergroupChatCreated,
},
},
message::{ForwardKind::NonChannel, MessageKind::*},
Chat, ForwardChannel, ForwardKind, ForwardNonChannel, ForwardOrigin, ForwardedFrom,
MediaAnimation, MediaAudio, MediaContact, MediaDocument, MediaGame, MediaKind,
MediaLocation, MediaPhoto, MediaPoll, MediaSticker, MediaText, MediaVenue, MediaVideo,
MediaVideoNote, MediaVoice, Message, MessageChannelChatCreated, MessageCommon,
MessageConnectedWebsite, MessageDeleteChatPhoto, MessageEntity, MessageGroupChatCreated,
MessageInvoice, MessageLeftChatMember, MessageMigrate, MessageNewChatMembers,
MessageNewChatPhoto, MessageNewChatTitle, MessagePassportData, MessagePinned,
MessageSuccessfulPayment, MessageSupergroupChatCreated, PhotoSize, True, User,
MessageConnectedWebsite, MessageDeleteChatPhoto, MessageDice, MessageEntity,
MessageGroupChatCreated, MessageInvoice, MessageLeftChatMember, MessageMigrate,
MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle, MessagePassportData,
MessagePinned, MessageProximityAlertTriggered, MessageSuccessfulPayment,
MessageSupergroupChatCreated, PhotoSize, True, User,
};
/// Getters for [Message] fields from [telegram docs].
@ -454,7 +467,6 @@ mod getters {
/// [Message]: crate::types::Message
/// [telegram docs]: https://core.telegram.org/bots/api#message
impl Message {
/// NOTE: this is getter for both `from` and `author_signature`
pub fn from(&self) -> Option<&User> {
match &self.kind {
Common(MessageCommon { from, .. }) => from.as_ref(),
@ -462,6 +474,22 @@ mod getters {
}
}
pub fn author_signature(&self) -> Option<&str> {
match &self.kind {
Common(MessageCommon {
author_signature, ..
}) => author_signature.as_deref(),
_ => None,
}
}
pub fn sender_chat(&self) -> Option<&Chat> {
match &self.kind {
Common(MessageCommon { sender_chat, .. }) => sender_chat.as_ref(),
_ => None,
}
}
pub fn chat_id(&self) -> i64 {
self.chat.id
}
@ -566,10 +594,6 @@ mod getters {
}
}
pub fn text_owned(&self) -> Option<String> {
self.text().map(ToOwned::to_owned)
}
pub fn entities(&self) -> Option<&[MessageEntity]> {
match &self.kind {
Common(MessageCommon {
@ -903,6 +927,22 @@ mod getters {
}
}
pub fn dice(&self) -> Option<&types::Dice> {
match &self.kind {
Dice(MessageDice { dice }) => Some(dice),
_ => None,
}
}
pub fn proximity_alert_triggered(&self) -> Option<&types::ProximityAlertTriggered> {
match &self.kind {
ProximityAlertTriggered(MessageProximityAlertTriggered {
proximity_alert_triggered,
}) => Some(proximity_alert_triggered),
_ => None,
}
}
pub fn reply_markup(&self) -> Option<&types::InlineKeyboardMarkup> {
match &self.kind {
Common(MessageCommon { reply_markup, .. }) => reply_markup.as_ref(),
@ -919,6 +959,7 @@ impl Message {
kind:
PublicChatKind::Channel(PublicChatChannel {
username: Some(username),
..
}),
..
})

5
src/types/message_id.rs Normal file
View file

@ -0,0 +1,5 @@
/// This object represents a unique message identifier.
pub struct MessageId {
/// Unique message identifier
pub message_id: i32,
}

View file

@ -0,0 +1,17 @@
use serde::{Deserialize, Serialize};
use crate::types::User;
/// This object represents the content of a service message, sent whenever a
/// user in the chat triggers a proximity alert set by another user.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ProximityAlertTriggered {
/// User that triggered the alert.
pub traveler: User,
/// User that set the alert.
pub watcher: User,
/// The distance between the users.
pub distance: u32,
}

View file

@ -169,8 +169,10 @@ mod test {
username: Some(String::from("WaffleLapkin")),
first_name: Some(String::from("Waffle")),
last_name: None,
bio: None,
}),
photo: None,
pinned_message: None,
},
kind: MessageKind::Common(MessageCommon {
from: Some(User {
@ -190,6 +192,8 @@ mod test {
entities: vec![],
}),
reply_markup: None,
sender_chat: None,
author_signature: None,
}),
}),
};

View file

@ -22,4 +22,12 @@ pub struct Venue {
/// `arts_entertainment/default`, `arts_entertainment/aquarium` or
/// `food/icecream`.)
pub foursquare_type: Option<String>,
/// Google Places identifier of the venue.
pub google_place_id: Option<String>,
/// Google Places type of the venue. (See [supported types].)
///
/// [supported types]: https://developers.google.com/places/web-service/supported_types
pub google_place_type: Option<String>,
}

View file

@ -29,6 +29,9 @@ pub struct Video {
/// Video thumbnail.
pub thumb: Option<PhotoSize>,
/// Original filename as defined by sender
pub file_name: Option<String>,
/// Mime type of a file as defined by sender.
#[serde(with = "crate::types::non_telegram_types::mime::opt_deser")]
pub mime_type: Option<Mime>,

View file

@ -16,6 +16,9 @@ pub struct WebhookInfo {
/// Number of updates awaiting delivery.
pub pending_update_count: u32,
/// Currently used webhook IP address.
pub ip_address: Option<String>,
/// Unix time for the most recent error that happened when trying to
/// deliver an update via webhook.
pub last_error_date: Option<u64>,