Merge pull request #94 from teloxide/doc_types

Fix the docs of the API types
This commit is contained in:
Temirkhan Myrzamadi 2019-12-12 01:12:47 +06:00 committed by GitHub
commit d93330cd1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
82 changed files with 2037 additions and 417 deletions

View file

@ -1,24 +1,33 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// This object represents an animation file (GIF or H.264/MPEG-4 AVC video /// This object represents an animation file (GIF or H.264/MPEG-4 AVC video
/// without sound). /// without sound).
///
/// [The official docs](https://core.telegram.org/bots/api#animation).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Animation { pub struct Animation {
/// Identifier for this file /// An identifier for this file.
pub file_id: String, pub file_id: String,
/// Video width as defined by sender
/// A video width as defined by a sender.
pub width: u32, pub width: u32,
/// Video height as defined by sender
/// A video height as defined by a sender.
pub height: u32, pub height: u32,
/// Duration of the video in seconds as defined by sender
/// A duration of the video in seconds as defined by a sender.
pub duration: u32, pub duration: u32,
/// Optional. Animation thumbnail as defined by sender
/// An animation thumbnail as defined by a sender.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
/// Optional. Original animation filename as defined by sender
/// An original animation filename as defined by a sender.
pub file_name: Option<String>, pub file_name: Option<String>,
/// Optional. MIME type of the file as defined by sender
/// A MIME type of the file as defined by a sender.
pub mime_type: Option<String>, pub mime_type: Option<String>,
/// Optional. File size
/// A size of a file.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,13 +1,30 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone)] /// This object represents an audio file to be treated as music by the Telegram
/// clients.
///
/// [The official docs](https://core.telegram.org/bots/api#audio).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Audio { pub struct Audio {
/// An identifier for this file.
pub file_id: String, pub file_id: String,
/// A duration of the audio in seconds as defined by a sender.
pub duration: u32, pub duration: u32,
/// A performer of the audio as defined by a sender or by audio tags.
pub performer: Option<String>, pub performer: Option<String>,
/// A title of the audio as defined by sender or by audio tags.
pub title: Option<String>, pub title: Option<String>,
/// A MIME type of the file as defined by a sender.
pub mime_type: Option<String>, pub mime_type: Option<String>,
/// A size of a file.
pub file_size: Option<u32>, pub file_size: Option<u32>,
/// A thumbnail of the album cover to which the music file belongs.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
} }

View file

@ -1,2 +1,4 @@
/// A placeholder, currently holds no information. Use [BotFather](https://t.me/botfather) to set up your game. /// A placeholder, currently holds no information. Use [@BotFather](https://t.me/botfather) to set up your game.
///
/// [The official docs](https://core.telegram.org/bots/api#callbackgame).
pub struct CallbackGame; pub struct CallbackGame;

View file

@ -1,13 +1,46 @@
use crate::types::{Message, User}; use crate::types::{Message, User};
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This object represents an incoming callback query from a callback button in
/// an [inline keyboard]. If the button that originated the query was attached
/// to a message sent by the bot, the field message will be present. If the
/// button was attached to a message sent via the bot (in [inline mode]), the
/// field `inline_message_id` will be present. Exactly one of the fields data or
/// `game_short_name` will be present.
///
/// [The official docs](https://core.telegram.org/bots/api#callbackquery).
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
/// [inline mode]: https://core.telegram.org/bots/api#inline-mode
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct CallbackQuery { pub struct CallbackQuery {
/// An unique identifier for this query.
pub id: String, pub id: String,
/// A sender.
pub from: User, pub from: User,
pub chat_instance: String,
/// A message with the callback button that originated the query. Note that
/// message content and message date will not be available if the message
/// is too old.
pub message: Option<Message>, pub message: Option<Message>,
/// An identifier of the message sent via the bot in inline mode, that
/// originated the query.
pub inline_message_id: Option<String>, pub inline_message_id: Option<String>,
/// A global identifier, uniquely corresponding to the chat to which the
/// message with the callback button was sent. Useful for high scores in
/// [games].
///
/// [games]: https://core.telegram.org/bots/api#games
pub chat_instance: String,
/// A data associated with the callback button. Be aware that a bad client
/// can send arbitrary data in this field.
pub data: Option<String>, pub data: Option<String>,
/// A short name of a Game to be returned, serves as the unique identifier
/// for the game.
pub game_short_name: Option<String>, pub game_short_name: Option<String>,
} }

View file

@ -1,49 +1,116 @@
use crate::types::{ChatPermissions, ChatPhoto, Message}; use crate::types::{ChatPermissions, ChatPhoto, Message};
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This object represents a chat.
///
/// [The official docs](https://core.telegram.org/bots/api#chat).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Chat { pub struct Chat {
/// A unique identifier for this chat. This number may be greater than 32
/// bits and some programming languages may have difficulty/silent defects
/// in interpreting it. But it is smaller than 52 bits, so a signed 64 bit
/// integer or double-precision float type are safe for storing this
/// identifier.
pub id: i64, pub id: i64,
#[serde(flatten)] #[serde(flatten)]
pub kind: ChatKind, pub kind: ChatKind,
/// A chat photo. Returned only in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
pub photo: Option<ChatPhoto>, pub photo: Option<ChatPhoto>,
} }
#[derive(Debug, Deserialize, PartialEq, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ChatKind { pub enum ChatKind {
NonPrivate { NonPrivate {
/// A title, for supergroups, channels and group chats.
title: Option<String>, title: Option<String>,
#[serde(flatten)] #[serde(flatten)]
kind: NonPrivateChatKind, kind: NonPrivateChatKind,
/// A description, for groups, supergroups and channel chats. Returned
/// only in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
description: Option<String>, description: Option<String>,
/// A chat invite link, for groups, supergroups and channel chats. Each
/// administrator in a chat generates their own invite links, so the
/// bot must first generate the link using
/// [`Bot::export_chat_invite_link`]. Returned only in
/// [`Bot::get_chat`].
///
/// [`Bot::export_chat_invite_link`]:
/// crate::Bot::export_chat_invite_link
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
invite_link: Option<String>, invite_link: Option<String>,
/// Pinned message, for groups, supergroups and channels. Returned only
/// in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
pinned_message: Option<Box<Message>>, pinned_message: Option<Box<Message>>,
}, },
Private { Private {
/// Dummy field. Used to ensure that "type" field is equal to "private" /// A dummy field. Used to ensure that the `type` field is equal to
/// `private`.
#[serde(rename = "type")] #[serde(rename = "type")]
#[serde(deserialize_with = "assert_private_field")] #[serde(deserialize_with = "assert_private_field")]
type_: (), type_: (),
/// A username, for private chats, supergroups and channels if
/// available.
username: Option<String>, username: Option<String>,
/// A first name of the other party in a private chat.
first_name: Option<String>, first_name: Option<String>,
/// A last name of the other party in a private chat.
last_name: Option<String>, last_name: Option<String>,
}, },
} }
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum NonPrivateChatKind { pub enum NonPrivateChatKind {
Channel { Channel {
/// A username, for private chats, supergroups and channels if
/// available.
username: Option<String>, username: Option<String>,
}, },
Group { Group {
/// A default chat member permissions, for groups and supergroups.
/// Returned only in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
permissions: Option<ChatPermissions>, permissions: Option<ChatPermissions>,
}, },
Supergroup { Supergroup {
/// A username, for private chats, supergroups and channels if
/// available.
username: Option<String>, username: Option<String>,
/// For supergroups, name of group sticker set. Returned only in
/// [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
sticker_set_name: Option<String>, sticker_set_name: Option<String>,
/// `true`, if the bot can change the group sticker set. Returned only
/// in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
can_set_sticker_set: Option<bool>, can_set_sticker_set: Option<bool>,
/// A default chat member permissions, for groups and supergroups.
/// Returned only in [`Bot::get_chat`].
///
/// [`Bot::get_chat`]: crate::Bot::get_chat
permissions: Option<ChatPermissions>, permissions: Option<ChatPermissions>,
}, },
} }

View file

@ -1,4 +1,4 @@
#[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ChatAction { pub enum ChatAction {
Typing, Typing,

View file

@ -1,14 +1,15 @@
/// Unique identifier for the target chat or username of the target channel (in /// A unique identifier for the target chat or username of the target channel
/// the format `@channelusername`) /// (in the format `@channelusername`).
#[derive( #[derive(
Debug, Display, PartialEq, Eq, Hash, Clone, Deserialize, Serialize, From, Debug, Display, PartialEq, Eq, Hash, Clone, Deserialize, Serialize, From,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum ChatId { pub enum ChatId {
/// chat identifier /// A chat identifier.
#[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]
Id(i64), Id(i64),
/// _channel_ username (in the format @channelusername)
/// A channel username (in the format @channelusername).
#[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]
ChannelUsername(String), ChannelUsername(String),
} }

View file

@ -1,61 +1,76 @@
use crate::types::User; use crate::types::User;
/// This object contains information about one member of the chat. /// This object contains information about one member of the chat.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] ///
/// [The official docs](https://core.telegram.org/bots/api#chatmember).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ChatMember { pub struct ChatMember {
/// Information about the user. /// Information about the user.
pub user: User, pub user: User,
/// The member's status in the chat. /// The member's status in the chat.
pub status: ChatMemberStatus, pub status: ChatMemberStatus,
///Optional. Restricted and kicked only. Date when restrictions will be
/// lifted for this user, unix time /// Restricted and kicked only. Date when restrictions will be lifted for
/// this user, unix time.
pub until_date: Option<i32>, pub until_date: Option<i32>,
///Optional. Administrators only. True, if the bot is allowed to edit
/// administrator privileges of that user /// Administrators only. `true`, if the bot is allowed to edit
/// administrator privileges of that user.
pub can_be_edited: Option<bool>, pub can_be_edited: Option<bool>,
///Optional. Administrators only. True, if the administrator can change
/// the chat title, photo and other settings /// Administrators only. `true`, if the administrator can change the chat
/// title, photo and other settings.
pub can_change_info: Option<bool>, pub can_change_info: Option<bool>,
///Optional. Administrators only. True, if the administrator can post in
/// the channel, channels only /// Administrators only. `true`, if the administrator can post in the
/// channel, channels only.
pub can_post_messages: Option<bool>, pub can_post_messages: Option<bool>,
///Optional. Administrators only. True, if the administrator can edit
/// messages of other users and can pin messages, channels only /// Administrators only. `true`, if the administrator can edit messages of
/// other users and can pin messages, channels only.
pub can_edit_messages: Option<bool>, pub can_edit_messages: Option<bool>,
///Optional. Administrators only. True, if the administrator can delete
/// messages of other users /// Administrators only. `true`, if the administrator can delete messages
/// of other users.
pub can_delete_messages: Option<bool>, pub can_delete_messages: Option<bool>,
///Optional. Administrators only. True, if the administrator can invite
/// new users to the chat /// Administrators only. `true`, if the administrator can invite new users
/// to the chat.
pub can_invite_users: Option<bool>, pub can_invite_users: Option<bool>,
///Optional. Administrators only. True, if the administrator can restrict,
/// ban or unban chat members /// Administrators only. `true`, if the administrator can restrict,
/// ban or unban chat members.
pub can_restrict_members: Option<bool>, pub can_restrict_members: Option<bool>,
///Optional. Administrators only. True, if the administrator can pin
/// messages, supergroups only /// Administrators only. `true`, if the administrator can pin messages,
/// supergroups only.
pub can_pin_messages: Option<bool>, pub can_pin_messages: Option<bool>,
///Optional. Administrators only. True, if the administrator can add new
/// Administrators only. `true`, if the administrator can add new
/// administrators with a subset of his own privileges or demote /// administrators with a subset of his own privileges or demote
/// administrators that he has promoted, directly or indirectly (promoted /// administrators that he has promoted, directly or indirectly (promoted
/// by administrators that were appointed by the user) /// by administrators that were appointed by the user).
pub can_promote_members: Option<bool>, pub can_promote_members: Option<bool>,
///Optional. Restricted only. True, if the user can send text messages,
/// contacts, locations and venues /// Restricted only. `true`, if the user can send text messages,
/// contacts, locations and venues.
pub can_send_messages: Option<bool>, pub can_send_messages: Option<bool>,
///Optional. Restricted only. True, if the user can send audios,
/// documents, photos, videos, video notes and voice notes, implies /// Restricted only. `true`, if the user is allowed to send audios,
/// can_send_messages /// documents, photos, videos, video notes and voice notes.
pub can_send_media_messages: Option<bool>, pub can_send_media_messages: Option<bool>,
///Optional. Restricted only. True, if the user can send animations,
/// games, stickers and use inline bots, implies /// Restricted only. `true`, if the user is allowed to send animations,
/// can_send_media_messages /// games, stickers and use inline bots.
pub can_send_other_messages: Option<bool>, pub can_send_other_messages: Option<bool>,
///Optional. Restricted only. True, if user may add web page previews to
/// his messages, implies can_send_media_messages /// Restricted only. `true`, if the user is allowed to add web page
/// previews to their messages.
pub can_add_web_page_previews: Option<bool>, pub can_add_web_page_previews: Option<bool>,
} }
#[derive(Deserialize, Debug, Hash, PartialEq, Eq, Clone)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ChatMemberStatus { pub enum ChatMemberStatus {
Creator, Creator,

View file

@ -1,19 +1,46 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Serialize, Clone)] /// Describes actions that a non-administrator user is allowed to take in a
/// chat.
///
/// [The official docs](https://core.telegram.org/bots/api#chatpermissions).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ChatPermissions { pub struct ChatPermissions {
/// `true`, if the user is allowed to send text messages, contacts,
/// locations and venues.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_send_messages: Option<bool>, pub can_send_messages: Option<bool>,
/// `true`, if the user is allowed to send audios, documents,
/// photos, videos, video notes and voice notes, implies
/// `can_send_messages`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_send_media_messages: Option<bool>, pub can_send_media_messages: Option<bool>,
/// `true`, if the user is allowed to send polls, implies
/// `can_send_messages`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_send_polls: Option<bool>, pub can_send_polls: Option<bool>,
/// `true`, if the user is allowed to send animations, games, stickers and
/// use inline bots, implies `can_send_media_messages`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_send_other_messages: Option<bool>, pub can_send_other_messages: Option<bool>,
/// `true`, if the user is allowed to add web page previews to
/// their messages, implies `can_send_media_messages`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_add_web_page_previews: Option<bool>, pub can_add_web_page_previews: Option<bool>,
/// `true`, if the user is allowed to change the chat title, photo and
/// other settings. Ignored in public supergroups.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_change_info: Option<bool>, pub can_change_info: Option<bool>,
/// `true`, if the user is allowed to invite new users to the chat.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_invite_users: Option<bool>, pub can_invite_users: Option<bool>,
/// `true`, if the user is allowed to pin messages. Ignored in public
/// supergroups.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>, pub can_pin_messages: Option<bool>,
} }

View file

@ -1,5 +1,15 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Serialize, Clone)] /// This object represents a chat photo.
///
/// [The official docs](https://core.telegram.org/bots/api#chatphoto).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ChatPhoto { pub struct ChatPhoto {
/// A file identifier of small (160x160) chat photo. This file_id can be
/// used only for photo download and only for as long as the photo is
/// not changed.
pub small_file_id: String, pub small_file_id: String,
/// A file identifier of big (640x640) chat photo. This file_id can be used
/// only for photo download and only for as long as the photo is not
/// changed.
pub big_file_id: String, pub big_file_id: String,
} }

View file

@ -1,20 +1,31 @@
use crate::types::{Location, User}; use crate::types::{Location, User};
#[derive(Debug, Deserialize, Clone, PartialEq)] /// Represents a [result] of an inline query that was chosen by the user and
/// Represents a result of an inline query that was chosen by the user and
/// sent to their chat partner. /// sent to their chat partner.
/// https://core.telegram.org/bots/api#inputtextmessagecontent ///
/// [The official docs](https://core.telegram.org/bots/api#choseninlineresult).
///
/// [result]: https://core.telegram.org/bots/api#inlinequeryresult
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ChosenInlineResult { pub struct ChosenInlineResult {
/// The unique identifier for the result that was chosen /// The unique identifier for the result that was chosen.
pub result_id: String, pub result_id: String,
/// The user that chose the result
/// The user that chose the result.
pub from: User, pub from: User,
/// Optional. Sender location, only for bots that require user location
/// A sender location, only for bots that require user location.
pub location: Option<Location>, pub location: Option<Location>,
/// Optional. Identifier of the sent inline message. Available only if
/// there is an inline keyboard attached to the message. Will be also /// An identifier of the sent inline message. Available only if
/// received in callback queries and can be used to edit the message. /// there is an [inline keyboard] attached to the message. Will be also
/// received in [callback queries] and can be used to [edit] the message.
///
/// [inline keyboard]: https://core.telegram.org/bots/api#inlinekeyboardmarkup
/// [callback queries]: https://core.telegram.org/bots/api#callbackquery
/// [edit]: https://core.telegram.org/bots/api#updating-messages
pub inline_message_id: Option<String>, pub inline_message_id: Option<String>,
/// The query that was used to obtain the result
/// The query that was used to obtain the result.
pub query: String, pub query: String,
} }

View file

@ -1,15 +1,22 @@
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
/// This object represents a phone contact. /// This object represents a phone contact.
///
/// [The official docs](https://core.telegram.org/bots/api#contact).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Contact { pub struct Contact {
/// Contact's phone number /// A contact's phone number.
pub phone_number: String, pub phone_number: String,
/// Contact's first name
/// A contact's first name.
pub first_name: String, pub first_name: String,
/// Optional. Contact's last name
/// A contact's last name.
pub last_name: Option<String>, pub last_name: Option<String>,
/// Optional. Contact's user identifier in Telegram
/// A contact's user identifier in Telegram.
pub user_id: Option<i32>, pub user_id: Option<i32>,
/// Optional. Additional data about the contact in the form of a
/// [vCard](https://en.wikipedia.org/wiki/VCard) /// Additional data about the contact in the form of a [vCard].
///
/// [vCard]: https://en.wikipedia.org/wiki/VCard
pub vcard: Option<String>, pub vcard: Option<String>,
} }

View file

@ -1,10 +1,27 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// This object represents a general file (as opposed to [photos], [voice
/// messages] and [audio files]).
///
/// [The official docs](https://core.telegram.org/bots/api#document).
///
/// [photos]: https://core.telegram.org/bots/api#photosize
/// [voice messages]: https://core.telegram.org/bots/api#voice
/// [audio files]: https://core.telegram.org/bots/api#audio
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Document { pub struct Document {
/// An identifier for this file.
pub file_id: String, pub file_id: String,
/// A document thumbnail as defined by a sender.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
/// An original filename as defined by a sender.
pub file_name: Option<String>, pub file_name: Option<String>,
/// A MIME type of the file as defined by a sender.
pub mime_type: Option<String>, pub mime_type: Option<String>,
/// A size of a file.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,8 +1,27 @@
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// Contains data required for decrypting and authenticating
/// [`EncryptedPassportElement`]. See the [Telegram Passport Documentation] for
/// a complete description of the data decryption and authentication processes.
///
/// [The official docs](https://core.telegram.org/bots/api#encryptedcredentials).
///
/// [`EncryptedPassportElement`]:
/// crate::types::EncryptedPassportElement
/// [Telegram Passport Documentation]: https://core.telegram.org/passport#receiving-information
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct EncryptedCredentials { pub struct EncryptedCredentials {
// TODO: check base64 type /// Base64-encoded encrypted JSON-serialized data with unique user's
pub data: String, /// payload, data hashes and secrets required for
/// [`EncryptedPassportElement`] decryption and authentication.
///
/// [`EncryptedPassportElement`]:
/// crate::types::EncryptedPassportElement
pub data: String, // TODO: check base64 type
/// Base64-encoded data hash for data authentication.
pub hash: String, pub hash: String,
/// A base64-encoded secret, encrypted with the bot's public RSA key,
/// required for data decryption.
pub secret: String, pub secret: String,
} }

View file

@ -1,8 +1,18 @@
use super::PassportFile; use super::PassportFile;
/// Contains information about documents or other Telegram Passport elements
/// shared with the bot by the user.
///
/// [The official docs](https://core.telegram.org/bots/api#encryptedpassportelement).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct EncryptedPassportElement { pub struct EncryptedPassportElement {
/// Base64-encoded element hash for using in
/// [`PassportElementErrorUnspecified`].
///
/// [`PassportElementErrorUnspecified`]:
/// crate::types::PassportElementErrorUnspecified
pub hash: String, pub hash: String,
#[serde(flatten)] #[serde(flatten)]
pub kind: EncryptedPassportElementKind, pub kind: EncryptedPassportElementKind,
} }
@ -11,61 +21,331 @@ pub struct EncryptedPassportElement {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum EncryptedPassportElementKind { pub enum EncryptedPassportElementKind {
PersonalDetails { PersonalDetails {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
}, },
Passport { Passport {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
/// Encrypted file with the front side of the document, provided by the
/// user. Available for `passport”, `driver_license”, `identity_card”
/// and `internal_passport”. The file can be decrypted and verified
/// using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
front_side: PassportFile, front_side: PassportFile,
/// Encrypted file with the selfie of the user holding a document,
/// provided by the user; available for `passport”, `driver_license”,
/// `identity_card” and `internal_passport”. The file can be decrypted
/// and verified using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
selfie: PassportFile, selfie: PassportFile,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
DriverLicense { DriverLicense {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
/// Encrypted file with the front side of the document, provided by the
/// user. Available for `passport”, `driver_license”, `identity_card”
/// and `internal_passport”. The file can be decrypted and verified
/// using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
front_side: PassportFile, front_side: PassportFile,
/// Encrypted file with the reverse side of the document, provided by
/// the user. Available for `driver_license” and `identity_card”. The
/// file can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
reverse_side: PassportFile, reverse_side: PassportFile,
/// Encrypted file with the selfie of the user holding a document,
/// provided by the user; available for `passport”, `driver_license”,
/// `identity_card” and `internal_passport”. The file can be decrypted
/// and verified using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
selfie: PassportFile, selfie: PassportFile,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
IdentityCard { IdentityCard {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
/// Encrypted file with the front side of the document, provided by the
/// user. Available for `passport”, `driver_license”, `identity_card”
/// and `internal_passport”. The file can be decrypted and verified
/// using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
front_side: PassportFile, front_side: PassportFile,
/// Encrypted file with the reverse side of the document, provided by
/// the user. Available for `driver_license” and `identity_card”. The
/// file can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
reverse_side: PassportFile, reverse_side: PassportFile,
/// Encrypted file with the selfie of the user holding a document,
/// provided by the user; available for `passport”, `driver_license”,
/// `identity_card” and `internal_passport”. The file can be decrypted
/// and verified using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
selfie: PassportFile, selfie: PassportFile,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
InternalPassport { InternalPassport {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
/// Encrypted file with the front side of the document, provided by the
/// user. Available for `passport”, `driver_license”, `identity_card”
/// and `internal_passport”. The file can be decrypted and verified
/// using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
front_side: PassportFile, front_side: PassportFile,
/// Encrypted file with the selfie of the user holding a document,
/// provided by the user; available for `passport”, `driver_license”,
/// `identity_card” and `internal_passport”. The file can be decrypted
/// and verified using the accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
selfie: PassportFile, selfie: PassportFile,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
Address { Address {
/// Base64-encoded encrypted Telegram Passport element data provided
/// by the user, available for `personal_details”, `passport”,
/// `driver_license”, `identity_card”, `internal_passport” and
/// `address” types. Can be decrypted and verified using the
/// accompanying [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
data: String, data: String,
}, },
UtilityBill { UtilityBill {
/// Array of encrypted files with documents provided by the user,
/// available for `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
files: Vec<PassportFile>, files: Vec<PassportFile>,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
BankStatement { BankStatement {
/// Array of encrypted files with documents provided by the user,
/// available for `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
files: Vec<PassportFile>, files: Vec<PassportFile>,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
RentalAgreement { RentalAgreement {
/// Array of encrypted files with documents provided by the user,
/// available for `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
files: Vec<PassportFile>, files: Vec<PassportFile>,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
PassportRegistration { PassportRegistration {
/// Array of encrypted files with documents provided by the user,
/// available for `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
files: Vec<PassportFile>, files: Vec<PassportFile>,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
TemporaryRegistration { TemporaryRegistration {
/// Array of encrypted files with documents provided by the user,
/// available for `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
files: Vec<PassportFile>, files: Vec<PassportFile>,
/// Array of encrypted files with translated versions of documents
/// provided by the user. Available if requested for `passport”,
/// `driver_license”, `identity_card”, `internal_passport”,
/// `utility_bill”, `bank_statement”, `rental_agreement”,
/// `passport_registration” and `temporary_registration” types. Files
/// can be decrypted and verified using the accompanying
/// [`EncryptedCredentials`].
///
/// [`EncryptedCredentials`]:
/// crate::types::EncryptedCredentials
translation: Option<Vec<PassportFile>>, translation: Option<Vec<PassportFile>>,
}, },
PhoneNumber { PhoneNumber {
/// User's verified phone number, available only for `phone_number”
/// type.
phone_number: String, phone_number: String,
}, },
Email { Email {
/// User's verified email address, available only for `email” type.
email: String, email: String,
}, },
} }

View file

@ -1,6 +1,20 @@
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone)] /// This object represents a file ready to be downloaded. The file can be
/// downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`.
/// It is guaranteed that the link will be valid for at least 1 hour. When the
/// link expires, a new one can be requested by calling [`Bot::get_file`].
///
/// [The official docs](https://core.telegram.org/bots/api#file).
///
/// [`Bot::get_file`]: crate::Bot::get_file
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct File { pub struct File {
/// Identifier for this file.
pub file_id: String, pub file_id: String,
/// File size, if known.
pub file_size: u32, pub file_size: u32,
/// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>`
/// to get the file.
pub file_path: String, pub file_path: String,
} }

View file

@ -1,22 +1,26 @@
use crate::types::True; use crate::types::True;
/// Upon receiving a message with this object, Telegram clients will /// Upon receiving a message with this object, Telegram clients will display a
/// display a reply interface to the user (act as if the user has /// reply interface to the user (act as if the user has selected the bots
/// selected the bots message and tapped Reply'). This can be /// message and tapped Reply'). This can be extremely useful if you want to
/// extremely useful if you want to create user-friendly step-by-step /// create user-friendly step-by-step interfaces without having to sacrifice
/// interfaces without having to sacrifice privacy mod /// [privacy mode].
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] ///
/// [The official docs](https://core.telegram.org/bots/api#forcereply).
///
/// [privacy mode]: https://core.telegram.org/bots#privacy-mode
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ForceReply { pub struct ForceReply {
/// Shows reply interface to the user, as if they manually selected the /// Shows reply interface to the user, as if they manually selected the
/// bots message and tapped Reply' /// bots message and tapped Reply'.
pub force_reply: True, pub force_reply: True,
#[serde(skip_serializing_if = "Option::is_none")] /// Use this parameter if you want to force reply from specific users only.
/// Optional. Use this parameter if you want to force reply from specific /// Targets: 1) users that are `@mentioned` in the text of the
/// users only. Targets: 1) users that are @mentioned in the text of the
/// [`Message`] object; 2) if the bot's message is a reply /// [`Message`] object; 2) if the bot's message is a reply
/// (has reply_to_message_id), sender of the original message. /// (has reply_to_message_id), sender of the original message.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
#[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -2,25 +2,38 @@ use serde::Deserialize;
use crate::types::{Animation, MessageEntity, PhotoSize}; use crate::types::{Animation, MessageEntity, PhotoSize};
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] /// This object represents a game. Use [@Botfather] to create and edit games,
/// This object represents a game. Use BotFather to create and edit games, their /// their short names will act as unique identifiers.
/// short names will act as unique identifiers. ///
/// [@Botfather]: https://t.me/botfather
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Game { pub struct Game {
/// Title of the game /// Title of the game.
pub title: String, pub title: String,
/// Description of the game
/// Description of the game.
pub description: String, pub description: String,
/// Photo that will be displayed in the game message in chats. /// Photo that will be displayed in the game message in chats.
pub photo: Vec<PhotoSize>, pub photo: Vec<PhotoSize>,
/// Optional. Brief description of the game or high scores included in the
/// game message. Can be automatically edited to include current high /// Brief description of the game or high scores included in the game
/// scores for the game when the bot calls setGameScore, or manually /// message. Can be automatically edited to include current high scores
/// edited using editMessageText. 0-4096 characters. /// for the game when the bot calls [`Bot::set_game_score`], or manually
/// edited using [`Bot::edit_message_text`]. 0-4096 characters.
///
/// [`Bot::set_game_score`]: crate::Bot::set_game_score
///
/// [`Bot::edit_message_text`]: crate::Bot::edit_message_text
pub text: Option<String>, pub text: Option<String>,
/// Optional. Special entities that appear in text, such as usernames,
/// URLs, bot commands, etc. /// Special entities that appear in text, such as usernames, URLs, bot
/// commands, etc.
pub text_entities: Option<Vec<MessageEntity>>, pub text_entities: Option<Vec<MessageEntity>>,
/// Optional. Animation that will be displayed in the game message in
/// chats. Upload via BotFather /// Animation that will be displayed in the game message in chats. Upload
/// via [@Botfather].
///
/// [@Botfather]: https://t.me/botfather
pub animation: Option<Animation>, pub animation: Option<Animation>,
} }

View file

@ -2,13 +2,17 @@ use serde::Deserialize;
use crate::types::user::User; use crate::types::user::User;
#[derive(Debug, Deserialize, Clone)]
/// This object represents one row of the high scores table for a game. /// This object represents one row of the high scores table for a game.
///
/// [The official docs](https://core.telegram.org/bots/api#gamehighscore).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct GameHighScore { pub struct GameHighScore {
/// Position in high score table for the game /// Position in high score table for the game.
pub position: u32, pub position: u32,
/// User
/// User.
pub user: User, pub user: User,
/// Score
/// Score.
pub score: u32, pub score: u32,
} }

View file

@ -1,7 +1,9 @@
/// This object represents one button of an inline keyboard. /// This object represents one button of an inline keyboard.
#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone)] ///
/// [The official docs](https://core.telegram.org/bots/api#inlinekeyboardbutton).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct InlineKeyboardButton { pub struct InlineKeyboardButton {
/// Label text on the button /// Label text on the button.
pub text: String, pub text: String,
#[serde(flatten)] #[serde(flatten)]
@ -13,24 +15,32 @@ pub struct InlineKeyboardButton {
)] )]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum InlineKeyboardButtonKind { pub enum InlineKeyboardButtonKind {
/// HTTP or tg:// url to be opened when button is pressed /// HTTP or tg:// url to be opened when button is pressed.
Url(String), Url(String),
/// Data to be sent in a callback query to the bot when button is pressed,
/// 1-64 bytes /// Data to be sent in a [`CallbackQuery`] to the bot when button is
/// pressed, 1-64 bytes.
///
/// [`CallbackQuery`]: crate::types::CallbackQuery
CallbackData(String), CallbackData(String),
/// If set, pressing the button will prompt the user to select one of their /// If set, pressing the button will prompt the user to select one of their
/// chats, open that chat and insert the bots username and the specified /// chats, open that chat and insert the bots username and the specified
/// inline query in the input field. Can be empty, in which case just the /// inline query in the input field. Can be empty, in which case just the
/// bots username will be inserted. /// bots username will be inserted.
/// ///
/// Note: This offers an easy way for users to start using your bot in /// Note: This offers an easy way for users to start using your bot in
/// inline mode when they are currently in a private chat with it. /// [inline mode] when they are currently in a private chat with it.
/// Especially useful when combined with switch_pm… actions in this case /// Especially useful when combined with [switch_pm…] actions in this
/// the user will be automatically returned to the chat they switched from, /// case the user will be automatically returned to the chat they
/// skipping the chat selection screen. /// switched from, skipping the chat selection screen.
///
/// [inline mode]: https://core.telegram.org/bots/inline
/// [switch_pm…]: https://core.telegram.org/bots/api#answerinlinequery
SwitchInlineQuery(String), SwitchInlineQuery(String),
/// Optional. If set, pressing the button will insert the bots username
/// and the specified inline query in the current chat's input field. /// If set, pressing the button will insert the bots username and the
/// specified inline query in the current chat's input field.
/// Can be empty, in which case only the bots username will be /// Can be empty, in which case only the bots username will be
/// inserted. /// inserted.
/// ///
@ -41,9 +51,9 @@ pub enum InlineKeyboardButtonKind {
* TODO: add LoginUrl, pay */ * TODO: add LoginUrl, pay */
} }
/// Build buttons /// Build buttons.
/// ///
/// Example: /// # Examples
/// ``` /// ```
/// use teloxide::types::InlineKeyboardButton; /// use teloxide::types::InlineKeyboardButton;
/// ///

View file

@ -1,20 +1,26 @@
use crate::types::InlineKeyboardButton; use crate::types::InlineKeyboardButton;
/// This object represents an inline keyboard that appears right next to the /// This object represents an [inline keyboard] that appears right next to the
/// message it belongs to. /// message it belongs to.
/// ///
/// *Note*: This will only work in Telegram versions released after /// *Note*: This will only work in Telegram versions released after 9 April,
/// 9 April, 2016. Older clients will display unsupported message. /// 2016. Older clients will display unsupported message.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize, Default)] ///
/// [The official docs](https://core.telegram.org/bots/api#inlinekeyboardmarkup).
///
/// [inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Default)]
pub struct InlineKeyboardMarkup { pub struct InlineKeyboardMarkup {
/// Array of button rows, each represented by an Array of /// Array of button rows, each represented by an array of
/// [`InlineKeyboardButton`] objects /// [`InlineKeyboardButton`] objects.
///
/// [`InlineKeyboardButton`]: crate::types::InlineKeyboardButton
pub inline_keyboard: Vec<Vec<InlineKeyboardButton>>, pub inline_keyboard: Vec<Vec<InlineKeyboardButton>>,
} }
/// Build Markup /// Build `InlineKeyboardMarkup`.
/// ///
/// Example: /// # Examples
/// ``` /// ```
/// use teloxide::types::{InlineKeyboardButton, InlineKeyboardMarkup}; /// use teloxide::types::{InlineKeyboardButton, InlineKeyboardMarkup};
/// ///

View file

@ -1,15 +1,23 @@
use crate::types::{Location, User}; use crate::types::{Location, User};
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] /// This object represents an incoming inline query. When the user sends an
/// empty query, your bot could return some default or trending results.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequery).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQuery { pub struct InlineQuery {
/// Unique identifier for this query /// Unique identifier for this query.
pub id: String, pub id: String,
/// Sender
/// Sender.
pub from: User, pub from: User,
/// Optional. Sender location, only for bots that request user location
/// Sender location, only for bots that request user location.
pub location: Option<Location>, pub location: Option<Location>,
/// Text of the query (up to 512 characters)
/// Text of the query (up to 512 characters).
pub query: String, pub query: String,
/// Offset of the results to be returned, can be controlled by the bot
/// Offset of the results to be returned, can be controlled by the bot.
pub offset: String, pub offset: String,
} }

View file

@ -13,7 +13,9 @@ use crate::types::{
}; };
/// This object represents one result of an inline query. /// This object represents one result of an inline query.
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, From)] ///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresult).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, From)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum InlineQueryResult { pub enum InlineQueryResult {

View file

@ -1,33 +1,45 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent}; use crate::types::{InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to an article or web page.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultarticle).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultArticle { pub struct InlineQueryResultArticle {
/// Unique identifier for this result, 1-64 Bytes /// Unique identifier for this result, 1-64 Bytes.
pub id: String, pub id: String,
/// Title of the result
/// Title of the result.
pub title: String, pub title: String,
/// Content of the message to be sent
/// Content of the message to be sent.
pub input_message_content: InputMessageContent, pub input_message_content: InputMessageContent,
/// Optional. Inline keyboard attached to the message
/// Inline keyboard attached to the message.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Optional. URL of the result
/// URL of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>, pub url: Option<String>,
/// Optional. Pass True, if you don't want the URL to be shown in the
/// message /// Pass `true`, if you don't want the URL to be shown in the
/// message.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub hide_url: Option<bool>, pub hide_url: Option<bool>,
/// Optional. Short description of the result
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Optional. Url of the thumbnail for the result
/// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Optional. Thumbnail width
/// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Optional. Thumbnail height
/// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -1,20 +1,49 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to an MP3 audio file. By default, this audio file will be
/// sent by the user. Alternatively, you can use `input_message_content` to send
/// a message with the specified content instead of the audio.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultaudio).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultAudio { pub struct InlineQueryResultAudio {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL for the audio file.
pub audio_url: String, pub audio_url: String,
/// Title.
pub title: String, pub title: String,
/// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Performer.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub performer: Option<String>, pub performer: Option<String>,
/// Audio duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub audio_duration: Option<String>, pub audio_duration: Option<String>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the audio.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,15 +1,39 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to an MP3 audio file stored on the Telegram servers. By
/// default, this audio file will be sent by the user. Alternatively, you can
/// use `input_message_content` to send a message with the specified content
/// instead of the audio.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedaudio).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedAudio { pub struct InlineQueryResultCachedAudio {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier for the audio file.
pub audio_file_id: String, pub audio_file_id: String,
/// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the audio.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,18 +1,46 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a file stored on the Telegram servers. By default, this
/// file will be sent by the user with an optional caption. Alternatively, you
/// can use `input_message_content` to send a message with the specified content
/// instead of the file.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcacheddocument).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedDocument { pub struct InlineQueryResultCachedDocument {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// Title for the result.
pub title: String, pub title: String,
/// A valid file identifier for the file.
pub document_file_id: String, pub document_file_id: String,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the document to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the file.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,17 +1,44 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to an animated GIF file stored on the Telegram servers. By
/// default, this animated GIF file will be sent by the user with an optional
/// caption. Alternatively, you can use `input_message_content` to send a
/// message with specified content instead of the animation.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedgif).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedGif { pub struct InlineQueryResultCachedGif {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier for the GIF file.
pub gif_file_id: String, pub gif_file_id: String,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the GIF file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [`ParseMode::Markdown`] or [`ParseMode::HTML`], if you want
/// Telegram apps to show [bold, italic, fixed-width text or inline
/// URLs] in the media caption.
///
/// [`ParseMode::Markdown`]: crate::types::ParseMode::Markdown
/// [`ParseMode::HTML`]: crate::types::ParseMode::HTML
/// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the GIF animation.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,17 +1,44 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a video animation (H.264/MPEG-4 AVC video without
/// sound) stored on the Telegram servers. By default, this animated MPEG-4 file
/// will be sent by the user with an optional caption. Alternatively, you can
/// use `input_message_content` to send a message with the specified content
/// instead of the animation.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedMpeg4Gif { pub struct InlineQueryResultCachedMpeg4Gif {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier for the MP4 file.
pub mpeg4_file_id: String, pub mpeg4_file_id: String,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the MPEG-4 file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video animation.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,19 +1,47 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a photo stored on the Telegram servers. By default,
/// this photo will be sent by the user with an optional caption. Alternatively,
/// you can use `input_message_content` to send a message with the specified
/// content instead of the photo.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedphoto).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedPhoto { pub struct InlineQueryResultCachedPhoto {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier of the photo.
pub photo_file_id: String, pub photo_file_id: String,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the photo.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,11 +1,26 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent}; use crate::types::{InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a sticker stored on the Telegram servers. By default,
/// this sticker will be sent by the user. Alternatively, you can use
/// `input_message_content` to send a message with the specified content instead
/// of the sticker.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedsticker).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedSticker { pub struct InlineQueryResultCachedSticker {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier of the sticker.
pub sticker_file_id: String, pub sticker_file_id: String,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the sticker.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,18 +1,46 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a video file stored on the Telegram servers. By
/// default, this video file will be sent by the user with an optional caption.
/// Alternatively, you can use `input_message_content` to send a message with
/// the specified content instead of the video.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedVideo { pub struct InlineQueryResultCachedVideo {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier for the video file.
pub video_file_id: String, pub video_file_id: String,
/// Title for each result.
pub title: String, pub title: String,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,16 +1,42 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a voice message stored on the Telegram servers. By
/// default, this voice message will be sent by the user. Alternatively, you can
/// use `input_message_content` to send a message with the specified content
/// instead of the voice message.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultCachedVoice { pub struct InlineQueryResultCachedVoice {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid file identifier for the voice message.
pub voice_file_id: String, pub voice_file_id: String,
/// Voice message title.
pub title: String, pub title: String,
/// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the voice message.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,22 +1,51 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent}; use crate::types::{InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a contact with a phone number. By default, this contact will be
/// sent by the user. Alternatively, you can use `input_message_content` to send
/// a message with the specified content instead of the contact.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultcachedvideo).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultContact { pub struct InlineQueryResultContact {
/// Unique identifier for this result, 1-64 Bytes.
pub id: String, pub id: String,
/// Contact's phone number.
pub phone_number: String, pub phone_number: String,
/// Contact's first name.
pub first_name: String, pub first_name: String,
/// Contact's last name.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>, pub last_name: Option<String>,
/// Additional data about the contact in the form of a [vCard], 0-2048
/// bytes.
///
/// [VCard]: https://en.wikipedia.org/wiki/VCard
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub vcard: Option<String>, pub vcard: Option<String>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the contact.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -1,25 +1,60 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a file. By default, this file will be sent by the user
/// with an optional caption. Alternatively, you can use `input_message_content`
/// to send a message with the specified content instead of the file. Currently,
/// only **.PDF** and **.ZIP** files can be sent using this method.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultdocument).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultDocument { pub struct InlineQueryResultDocument {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// Title for the result.
pub title: String, pub title: String,
/// Caption of the document to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// A valid URL for the file.
pub document_url: String, pub document_url: String,
/// Mime type of the content of the file, either `application/pdf” or
/// `application/zip”.
pub mime_type: String, pub mime_type: String,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Inline keyboard attached to the message.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the file.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// URL of the thumbnail (jpeg only) for the file.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -1,9 +1,21 @@
use crate::types::InlineKeyboardMarkup; use crate::types::InlineKeyboardMarkup;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] /// Represents a [game].
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgame).
///
/// [game]: https://core.telegram.org/bots/api#games
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct InlineQueryResultGame { pub struct InlineQueryResultGame {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// Short name of the game.
pub game_short_name: String, pub game_short_name: String,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
} }

View file

@ -1,24 +1,58 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to an animated GIF file. By default, this animated GIF
/// file will be sent by the user with optional caption. Alternatively, you can
/// use `input_message_content` to send a message with the specified content
/// instead of the animation.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultgif).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultGif { pub struct InlineQueryResultGif {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL for the GIF file. File size must not exceed 1MB.
pub gif_url: String, pub gif_url: String,
/// Width of the GIF.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub gif_width: Option<i32>, pub gif_width: Option<i32>,
/// Height of the GIFv.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub gif_height: Option<i32>, pub gif_height: Option<i32>,
/// Duration of the GIF.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub gif_duration: Option<i32>, pub gif_duration: Option<i32>,
/// URL of the static thumbnail for the result (jpeg or gif).
pub thumb_url: String, pub thumb_url: String,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the GIF file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the GIF animation.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,21 +1,48 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent}; use crate::types::{InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a location on a map. By default, the location will be sent by the
/// user. Alternatively, you can use `input_message_content` to send a message
/// with the specified content instead of the location.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultlocation).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultLocation { pub struct InlineQueryResultLocation {
/// Unique identifier for this result, 1-64 Bytes.
pub id: String, pub id: String,
/// Location latitude in degrees.
pub latitude: f64, pub latitude: f64,
/// Location longitude in degrees.
pub longitude: f64, pub longitude: f64,
/// Location title.
pub title: String, pub title: String,
/// Period in seconds for which the location can be updated, should be
/// between 60 and 86400.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub live_period: Option<i32>, pub live_period: Option<i32>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the location.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -1,24 +1,58 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a video animation (H.264/MPEG-4 AVC video without
/// sound). By default, this animated MPEG-4 file will be sent by the user with
/// optional caption. Alternatively, you can use `input_message_content` to send
/// a message with the specified content instead of the animation.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultMpeg4Gif { pub struct InlineQueryResultMpeg4Gif {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL for the MP4 file. File size must not exceed 1MB.
pub mpeg4_url: String, pub mpeg4_url: String,
/// Video width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_width: Option<i32>, pub mpeg4_width: Option<i32>,
/// Video height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_height: Option<i32>, pub mpeg4_height: Option<i32>,
/// Video duration.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mpeg4_duration: Option<i32>, pub mpeg4_duration: Option<i32>,
/// URL of the static thumbnail (jpeg or gif) for the result.
pub thumb_url: String, pub thumb_url: String,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Caption of the MPEG-4 file to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video animation.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,27 +1,59 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
/// Represents a link to a photo. By default, this photo will be sent by the /// Represents a link to a photo. By default, this photo will be sent by the
/// user with optional caption. Alternatively, you can use input_message_content /// user with optional caption. Alternatively, you can use
/// to send a message with the specified content instead of the photo. /// `input_message_content` to send a message with the specified content instead
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// of the photo.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultphoto).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultPhoto { pub struct InlineQueryResultPhoto {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL of the photo. Photo must be in **jpeg** format. Photo size
/// must not exceed 5MB.
pub photo_url: String, pub photo_url: String,
/// URL of the thumbnail for the photo.
pub thumb_url: String, pub thumb_url: String,
/// Width of the photo.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub photo_width: Option<i32>, pub photo_width: Option<i32>,
/// Height of the photo.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub photo_height: Option<i32>, pub photo_height: Option<i32>,
/// Title for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>, pub title: Option<String>,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the photo.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,24 +1,56 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent}; use crate::types::{InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a venue. By default, the venue will be sent by the user.
/// Alternatively, you can use `input_message_content` to send a message with
/// the specified content instead of the venue.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvenue).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVenue { pub struct InlineQueryResultVenue {
/// Unique identifier for this result, 1-64 Bytes.
pub id: String, pub id: String,
/// Latitude of the venue location in degrees.
pub latitude: f64, pub latitude: f64,
/// Longitude of the venue location in degrees.
pub longitude: f64, pub longitude: f64,
/// Title of the venue.
pub title: String, pub title: String,
/// Address of the venue.
pub address: String, pub address: String,
/// Foursquare identifier of the venue if known.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_id: Option<String>, pub foursquare_id: Option<String>,
/// Foursquare type of the venue, if known. (For example,
/// `arts_entertainment/default`, `arts_entertainment/aquarium` or
/// `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_type: Option<String>, pub foursquare_type: Option<String>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the venue.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
/// Url of the thumbnail for the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_url: Option<String>, pub thumb_url: Option<String>,
/// Thumbnail width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_width: Option<i32>, pub thumb_width: Option<i32>,
/// Thumbnail height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub thumb_height: Option<i32>, pub thumb_height: Option<i32>,
} }

View file

@ -1,26 +1,69 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a page containing an embedded video player or a video
/// file. By default, this video file will be sent by the user with an optional
/// caption. Alternatively, you can use `input_messaage_content` to send a
/// message with the specified content instead of the video.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvideo).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVideo { pub struct InlineQueryResultVideo {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL for the embedded video player or video file.
pub video_url: String, pub video_url: String,
/// Mime type of the content of video url, `text/html` or `video/mp4`.
pub mime_type: String, pub mime_type: String,
/// URL of the thumbnail (jpeg only) for the video.
pub thumb_url: String, pub thumb_url: String,
/// Title for the result.
pub title: String, pub title: String,
/// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Video width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub video_width: Option<i32>, pub video_width: Option<i32>,
/// Video height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub video_height: Option<i32>, pub video_height: Option<i32>,
/// Video duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub video_duration: Option<i32>, pub video_duration: Option<i32>,
/// Short description of the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>, pub description: Option<String>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the video. This field is
/// **required** if [`InlineQueryResultVideo`] is used to send an HTML-page
/// as a result (e.g., a YouTube video).
///
/// [`InlineQueryResultVideo`]:
/// crate::types::InlineQueryResultVideo
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,18 +1,46 @@
use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode};
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// Represents a link to a voice recording in an .ogg container encoded with
/// OPUS. By default, this voice recording will be sent by the user.
/// Alternatively, you can use `input_message_content` to send a message with
/// the specified content instead of the the voice message.
///
/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultvoice).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct InlineQueryResultVoice { pub struct InlineQueryResultVoice {
/// Unique identifier for this result, 1-64 bytes.
pub id: String, pub id: String,
/// A valid URL for the voice recording.
pub voice_url: String, pub voice_url: String,
/// Recording title.
pub title: String, pub title: String,
/// Caption, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub caption: Option<String>, pub caption: Option<String>,
/// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// italic, fixed-width text or inline URLs] in the media caption.
///
/// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [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
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub parse_mode: Option<ParseMode>, pub parse_mode: Option<ParseMode>,
/// Recording duration in seconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub voice_duration: Option<i32>, pub voice_duration: Option<i32>,
/// [Inline keyboard] attached to the message.
///
/// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_markup: Option<InlineKeyboardMarkup>,
/// Content of the message to be sent instead of the voice recording.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub input_message_content: Option<InputMessageContent>, pub input_message_content: Option<InputMessageContent>,
} }

View file

@ -1,6 +1,9 @@
use std::path::PathBuf; use std::path::PathBuf;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)] /// This object represents the contents of a file to be uploaded.
///
/// [The official docs](https://core.telegram.org/bots/api#inputfile).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq)]
pub enum InputFile { pub enum InputFile {
File(PathBuf), File(PathBuf),
Url(String), Url(String),

View file

@ -1,165 +1,187 @@
use crate::types::{InputFile, ParseMode}; use crate::types::{InputFile, ParseMode};
// TODO: should variants use new-type? // TODO: should variants use new-type?
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
/// This object represents the content of a media message to be sent. /// This object represents the content of a media message to be sent.
/// [More](https://core.telegram.org/bots/api#inputmedia) ///
/// [The official docs](https://core.telegram.org/bots/api#inputmedia).
pub enum InputMedia { pub enum InputMedia {
/// Represents a photo to be sent. /// Represents a photo to be sent.
///
/// [The official docs](https://core.telegram.org/bots/api#inputmediaphoto).
Photo { Photo {
/// File to send. /// File to send.
media: InputFile, media: InputFile,
/// Caption of the photo to be sent, 0-1024 characters
/// Caption of the photo to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// or inline URLs] in the media caption. /// italic, fixed-width text or inline URLs] in the media caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
}, },
/// Represents a video to be sent.
///
/// [The official docs](https://core.telegram.org/bots/api#inputmediavideo).
Video { Video {
/// File to send.File to send. // File to send.
media: InputFile, media: InputFile,
#[serde(skip_serializing_if = "Option::is_none")]
/// Thumbnail of the file sent; can be ignored if thumbnail generation /// Thumbnail of the file sent; can be ignored if thumbnail generation
/// for the file is supported server-side. /// for the file is supported server-side. The thumbnail should be in
/// The thumbnail should be in JPEG format and less than 200 kB in /// JPEG format and less than 200 kB in size. A thumbnails width and
/// size. A thumbnails width and height should not exceed 320. /// height should not exceed 320. Ignored if the file is not uploaded
/// Ignored if the file is not uploaded using [InputFile::File]. /// using multipart/form-data.
/// #[serde(skip_serializing_if = "Option::is_none")]
/// [InputFile::File]: crate::types::InputFile::File
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the video to be sent, 0-1024 characters. /// Caption of the video to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// or inline URLs] in the media caption. /// italic, fixed-width text or inline URLs] in the media caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Video width
/// Video width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
width: Option<u16>, width: Option<u16>,
/// Video height
/// Video height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
height: Option<u16>, height: Option<u16>,
/// Video duration
/// Video duration.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
/// Pass `true`, if the uploaded video is suitable for streaming
/// Pass `true`, if the uploaded video is suitable for streaming.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
supports_streaming: Option<bool>, supports_streaming: Option<bool>,
}, },
/// Represents an animation file (GIF or H.264/MPEG-4 AVC video without /// Represents an animation file (GIF or H.264/MPEG-4 AVC video without
/// sound) to be sent. /// sound) to be sent.
///
/// [The official docs](https://core.telegram.org/bots/api#inputmediaanimation).
Animation { Animation {
/// File to send. /// File to send.
media: InputFile, media: InputFile,
/// Thumbnail of the file sent; can be ignored if thumbnail generation /// Thumbnail of the file sent; can be ignored if thumbnail generation
/// for the file is supported server-side. /// for the file is supported server-side. The thumbnail should be in
/// The thumbnail should be in JPEG format and less than 200 kB in /// JPEG format and less than 200 kB in size. A thumbnails width and
/// size. A thumbnails width and height should not exceed 320. /// height should not exceed 320. Ignored if the file is not uploaded
/// Ignored if the file is not uploaded using [InputFile::File]. /// using multipart/form-data.
///
/// [InputFile::File]: crate::types::InputFile::File
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the animation to be sent, 0-1024 characters
/// Caption of the animation to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// or inline URLs] in the media caption. /// italic, fixed-width text or inline URLs] in the media caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Animation width
/// Animation width.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
width: Option<u16>, width: Option<u16>,
/// Animation height
/// Animation height.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
height: Option<u16>, height: Option<u16>,
/// Animation duration
/// Animation duration.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
}, },
/// Represents an audio file to be treated as music to be sent. /// Represents an audio file to be treated as music to be sent.
///
/// [The official docs](https://core.telegram.org/bots/api#inputmediaaudio).
Audio { Audio {
/// File to send, /// File to send.
media: InputFile, media: InputFile,
/// Thumbnail of the file sent; can be ignored if thumbnail generation /// Thumbnail of the file sent; can be ignored if thumbnail generation
/// for the file is supported server-side. /// for the file is supported server-side. The thumbnail should be in
/// The thumbnail should be in JPEG format and less than 200 kB in /// JPEG format and less than 200 kB in size. A thumbnails width and
/// size. A thumbnails width and height should not exceed 320. /// height should not exceed 320. Ignored if the file is not uploaded
/// Ignored if the file is not uploaded using [InputFile::File]. /// using multipart/form-data.
///
/// [InputFile::File]: crate::types::InputFile::File
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the audio to be sent, 0-1024 characters
/// Caption of the audio to be sent, 0-1024 characters.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// or inline URLs] in the media caption. /// italic, fixed-width text or inline URLs] in the media caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<String>, parse_mode: Option<String>,
/// Duration of the audio in seconds
/// Duration of the audio in seconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
duration: Option<u16>, duration: Option<u16>,
/// Performer of the audio
/// Performer of the audio.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
performer: Option<String>, performer: Option<String>,
/// Title of the audio
/// Title of the audio.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
title: Option<String>, title: Option<String>,
}, },
/// Represents a general file to be sent. /// Represents a general file to be sent.
///
/// [The official docs](https://core.telegram.org/bots/api#inputmediadocument).
Document { Document {
/// File to send. /// File to send.
media: InputFile, media: InputFile,
/// Thumbnail of the file sent; can be ignored if thumbnail generation /// Thumbnail of the file sent; can be ignored if thumbnail generation
/// for the file is supported server-side. /// for the file is supported server-side. The thumbnail should be in
/// The thumbnail should be in JPEG format and less than 200 kB in /// JPEG format and less than 200 kB in size. A thumbnails width and
/// size. A thumbnails width and height should not exceed 320. /// height should not exceed 320. Ignored if the file is not uploaded
/// Ignored if the file is not uploaded using [InputFile::File]. /// using multipart/form-data.
///
/// [InputFile::File]: crate::types::InputFile::File
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
thumb: Option<InputFile>, thumb: Option<InputFile>,
/// Caption of the document to be sent, 0-1024 characters
/// Caption of the document to be sent, 0-1024 charactersю
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
caption: Option<String>, caption: Option<String>,
/// Send [Markdown] or [HTML],
/// if you want Telegram apps to show [bold, italic, fixed-width text /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// or inline URLs] in the media caption. /// italic, fixed-width text or inline URLs] in the media caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
}, },

View file

@ -2,39 +2,40 @@ use serde::Serialize;
use crate::types::ParseMode; use crate::types::ParseMode;
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
/// This object represents the content of a message to be sent as /// This object represents the content of a message to be sent as a result of an
/// a result of an inline query. /// inline query.
/// [More](https://core.telegram.org/bots/api#inputmessagecontent) ///
/// [The official docs](https://core.telegram.org/bots/api#inputmessagecontent).
pub enum InputMessageContent { pub enum InputMessageContent {
/// Represents the content of a text message to be sent as the result of an /// Represents the content of a text message to be sent as the result of an
/// inline query. /// inline query.
Text { Text {
/// Text of the message to be sent, 1-4096 characters /// Text of the message to be sent, 1-4096 characters.
message_text: String, message_text: String,
/// Send [Markdown] or [HTML], if you want Telegram apps to show /// Send [Markdown] or [HTML], if you want Telegram apps to show [bold,
/// [bold, italic, fixed-width text or inline URLs] in the media /// italic, fixed-width text or inline URLs] in the media caption.
/// caption.
/// ///
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: https://core.telegram.org/bots/api#markdown-style
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: https://core.telegram.org/bots/api#html-style
/// [bold, italic, fixed-width text or inline URLs]: /// [bold, italic, fixed-width text or inline URLs]: https://core.telegram.org/bots/api#formatting-options
/// crate::types::ParseMode
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
parse_mode: Option<ParseMode>, parse_mode: Option<ParseMode>,
/// Disables link previews for links in the sent message /// Disables link previews for links in the sent message.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
disable_web_page_preview: Option<bool>, disable_web_page_preview: Option<bool>,
}, },
/// Represents the content of a location message to be sent as the result /// Represents the content of a location message to be sent as the result
/// of an inline query. /// of an inline query.
Location { Location {
/// Latitude of the location in degrees /// Latitude of the location in degrees.
latitude: f64, latitude: f64,
/// Longitude of the location in degrees
/// Longitude of the location in degrees.
longitude: f64, longitude: f64,
/// Period in seconds for which the location can be updated, should be /// Period in seconds for which the location can be updated, should be
@ -42,42 +43,50 @@ pub enum InputMessageContent {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
live_period: Option<u32>, live_period: Option<u32>,
}, },
/// Represents the content of a venue message to be sent as the result of /// Represents the content of a venue message to be sent as the result of
/// an inline query. /// an inline query.
Venue { Venue {
/// Latitude of the venue in degrees /// Latitude of the venue in degrees.
latitude: f64, latitude: f64,
/// Longitude of the venue in degrees
/// Longitude of the venue in degrees.
longitude: f64, longitude: f64,
/// Name of the venue
/// Name of the venue.
title: String, title: String,
/// Address of the venue
/// Address of the venue.
address: String, address: String,
/// Foursquare identifier of the venue, if known /// Foursquare identifier of the venue, if known.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
foursquare_id: Option<String>, foursquare_id: Option<String>,
/// Foursquare type of the venue, if known. (For example, /// Foursquare type of the venue, if known. (For example,
/// “arts_entertainment/default”, “arts_entertainment/aquarium” /// `arts_entertainment/default`, `arts_entertainment/aquarium`
/// or “food/icecream”.) /// or `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
foursquare_type: Option<String>, foursquare_type: Option<String>,
}, },
/// Represents the content of a contact message to be sent as the result of /// Represents the content of a contact message to be sent as the result of
/// an inline query. /// an inline query.
Contact { Contact {
/// Contact's phone number /// Contact's phone number.
phone_number: String, phone_number: String,
/// Contact's first name
/// Contact's first name.
first_name: String, first_name: String,
/// Contact's last name /// Contact's last name.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
last_name: Option<String>, last_name: Option<String>,
/// Additional data about the contact in the form of a /// Additional data about the contact in the form of a [vCard], 0-2048
/// [vCard](https://en.wikipedia.org/wiki/VCard), 0-2048 bytes /// bytes.
///
/// [vCard]: https://en.wikipedia.org/wiki/VCard
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
vcard: Option<String>, vcard: Option<String>,
}, },

View file

@ -1,8 +1,27 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] /// This object contains basic information about an invoice.
///
/// [The official docs](https://core.telegram.org/bots/api#invoice).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Invoice { pub struct Invoice {
/// Product name.
pub title: String, pub title: String,
/// Product description.
pub description: String, pub description: String,
/// Unique bot deep-linking parameter that can be used to generate this
/// invoice.
pub start_parameter: String, pub start_parameter: String,
/// Three-letter ISO 4217 currency code.
pub currency: String, pub currency: String,
/// Total price in the smallest units of the currency (integer, **not**
/// float/double). For example, for a price of `US$ 1.45` pass `amount =
/// 145`. See the exp parameter in [`currencies.json`], it shows the number
/// of digits past the decimal point for each currency (2 for the
/// majority of currencies).
///
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
pub total_amount: i32, pub total_amount: i32,
} }

View file

@ -1,19 +1,21 @@
/// This object represents one button of the reply keyboard. For filter text /// This object represents one button of the reply keyboard. For filter text
/// buttons String can be used instead of this object to specify text of the /// buttons String can be used instead of this object to specify text of the
/// button. Optional fields are mutually exclusive. /// button. Optional fields are mutually exclusive.
#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone)] ///
/// [The official docs](https://core.telegram.org/bots/api#keyboardbutton).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct KeyboardButton { pub struct KeyboardButton {
/// Text of the button. If none of the optional fields are used, it will /// Text of the button. If none of the optional fields are used, it will
/// be sent as a message when the button is pressed /// be sent as a message when the button is pressed.
pub text: String, pub text: String,
/// If `true`, the user's phone number will be sent as a contact
/// when the button is pressed. Available in private chats only.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
/// Optional. If True, the user's phone number will be sent as a contact
/// when the button is pressed. Available in private chats only
pub request_contact: Option<bool>, pub request_contact: Option<bool>,
/// If `true`, the user's current location will be sent when the
/// button is pressed. Available in private chats only.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
/// Optional. If True, the user's current location will be sent when the
/// button is pressed. Available in private chats only
pub request_location: Option<bool>, pub request_location: Option<bool>,
} }

View file

@ -1,14 +1,19 @@
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)]
/// This object represents a portion of the price for goods or services. /// This object represents a portion of the price for goods or services.
///
/// [The official docs](https://core.telegram.org/bots/api#labeledprice).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct LabeledPrice { pub struct LabeledPrice {
/// Portion label /// Portion label.
pub label: String, pub label: String,
/// Price of the product in the smallest units of the
/// [currency](https://core.telegram.org/bots/payments#supported-currencies) /// Price of the product in the smallest units of the [currency] (integer,
/// (integer, not float/double). For example, for a price of US$ 1.45 pass /// **not** float/double). For example, for a price of `US$ 1.45` pass
/// amount = 145. See the exp parameter in [`currencies.json`](https://core.telegram.org/bots/payments/currencies.json), /// `amount = 145`. See the exp parameter in [`currencies.json`], it shows
/// it shows the number of digits past the decimal point for each currency /// the number of digits past the decimal point for each currency (2
/// (2 for the majority of currencies). /// for the majority of currencies).
///
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
pub amount: i32, pub amount: i32,
} }

View file

@ -1,8 +1,9 @@
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
/// This object represents a point on the map. /// This object represents a point on the map.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Location { pub struct Location {
/// Longitude as defined by sender /// Longitude as defined by sender.
pub longitude: f64, pub longitude: f64,
/// Latitude as defined by sender
/// Latitude as defined by sender.
pub latitude: f64, pub latitude: f64,
} }

View file

@ -1,10 +1,23 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] /// This object represents a parameter of the inline keyboard button used to
/// automatically authorize a user. Serves as a great replacement for the
/// [Telegram Login Widget] when the user is coming from Telegram. All the user
/// needs to do is tap/click a button and confirm that they want to log in:
///
/// <div align="center">
/// <img src="https://core.telegram.org/file/811140015/1734/8VZFkwWXalM.97872/6127fa62d8a0bf2b3c" width=300 />
/// </div>
///
/// [Telegram Login Widget]: https://core.telegram.org/widgets/login
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct LoginUrl { pub struct LoginUrl {
pub url: String, pub url: String,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub forward_text: Option<String>, pub forward_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub bot_username: Option<String>, pub bot_username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub request_write_access: Option<bool>, pub request_write_access: Option<bool>,
} }

View file

@ -1,7 +1,23 @@
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] /// This object describes the position on faces where a mask should be placed by
/// default.
///
/// [The official docs](https://core.telegram.org/bots/api#maskposition).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct MaskPosition { pub struct MaskPosition {
/// The part of the face relative to which the mask should be placed. One
/// of `forehead`, `eyes`, `mouth`, or `chin`.
pub point: String, pub point: String,
/// Shift by X-axis measured in widths of the mask scaled to the face size,
/// from left to right. For example, choosing `-1.0` will place mask just
/// to the left of the default mask position.
pub x_shift: f64, pub x_shift: f64,
/// Shift by Y-axis measured in heights of the mask scaled to the face
/// size, from top to bottom. For example, `1.0` will place the mask just
/// below the default mask position.
pub y_shift: f64, pub y_shift: f64,
/// Mask scaling coefficient. For example, `2.0` means double size.
pub scale: f64, pub scale: f64,
} }

View file

@ -6,80 +6,147 @@ use crate::types::{
SuccessfulPayment, True, User, Venue, Video, VideoNote, Voice, SuccessfulPayment, True, User, Venue, Video, VideoNote, Voice,
}; };
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This object represents a message.
///
/// [The official docs](https://core.telegram.org/bots/api#message).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Message { pub struct Message {
/// Unique message identifier inside this chat.
#[serde(rename = "message_id")] #[serde(rename = "message_id")]
pub id: i32, pub id: i32,
/// Date the message was sent in Unix time.
pub date: i32, pub date: i32,
/// Conversation the message belongs to.
pub chat: Chat, pub chat: Chat,
#[serde(flatten)] #[serde(flatten)]
pub kind: MessageKind, pub kind: MessageKind,
} }
#[derive(Debug, Deserialize, PartialEq, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum MessageKind { pub enum MessageKind {
Common { Common {
/// Sender, empty for messages sent to channels.
#[serde(flatten)] #[serde(flatten)]
from: Sender, from: Sender,
#[serde(flatten)] #[serde(flatten)]
forward_kind: ForwardKind, forward_kind: ForwardKind,
/// Date the message was last edited in Unix time.
edit_date: Option<i32>, edit_date: Option<i32>,
#[serde(flatten)] #[serde(flatten)]
media_kind: MediaKind, media_kind: MediaKind,
/// Inline keyboard attached to the message. `login_url` buttons are
/// represented as ordinary `url` buttons.
reply_markup: Option<InlineKeyboardMarkup>, reply_markup: Option<InlineKeyboardMarkup>,
}, },
NewChatMembers { NewChatMembers {
/// New members that were added to the group or supergroup and
/// information about them (the bot itself may be one of these
/// members).
new_chat_members: Vec<User>, new_chat_members: Vec<User>,
}, },
LeftChatMember { LeftChatMember {
/// A member was removed from the group, information about them (this
/// member may be the bot itself).
left_chat_member: User, left_chat_member: User,
}, },
NewChatTitle { NewChatTitle {
/// A chat title was changed to this value.
new_chat_title: String, new_chat_title: String,
}, },
NewChatPhoto { NewChatPhoto {
/// A chat photo was change to this value.
new_chat_photo: Vec<PhotoSize>, new_chat_photo: Vec<PhotoSize>,
}, },
DeleteChatPhoto { DeleteChatPhoto {
/// Service message: the chat photo was deleted.
delete_chat_photo: True, delete_chat_photo: True,
}, },
GroupChatCreated { GroupChatCreated {
/// Service message: the group has been created.
group_chat_created: True, group_chat_created: True,
}, },
SupergroupChatCreated { SupergroupChatCreated {
/// Service message: the supergroup has been created. This field cant
/// be received in a message coming through updates, because bot cant
/// be a member of a supergroup when it is created. It can only be
/// found in `reply_to_message` if someone replies to a very first
/// message in a directly created supergroup.
supergroup_chat_created: True, supergroup_chat_created: True,
}, },
ChannelChatCreated { ChannelChatCreated {
/// Service message: the channel has been created. This field cant be
/// received in a message coming through updates, because bot cant be
/// a member of a channel when it is created. It can only be found in
/// `reply_to_message` if someone replies to a very first message in a
/// channel.
channel_chat_created: True, channel_chat_created: True,
}, },
Migrate { Migrate {
/// The group has been migrated to a supergroup with the specified
/// identifier. This number may be greater than 32 bits and some
/// programming languages may have difficulty/silent defects in
/// interpreting it. But it is smaller than 52 bits, so a signed 64 bit
/// integer or double-precision float type are safe for storing this
/// identifier.
migrate_to_chat_id: i64, migrate_to_chat_id: i64,
/// The supergroup has been migrated from a group with the specified
/// identifier. This number may be greater than 32 bits and some
/// programming languages may have difficulty/silent defects in
/// interpreting it. But it is smaller than 52 bits, so a signed 64 bit
/// integer or double-precision float type are safe for storing this
/// identifier.
migrate_from_chat_id: i64, migrate_from_chat_id: i64,
}, },
Pinned { Pinned {
/// Specified message was pinned. Note that the Message object in this
/// field will not contain further `reply_to_message` fields even if it
/// is itself a reply.
pinned: Box<Message>, pinned: Box<Message>,
}, },
Invoice { Invoice {
/// Message is an invoice for a [payment], information about the
/// invoice. [More about payments »].
///
/// [payment]: https://core.telegram.org/bots/api#payments
/// [More about payments »]: https://core.telegram.org/bots/api#payments
invoice: Invoice, invoice: Invoice,
}, },
SuccessfulPayment { SuccessfulPayment {
/// Message is a service message about a successful payment,
/// information about the payment. [More about payments »].
///
/// [More about payments »]: https://core.telegram.org/bots/api#payments
successful_payment: SuccessfulPayment, successful_payment: SuccessfulPayment,
}, },
ConnectedWebsite { ConnectedWebsite {
/// The domain name of the website on which the user has logged in.
/// [More about Telegram Login »].
///
/// [More about Telegram Login »]: https://core.telegram.org/widgets/login
connected_website: String, connected_website: String,
}, },
PassportData { PassportData {
/// Telegram Passport data.
passport_data: PassportData, passport_data: PassportData,
}, },
} }
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum Sender { pub enum Sender {
/// If message is sent from Chat /// Sender of a message from chat.
#[serde(rename = "from")] #[serde(rename = "from")]
User(User), User(User),
/// If message is sent from Channel
/// Signature of a sender of a message from a channel.
#[serde(rename = "author_signature")] #[serde(rename = "author_signature")]
Signature(String), Signature(String),
} }
@ -92,7 +159,7 @@ pub enum ForwardedFrom {
SenderName(String), SenderName(String),
} }
#[derive(Debug, Deserialize, PartialEq, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ForwardKind { pub enum ForwardKind {
ChannelForward { ChannelForward {
@ -116,75 +183,137 @@ pub enum ForwardKind {
}, },
} }
#[derive(Debug, Deserialize, PartialEq, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum MediaKind { pub enum MediaKind {
Animation { Animation {
/// Message is an animation, information about the animation. For
/// backward compatibility, when this field is set, the document field
/// will also be set.
animation: Animation, animation: Animation,
#[doc(hidden)] #[doc(hidden)]
/// "For backward compatibility" (c) Telegram Docs /// "For backward compatibility" (c) Telegram Docs.
#[serde(skip)] #[serde(skip)]
document: (), document: (),
/// Caption for the animation, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
}, },
Audio { Audio {
/// Message is an audio file, information about the file.
audio: Audio, audio: Audio,
/// Caption for the audio, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
}, },
Contact { Contact {
/// Message is a shared contact, information about the contact.
contact: Contact, contact: Contact,
}, },
Document { Document {
/// Message is a general file, information about the file.
document: Document, document: Document,
/// Caption for the document, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
}, },
Game { Game {
/// Message is a game, information about the game. [More
/// about games »].
///
/// [More about games »]: https://core.telegram.org/bots/api#games
game: Game, game: Game,
}, },
Location { Location {
/// Message is a shared location, information about the location.
location: Location, location: Location,
}, },
Photo { Photo {
/// Message is a photo, available sizes of the photo.
photo: Vec<PhotoSize>, photo: Vec<PhotoSize>,
/// Caption for the photo, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
/// The unique identifier of a media message group this message belongs
/// to.
media_group_id: Option<String>, media_group_id: Option<String>,
}, },
Poll { Poll {
/// Message is a native poll, information about the poll.
poll: Poll, poll: Poll,
}, },
Sticker { Sticker {
/// Message is a sticker, information about the sticker.
sticker: Sticker, sticker: Sticker,
}, },
Text { Text {
/// For text messages, the actual UTF-8 text of the message, 0-4096
/// characters.
text: String, text: String,
/// For text messages, special entities like usernames, URLs, bot
/// commands, etc. that appear in the text.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
entities: Vec<MessageEntity>, entities: Vec<MessageEntity>,
}, },
Video { Video {
/// Message is a video, information about the video.
video: Video, video: Video,
/// Caption for the video, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
/// The unique identifier of a media message group this message belongs
/// to.
media_group_id: Option<String>, media_group_id: Option<String>,
}, },
VideoNote { VideoNote {
/// Message is a [video note], information about the video message.
///
/// [video note]: https://telegram.org/blog/video-messages-and-telescope
video_note: VideoNote, video_note: VideoNote,
}, },
Voice { Voice {
/// Message is a voice message, information about the file.
voice: Voice, voice: Voice,
/// Caption for the voice, 0-1024 characters.
caption: Option<String>, caption: Option<String>,
/// For messages with a caption, special entities like usernames, URLs,
/// bot commands, etc. that appear in the caption.
#[serde(default = "Vec::new")] #[serde(default = "Vec::new")]
caption_entities: Vec<MessageEntity>, caption_entities: Vec<MessageEntity>,
}, },
Venue { Venue {
/// Message is a venue, information about the venue.
venue: Venue, venue: Venue,
}, },
} }

View file

@ -1,14 +1,22 @@
use crate::types::User; use crate::types::User;
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// This object represents one special entity in a text message. For example,
/// hashtags, usernames, URLs, etc.
///
/// [The official docs](https://core.telegram.org/bots/api#messageentity).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct MessageEntity { pub struct MessageEntity {
#[serde(flatten)] #[serde(flatten)]
pub kind: MessageEntityKind, pub kind: MessageEntityKind,
/// Offset in UTF-16 code units to the start of the entity.
pub offset: usize, pub offset: usize,
/// Length of the entity in UTF-16 code units.
pub length: usize, pub length: usize,
} }
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum MessageEntityKind { pub enum MessageEntityKind {

View file

@ -1,9 +1,19 @@
use crate::types::ShippingAddress; use crate::types::ShippingAddress;
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] /// This object represents information about an order.
///
/// [The official docs](https://core.telegram.org/bots/api#orderinfo).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct OrderInfo { pub struct OrderInfo {
/// User's name.
pub name: String, pub name: String,
/// User's phone number.
pub phone_number: String, pub phone_number: String,
/// User's email.
pub email: String, pub email: String,
/// User's shipping address.
pub shipping_address: ShippingAddress, pub shipping_address: ShippingAddress,
} }

View file

@ -1,11 +1,11 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
/// ## Formatting options /// ## Formatting options
/// The Bot API supports basic formatting for messages. /// The Bot API supports basic formatting for messages.
/// You can use **bold** and *italic* text, as well as [inline links](https://example.com) and `pre-formatted code` in /// You can use **bold** and *italic* text, as well as [inline links](https://example.com)
/// your bots' messages. Telegram clients will render them accordingly. You can /// and `pre-formatted code` in your bots' messages. Telegram clients will
/// use either markdown-style or HTML-style formatting. /// render them accordingly. You can use either markdown-style or HTML-style
/// formatting.
/// ///
/// Note that Telegram clients will display an alert to the user before opening /// Note that Telegram clients will display an alert to the user before opening
/// an inline link (Open this link? together with the full URL). /// an inline link (Open this link? together with the full URL).
@ -68,6 +68,7 @@ use serde::{Deserialize, Serialize};
/// [Markdown]: crate::types::ParseMode::Markdown /// [Markdown]: crate::types::ParseMode::Markdown
/// [HTML]: crate::types::ParseMode::HTML /// [HTML]: crate::types::ParseMode::HTML
/// [SendMessage]: crate::requests::payloads::SendMessage /// [SendMessage]: crate::requests::payloads::SendMessage
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum ParseMode { pub enum ParseMode {
HTML, HTML,
Markdown, Markdown,

View file

@ -1,7 +1,15 @@
use super::{EncryptedCredentials, EncryptedPassportElement}; use super::{EncryptedCredentials, EncryptedPassportElement};
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// Contains information about Telegram Passport data shared with the bot by the
/// user.
///
/// [The official docs](https://core.telegram.org/bots/api#passportdata).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PassportData { pub struct PassportData {
/// Array with information about documents and other Telegram Passport
/// elements that was shared with the bot.
pub data: Vec<EncryptedPassportElement>, pub data: Vec<EncryptedPassportElement>,
/// Encrypted credentials required to decrypt the data.
pub credentials: EncryptedCredentials, pub credentials: EncryptedCredentials,
} }

View file

@ -1,6 +1,16 @@
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// This object represents a file uploaded to Telegram Passport. Currently all
/// Telegram Passport files are in JPEG format when decrypted and don't exceed
/// 10MB.
///
/// [The official docs](https://core.telegram.org/bots/api#passportfile).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PassportFile { pub struct PassportFile {
/// Identifier for this file.
pub file_id: String, pub file_id: String,
/// File size.
pub file_size: u64, pub file_size: u64,
/// Unix time when the file was uploaded.
pub file_date: u64, pub file_date: u64,
} }

View file

@ -1,17 +1,19 @@
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Clone)] /// This object represents one size of a photo or a [file]/[sticker] thumbnail.
/// This object represents one size of a photo or a [`Document`] /
/// [`Sticker`] thumbnail.
/// ///
/// [`Document`]: crate::types::Document /// [file]: crate::types::Document
/// [`Sticker`]: crate::types::Sticker /// [sticker]: crate::types::Sticker
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PhotoSize { pub struct PhotoSize {
/// Identifier for this file /// Identifier for this file.
pub file_id: String, pub file_id: String,
/// Photo width
/// Photo width.
pub width: i32, pub width: i32,
/// Photo height
/// Photo height.
pub height: i32, pub height: i32,
/// Optional. File size
/// File size.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,13 +1,29 @@
/// This object contains information about a poll.
///
/// [The official docs](https://core.telegram.org/bots/api#poll).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Poll { pub struct Poll {
/// Unique poll identifier.
pub id: String, pub id: String,
/// Poll question, 1-255 characters.
pub question: String, pub question: String,
/// List of poll options.
pub options: Vec<PollOption>, pub options: Vec<PollOption>,
/// `true`, if the poll is closed.
pub is_closed: bool, pub is_closed: bool,
} }
/// This object contains information about one answer option in a poll.
///
/// [The official docs](https://core.telegram.org/bots/api#polloption).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PollOption { pub struct PollOption {
/// Option text, 1-100 characters.
pub text: String, pub text: String,
/// Number of users that voted for this option.
pub voter_count: i32, pub voter_count: i32,
} }

View file

@ -1,12 +1,36 @@
use crate::types::{OrderInfo, User}; use crate::types::{OrderInfo, User};
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] /// This object contains information about an incoming pre-checkout query.
///
/// [The official docs](https://core.telegram.org/bots/api#precheckoutquery).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct PreCheckoutQuery { pub struct PreCheckoutQuery {
/// Unique query identifier.
pub id: String, pub id: String,
/// User who sent the query.
pub from: User, pub from: User,
/// Three-letter ISO 4217 [currency] code.
///
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
pub currency: String, pub currency: String,
/// Total price in the _smallest units_ of the currency (integer, **not**
/// float/double). For example, for a price of `US$ 1.45` pass `amount =
/// 145`. See the exp parameter in [`currencies.json`], it shows the number
/// of digits past the decimal point for each currency (2 for the
/// majority of currencies).
///
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
pub total_amount: i32, pub total_amount: i32,
/// Bot specified invoice payload.
pub invoice_payload: String, pub invoice_payload: String,
/// Identifier of the shipping option chosen by the user.
pub shipping_option_id: Option<String>, pub shipping_option_id: Option<String>,
/// Order info provided by the user.
pub order_info: Option<OrderInfo>, pub order_info: Option<OrderInfo>,
} }

View file

@ -1,7 +1,13 @@
use crate::types::KeyboardButton; use crate::types::KeyboardButton;
/// This object represents a custom keyboard with reply options. /// This object represents a [custom keyboard] with reply options (see
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] /// [Introduction to bots] for details and examples).
///
/// [The official docs](https://core.telegram.org/bots/api#replykeyboardmarkup).
///
/// [custom keyboard]: https://core.telegram.org/bots#keyboards
/// [Introduction to bots]: https://core.telegram.org/bots#keyboards
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ReplyKeyboardMarkup { pub struct ReplyKeyboardMarkup {
/// Array of button rows, each represented by an Array of /// Array of button rows, each represented by an Array of
/// [`KeyboardButton`] objects /// [`KeyboardButton`] objects
@ -9,32 +15,31 @@ pub struct ReplyKeyboardMarkup {
/// [`KeyboardButton`]: crate::types::KeyboardButton /// [`KeyboardButton`]: crate::types::KeyboardButton
pub keyboard: Vec<Vec<KeyboardButton>>, pub keyboard: Vec<Vec<KeyboardButton>>,
/// Requests clients to resize the keyboard vertically for optimal fit
/// (e.g., make the keyboard smaller if there are just two rows of
/// buttons). Defaults to `false`, in which case the custom keyboard is
/// always of the same height as the app's standard keyboard.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
/// Optional. Requests clients to resize the keyboard vertically for
/// optimal fit (e.g., make the keyboard smaller if there are just two
/// rows of buttons). Defaults to false, in which case the custom
/// keyboard is always of the same height as the app's standard
/// keyboard.
pub resize_keyboard: Option<bool>, pub resize_keyboard: Option<bool>,
/// Requests clients to hide the keyboard as soon as it's been used. The
/// keyboard will still be available, but clients will automatically
/// display the usual letter-keyboard in the chat the user can press a
/// special button in the input field to see the custom keyboard again.
/// Defaults to `false`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
/// Optional. Requests clients to hide the keyboard as soon as it's been
/// used. The keyboard will still be available, but clients will
/// automatically display the usual letter-keyboard in the chat the user
/// can press a special button in the input field to see the custom
/// keyboard again. Defaults to false.
pub one_time_keyboard: Option<bool>, pub one_time_keyboard: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")] /// Use this parameter if you want to show the keyboard to specific users
/// Optional. Use this parameter if you want to show the keyboard to /// only. Targets: 1) users that are `@mentioned` in the `text` of the
/// specific users only. Targets: 1) users that are @mentioned in the text /// [`Message`] object; 2) if the bot's message is a reply (has
/// of the [`Message`] object; 2) if the bot's message is a reply /// `reply_to_message_id`), sender of the original message.
/// (has reply_to_message_id), sender of the original message.
/// ///
/// Example: A user requests to change the bots language, bot replies to /// Example: A user requests to change the bots language, bot replies to
/// the request with a keyboard to select the new language. Other users in /// the request with a keyboard to select the new language. Other users
/// the group dont see the keyboard. /// in the group dont see the keyboard.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
#[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -1,35 +1,34 @@
use crate::types::True; use crate::types::True;
/// Upon receiving a message with this object, Telegram clients will remove /// Upon receiving a message with this object, Telegram clients will remove the
/// the current custom keyboard and display the default letter-keyboard. /// current custom keyboard and display the default letter-keyboard. By default,
/// By default, custom keyboards are displayed until a new keyboard is sent /// custom keyboards are displayed until a new keyboard is sent by a bot. An
/// by a bot. An exception is made for one-time keyboards that are hidden /// exception is made for one-time keyboards that are hidden immediately after
/// immediately after the user presses a button (see [`ReplyKeyboardMarkup`]). /// the user presses a button (see [`ReplyKeyboardMarkup`]).
///
/// [The official docs](https://core.telegram.org/bots/api#replykeyboardremove).
/// ///
/// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup /// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ReplyKeyboardRemove { pub struct ReplyKeyboardRemove {
/// Requests clients to remove the custom keyboard (user will not be able /// Requests clients to remove the custom keyboard (user will not be able
/// to summon this keyboard; if you want to hide the keyboard from /// to summon this keyboard; if you want to hide the keyboard from sight
/// sight but keep it accessible, use one_time_keyboard in /// but keep it accessible, use one_time_keyboard in
/// ReplyKeyboardMarkup) /// [`ReplyKeyboardMarkup`]).
///
/// [`ReplyKeyboardMarkup`]: crate::types::ReplyKeyboardMarkup
pub remove_keyboard: True, pub remove_keyboard: True,
/// Optional. Use this parameter if you want to show the keyboard to /// Use this parameter if you want to remove the keyboard for specific
/// specific users only. /// users only. Targets: 1) users that are `@mentioned` in the `text` of
/// the [`Message`] object; 2) if the bot's message is a reply (has
/// `reply_to_message_id`), sender of the original message.
/// ///
/// Targets: /// Example: A user votes in a poll, bot returns confirmation message in
/// 1. users that are `@mentioned` in the text of the [`Message`] /// reply to the vote and removes the keyboard for that user, while still
/// 2. if the bot's message is a reply (has [`reply_to_message_id`]), /// showing the keyboard with poll options to users who haven't voted yet.
/// sender of the original message.
///
/// ## Example
/// A user requests to change the bots language, bot replies to
/// the request with a keyboard to select the new language. Other users in
/// the group dont see the keyboard.
/// ///
/// [`Message`]: crate::types::Message /// [`Message`]: crate::types::Message
/// [`reply_to_message_id`]: crate::types::ForwardKind::Origin
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub selective: Option<bool>, pub selective: Option<bool>,
} }

View file

@ -2,7 +2,7 @@ use crate::types::{
ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove,
}; };
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ReplyMarkup { pub enum ReplyMarkup {
Inline(InlineKeyboardMarkup), Inline(InlineKeyboardMarkup),

View file

@ -1,7 +1,19 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] /// Contains information about why a request was unsuccessful.
///
/// [The official docs](https://core.telegram.org/bots/api#responseparameters).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ResponseParameters { pub enum ResponseParameters {
/// The group has been migrated to a supergroup with the specified
/// identifier. This number may be greater than 32 bits and some
/// programming languages may have difficulty/silent defects in
/// interpreting it. But it is smaller than 52 bits, so a signed 64 bit
/// integer or double-precision float type are safe for storing this
/// identifier.
MigrateToChatId(i64), MigrateToChatId(i64),
/// In case of exceeding flood control, the number of seconds left to wait
/// before the request can be repeated.
RetryAfter(i32), RetryAfter(i32),
} }

View file

@ -1,6 +1,6 @@
use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice}; use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice};
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct SendInvoice { pub struct SendInvoice {
pub chat_id: ChatId, pub chat_id: ChatId,
pub title: String, pub title: String,

View file

@ -1,9 +1,23 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] /// This object represents a shipping address.
///
/// [The official docs](https://core.telegram.org/bots/api#shippingaddress).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ShippingAddress { pub struct ShippingAddress {
/// ISO 3166-1 alpha-2 country code.
pub country_code: String, pub country_code: String,
/// State, if applicable.
pub state: String, pub state: String,
/// City.
pub city: String, pub city: String,
/// First line for the address.
pub street_line1: String, pub street_line1: String,
/// Second line for the address.
pub street_line2: String, pub street_line2: String,
/// Address post code.
pub post_code: String, pub post_code: String,
} }

View file

@ -1,13 +1,17 @@
use crate::types::LabeledPrice; use crate::types::LabeledPrice;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)]
/// This object represents one shipping option. /// This object represents one shipping option.
///
/// [The official docs](https://core.telegram.org/bots/api#shippingoption).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ShippingOption { pub struct ShippingOption {
/// Shipping option identifier /// Shipping option identifier.
pub id: String, pub id: String,
/// Option title
/// Option title.
pub title: String, pub title: String,
/// List of price portions
/// List of price portions.
pub prices: Vec<LabeledPrice>, pub prices: Vec<LabeledPrice>,
} }

View file

@ -1,9 +1,19 @@
use crate::types::{ShippingAddress, User}; use crate::types::{ShippingAddress, User};
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] /// This object contains information about an incoming shipping query.
///
/// [The official docs](https://core.telegram.org/bots/api#shippingquery).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ShippingQuery { pub struct ShippingQuery {
/// Unique query identifier.
pub id: String, pub id: String,
/// User who sent the query.
pub from: User, pub from: User,
/// Bot specified invoice payload.
pub invoice_payload: String, pub invoice_payload: String,
/// User specified shipping address.
pub shipping_address: ShippingAddress, pub shipping_address: ShippingAddress,
} }

View file

@ -1,14 +1,36 @@
use crate::types::{MaskPosition, PhotoSize}; use crate::types::{MaskPosition, PhotoSize};
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This object represents a sticker.
///
/// [The official docs](https://core.telegram.org/bots/api#sticker).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Sticker { pub struct Sticker {
/// Identifier for this file.
pub file_id: String, pub file_id: String,
/// Sticker width.
pub width: u16, pub width: u16,
/// Sticker height.
pub height: u16, pub height: u16,
/// `true`, if the sticker is [animated].
///
/// [animated]: https://telegram.org/blog/animated-stickers
pub is_animated: bool, pub is_animated: bool,
/// Sticker thumbnail in the .webp or .jpg format.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
/// Emoji associated with the sticker.
pub emoji: Option<String>, pub emoji: Option<String>,
/// Name of the sticker set to which the sticker belongs.
pub set_name: Option<String>, pub set_name: Option<String>,
/// For mask stickers, the position where the mask should be placed.
pub mask_position: Option<MaskPosition>, pub mask_position: Option<MaskPosition>,
/// File size.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,10 +1,24 @@
use crate::types::Sticker; use crate::types::Sticker;
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This object represents a sticker set.
///
/// [The official docs](https://core.telegram.org/bots/api#stickerset).
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct StickerSet { pub struct StickerSet {
/// Sticker set name.
pub name: String, pub name: String,
/// Sticker set title.
pub title: String, pub title: String,
/// `true`, if the sticker set contains [animated stickers].
///
/// [animates stickers]: https://telegram.org/blog/animated-stickers
pub is_animated: bool, pub is_animated: bool,
/// `true`, if the sticker set contains masks.
pub contains_masks: bool, pub contains_masks: bool,
/// List of all set stickers.
pub stickers: Vec<Sticker>, pub stickers: Vec<Sticker>,
} }

View file

@ -1,12 +1,36 @@
use crate::types::OrderInfo; use crate::types::OrderInfo;
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] /// This object contains basic information about a successful payment.
///
/// [The official docs](https://core.telegram.org/bots/api#successfulpayment).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct SuccessfulPayment { pub struct SuccessfulPayment {
/// Three-letter ISO 4217 [currency] code.
///
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
pub currency: String, pub currency: String,
/// Total price in the smallest units of the currency (integer, not
/// float/double). For example, for a price of `US$ 1.45` pass `amount =
/// 145`. See the exp parameter in [`currencies.json`], it shows the
/// number of digits past the decimal point for each currency (2 for
/// the majority of currencies).
///
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
pub total_amount: i32, pub total_amount: i32,
/// Bot specified invoice payload.
pub invoice_payload: String, pub invoice_payload: String,
/// Identifier of the shipping option chosen by the user.
pub shipping_option_id: Option<String>, pub shipping_option_id: Option<String>,
/// Order info provided by the user.
pub order_info: Option<OrderInfo>, pub order_info: Option<OrderInfo>,
/// Telegram payment identifier.
pub telegram_payment_charge_id: String, pub telegram_payment_charge_id: String,
/// Provider payment identifier.
pub provider_payment_charge_id: String, pub provider_payment_charge_id: String,
} }

View file

@ -1,6 +1,6 @@
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq)] #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Default)]
pub struct False; pub struct False;
impl std::convert::TryFrom<bool> for False { impl std::convert::TryFrom<bool> for False {

View file

@ -3,7 +3,7 @@ use serde::{
ser::{Serialize, Serializer}, ser::{Serialize, Serializer},
}; };
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq)] #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Default)]
pub struct True; pub struct True;
impl std::convert::TryFrom<bool> for True { impl std::convert::TryFrom<bool> for True {

View file

@ -2,24 +2,60 @@
use crate::types::{CallbackQuery, ChosenInlineResult, InlineQuery, Message}; use crate::types::{CallbackQuery, ChosenInlineResult, InlineQuery, Message};
#[derive(Debug, Deserialize, PartialEq, Clone)] /// This [object] represents an incoming update.
///
/// [The official docs](https://core.telegram.org/bots/api#update).
///
/// [object]: https://core.telegram.org/bots/api#available-types
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Update { pub struct Update {
/// The updates unique identifier. Update identifiers start from a certain
/// positive number and increase sequentially. This ID becomes especially
/// handy if youre using [Webhooks], since it allows you to ignore
/// repeated updates or to restore the correct update sequence, should
/// they get out of order. If there are no new updates for at least a
/// week, then identifier of the next update will be chosen randomly
/// instead of sequentially.
///
/// [Webhooks]: crate::Bot::set_webhook
#[serde(rename = "update_id")] #[serde(rename = "update_id")]
pub id: i32, pub id: i32,
#[serde(flatten)] #[serde(flatten)]
pub kind: UpdateKind, pub kind: UpdateKind,
} }
#[derive(Debug, Deserialize, PartialEq, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum UpdateKind { pub enum UpdateKind {
/// New incoming message of any kind — text, photo, sticker, etc.
Message(Message), Message(Message),
/// New version of a message that is known to the bot and was edited.
EditedMessage(Message), EditedMessage(Message),
/// New incoming channel post of any kind — text, photo, sticker, etc.
ChannelPost(Message), ChannelPost(Message),
/// New version of a channel post that is known to the bot and was edited.
EditedChannelPost(Message), EditedChannelPost(Message),
/// New incoming [inline] query.
///
/// [inline]: https://core.telegram.org/bots/api#inline-mode
InlineQuery(InlineQuery), InlineQuery(InlineQuery),
/// The result of an [inline] query that was chosen by a user and sent to
/// their chat partner. Please see our documentation on the [feedback
/// collecting] for details on how to enable these updates for your bot.
///
/// [inline]: https://core.telegram.org/bots/api#inline-mode
/// [feedback collecting]: https://core.telegram.org/bots/inline#collecting-feedback
ChosenInlineResult(ChosenInlineResult), ChosenInlineResult(ChosenInlineResult),
/// New incoming callback query.
CallbackQuery(CallbackQuery), CallbackQuery(CallbackQuery),
// TODO: Add more variants
} }
#[cfg(test)] #[cfg(test)]

View file

@ -1,10 +1,26 @@
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] /// This object represents a Telegram user or bot.
///
/// [The official docs](https://core.telegram.org/bots/api#user).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct User { pub struct User {
/// Unique identifier for this user or bot.
pub id: i32, pub id: i32,
/// `true`, if this user is a bot.
pub is_bot: bool, pub is_bot: bool,
/// Users or bots first name.
pub first_name: String, pub first_name: String,
/// Users or bots last name.
pub last_name: Option<String>, pub last_name: Option<String>,
/// Users or bots username.
pub username: Option<String>, pub username: Option<String>,
/// [IETF language tag] of the user's language.
///
/// [IETF language tag]: https://en.wikipedia.org/wiki/IETF_language_tag
pub language_code: Option<String>, pub language_code: Option<String>,
} }

View file

@ -1,7 +1,13 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)] /// This object represent a user's profile pictures.
///
/// [The official docs](https://core.telegram.org/bots/api#userprofilephotos).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct UserProfilePhotos { pub struct UserProfilePhotos {
/// Total number of profile pictures the target user has.
pub total_count: u32, pub total_count: u32,
/// Requested profile pictures (in up to 4 sizes each).
pub photos: Vec<Vec<PhotoSize>>, pub photos: Vec<Vec<PhotoSize>>,
} }

View file

@ -1,20 +1,24 @@
use crate::types::Location; use crate::types::Location;
/// This object represents a venue. /// This object represents a venue.
#[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Venue { pub struct Venue {
/// Venue location /// Venue location.
pub location: Location, pub location: Location,
/// Name of the venue
/// Name of the venue.
pub title: String, pub title: String,
/// Address of the venue
/// Address of the venue.
pub address: String, pub address: String,
/// Foursquare identifier of the venue
/// Foursquare identifier of the venue.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_id: Option<String>, pub foursquare_id: Option<String>,
/// Foursquare type of the venue. (For example, /// Foursquare type of the venue. (For example,
/// “arts_entertainment/default”, “arts_entertainment/aquarium” or /// `arts_entertainment/default`, `arts_entertainment/aquarium` or
/// “food/icecream”.) /// `food/icecream`.)
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub foursquare_type: Option<String>, // TODO: is this enum?... pub foursquare_type: Option<String>, // TODO: is this enum?...
} }

View file

@ -1,20 +1,28 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
/// This object represents a video file. /// This object represents a video file.
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Clone)] ///
/// [The official docs](https://core.telegram.org/bots/api#video).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Video { pub struct Video {
/// Identifier for this file /// Identifier for this file.
pub file_id: String, pub file_id: String,
/// Video width as defined by sender
/// Video width as defined by sender.
pub width: u32, pub width: u32,
/// Video height as defined by sender
/// Video height as defined by sender.
pub height: u32, pub height: u32,
/// Duration of the video in seconds as defined by sender
/// Duration of the video in seconds as defined by sender.
pub duration: u32, pub duration: u32,
/// Video thumbnail
/// Video thumbnail.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
/// Mime type of a file as defined by sender
/// Mime type of a file as defined by sender.
pub mime_type: Option<String>, pub mime_type: Option<String>,
/// File size
/// File size.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,18 +1,27 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] /// This object represents a [video message] (available in Telegram apps as of
/// This object represents a [video message](https://telegram.org/blog/video-messages-and-telescope) /// [v.4.0]).
/// (available in Telegram apps as of v.4.0). ///
/// [The official docs](https://core.telegram.org/bots/api#videonote).
///
/// [video message]: https://telegram.org/blog/video-messages-and-telescope
/// [v4.0]: https://telegram.org/blog/video-messages-and-telescope
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct VideoNote { pub struct VideoNote {
/// Identifier for this file /// Identifier for this file.
pub file_id: String, pub file_id: String,
/// Video width and height (diameter of the video message) as defined by /// Video width and height (diameter of the video message) as defined by
/// sender /// sender.
pub length: u32, pub length: u32,
/// Duration of the video in seconds as defined by sender
/// Duration of the video in seconds as defined by sender.
pub duration: u32, pub duration: u32,
/// Optional. Video thumbnail
/// Video thumbnail.
pub thumb: Option<PhotoSize>, pub thumb: Option<PhotoSize>,
/// Optional. File size
/// File size.
pub file_size: Option<u32>, pub file_size: Option<u32>,
} }

View file

@ -1,12 +1,17 @@
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)]
/// This object represents a voice note. /// This object represents a voice note.
///
/// [The official docs](https://core.telegram.org/bots/api#voice).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Voice { pub struct Voice {
/// Identifier for this file /// Identifier for this file.
pub file_id: String, pub file_id: String,
/// Duration of the audio in seconds as defined by sender
/// Duration of the audio in seconds as defined by sender.
pub duration: u32, pub duration: u32,
/// Optional. MIME type of the file as defined by sender
/// MIME type of the file as defined by sender.
pub mime_type: Option<String>, pub mime_type: Option<String>,
/// Optional. File size
/// File size.
pub file_size: Option<u64>, pub file_size: Option<u64>,
} }

View file

@ -1,23 +1,31 @@
/// Contains information about the current status of a webhook. /// Contains information about the current status of a webhook.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] ///
/// [The official docs](https://core.telegram.org/bots/api#webhookinfo).
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct WebhookInfo { pub struct WebhookInfo {
/// Webhook URL, may be empty if webhook is not set up /// Webhook URL, may be empty if webhook is not set up.
pub url: String, pub url: String,
/// True, if a custom certificate was provided for webhook certificate
/// checks /// `true`, if a custom certificate was provided for webhook certificate
/// checks.
pub has_custom_certificate: bool, pub has_custom_certificate: bool,
/// Number of updates awaiting delivery
/// Number of updates awaiting delivery.
pub pending_update_count: u32, pub pending_update_count: u32,
/// Optional. Unix time for the most recent error that happened when trying
/// to deliver an update via webhook /// Unix time for the most recent error that happened when trying to
/// deliver an update via webhook.
pub last_error_date: Option<u64>, pub last_error_date: Option<u64>,
/// Optional. Error message in human-readable format for the most recent
/// error that happened when trying to deliver an update via webhook /// Error message in human-readable format for the most recent error that
/// happened when trying to deliver an update via webhook.
pub last_error_message: Option<String>, pub last_error_message: Option<String>,
/// Optional. Maximum allowed number of simultaneous HTTPS connections to
/// the webhook for update delivery /// Maximum allowed number of simultaneous HTTPS connections to the webhook
/// for update delivery.
pub max_connections: Option<u32>, pub max_connections: Option<u32>,
/// Optional. A list of update types the bot is subscribed to. Defaults
/// to all update types /// A list of update types the bot is subscribed to. Defaults to all update
/// types.
pub allowed_updates: Option<Vec<String>>, pub allowed_updates: Option<Vec<String>>,
} }