mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Merge branch 'dev' of github.com:async-telegram-bot/async-telegram-bot into dev
This commit is contained in:
commit
8fe2db0259
24 changed files with 157 additions and 155 deletions
|
@ -45,8 +45,6 @@ pub trait Request<'a> {
|
||||||
|
|
||||||
pub type RequestFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
|
pub type RequestFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// todo: better name?
|
// todo: better name?
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RequestInfo<'a> {
|
pub struct RequestInfo<'a> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::core::types::PhotoSize;
|
use crate::core::types::PhotoSize;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||||
pub struct Audio {
|
pub struct Audio {
|
||||||
pub file_id: String,
|
pub file_id: String,
|
||||||
|
@ -14,5 +13,5 @@ pub struct Audio {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub file_size: Option<u32>,
|
pub file_size: Option<u32>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub thumb: Option<PhotoSize>
|
pub thumb: Option<PhotoSize>,
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::core::types::{ChatPermissions, ChatPhoto, Message};
|
use crate::core::types::{ChatPermissions, ChatPhoto, Message};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
pub struct Chat {
|
pub struct Chat {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
|
@ -9,7 +8,6 @@ pub struct Chat {
|
||||||
pub photo: Option<ChatPhoto>,
|
pub photo: Option<ChatPhoto>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -20,34 +18,32 @@ pub enum ChatType {
|
||||||
type_: NotPrivateChatType,
|
type_: NotPrivateChatType,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
invite_link: Option<String>,
|
invite_link: Option<String>,
|
||||||
pinned_message: Option<Box<Message>>
|
pinned_message: Option<Box<Message>>,
|
||||||
},
|
},
|
||||||
Private {
|
Private {
|
||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
first_name: Option<String>,
|
first_name: Option<String>,
|
||||||
last_name: Option<String>
|
last_name: Option<String>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum NotPrivateChatType {
|
pub enum NotPrivateChatType {
|
||||||
Channel {
|
Channel {
|
||||||
username: Option<String>
|
username: Option<String>,
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
permissions: Option<ChatPermissions>
|
permissions: Option<ChatPermissions>,
|
||||||
},
|
},
|
||||||
Supergroup {
|
Supergroup {
|
||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
sticker_set_name: Option<String>,
|
sticker_set_name: Option<String>,
|
||||||
can_set_sticker_set: Option<bool>,
|
can_set_sticker_set: Option<bool>,
|
||||||
permissions: Option<ChatPermissions>
|
permissions: Option<ChatPermissions>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chat_de() {
|
fn test_chat_de() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::core::types::{User, ChatMemberStatus};
|
use crate::core::types::{ChatMemberStatus, 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)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
|
@ -7,32 +7,48 @@ pub struct ChatMember {
|
||||||
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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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
|
///Optional. 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 with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
|
///Optional. Administrators only. True, if the administrator can add new
|
||||||
|
/// administrators with a subset of his own privileges or demote
|
||||||
|
/// administrators that he has promoted, directly or indirectly (promoted 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
|
///Optional. 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 can_send_messages
|
///Optional. Restricted only. True, if the user can send audios, documents,
|
||||||
|
/// photos, videos, video notes and voice notes, implies can_send_messages
|
||||||
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 can_send_media_messages
|
///Optional. Restricted only. True, if the user can send animations, games,
|
||||||
|
/// stickers and use inline bots, implies can_send_media_messages
|
||||||
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
|
///Optional. Restricted only. True, if user may add web page previews to
|
||||||
|
/// his messages, implies can_send_media_messages
|
||||||
pub can_add_web_page_previews: Option<bool>,
|
pub can_add_web_page_previews: Option<bool>,
|
||||||
}
|
}
|
|
@ -4,14 +4,14 @@ use serde::Deserialization;
|
||||||
/// This object represents a phone contact.
|
/// This object represents a phone contact.
|
||||||
struct Contact {
|
struct Contact {
|
||||||
/// Contact's phone number
|
/// Contact's phone number
|
||||||
phone_number: String,
|
pub phone_number: String,
|
||||||
/// Contact's first name
|
/// Contact's first name
|
||||||
first_name: String,
|
pub first_name: String,
|
||||||
/// Optional. Contact's last name
|
/// Optional. Contact's last name
|
||||||
last_name: Option<String>,
|
pub last_name: Option<String>,
|
||||||
/// Optional. Contact's user identifier in Telegram
|
/// Optional. Contact's user identifier in Telegram
|
||||||
user_id: Option<i64>,
|
pub user_id: Option<i64>,
|
||||||
/// Optional. Additional data about the contact in the form of a
|
/// Optional. Additional data about the contact in the form of a
|
||||||
/// [vCard](https://en.wikipedia.org/wiki/VCard)
|
/// [vCard](https://en.wikipedia.org/wiki/VCard)
|
||||||
vcard: Option<String>,
|
pub vcard: Option<String>,
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::core::types::PhotoSize;
|
use crate::core::types::PhotoSize;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
pub struct Document {
|
pub struct Document {
|
||||||
pub file_id: String,
|
pub file_id: String,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
/// interfaces without having to sacrifice privacy mod
|
/// interfaces without having to sacrifice privacy mod
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct ForceReply {
|
pub struct ForceReply {
|
||||||
force_reply: True,
|
pub force_reply: True,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
selective: bool,
|
pub selective: bool,
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
/// This object represents one button of an inline keyboard.
|
/// This object represents one button of an inline keyboard.
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct InlineKeyboardButton {
|
pub struct InlineKeyboardButton {
|
||||||
text: String,
|
pub text: String,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
kind: InlineKeyboardButtonKind,
|
pub kind: InlineKeyboardButtonKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/// This object represents an inline keyboard that appears right next to the message it belongs to.
|
/// This object represents an inline keyboard that appears right next to the message it belongs to.
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct InlineKeyboardMarkup {
|
pub struct InlineKeyboardMarkup {
|
||||||
inline_keyboard: Vec<Vec<InlineKeyboardButton>>,
|
pub inline_keyboard: Vec<Vec<InlineKeyboardButton>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,20 @@ pub enum InputFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl serde::Serialize for InputFile {
|
impl serde::Serialize for InputFile {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
match self {
|
match self {
|
||||||
InputFile::File(path) => {
|
InputFile::File(path) => {
|
||||||
// NOTE: file should be actually attached with multipart/form-data
|
// NOTE: file should be actually attached with multipart/form-data
|
||||||
serializer.serialize_str(
|
serializer.serialize_str(
|
||||||
// TODO: remove unwrap (?)
|
// TODO: remove unwrap (?)
|
||||||
&format!("attach://{}", path.file_name().unwrap().to_string_lossy())
|
&format!("attach://{}", path.file_name().unwrap().to_string_lossy()),
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
InputFile::Url(url) => serializer.serialize_str(url),
|
InputFile::Url(url) => serializer.serialize_str(url),
|
||||||
InputFile::FileId(id) => serializer.serialize_str(id),
|
InputFile::FileId(id) => serializer.serialize_str(id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,13 @@ pub enum InputMedia {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
caption: Option<String>,
|
caption: Option<String>,
|
||||||
/// Send [Markdown] or [HTML],
|
/// Send [Markdown] or [HTML],
|
||||||
/// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs]
|
/// if you want Telegram apps to show [bold, italic, fixed-width text or
|
||||||
/// in the media caption.
|
/// inline URLs] in the media caption.
|
||||||
///
|
///
|
||||||
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
||||||
/// [Html]: crate::core::types::ParseMode::Html
|
/// [Html]: crate::core::types::ParseMode::Html
|
||||||
/// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode
|
/// [bold, italic, fixed-width text or inline URLs]:
|
||||||
|
/// crate::core::types::ParseMode
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
parse_mode: Option<ParseMode>,
|
parse_mode: Option<ParseMode>,
|
||||||
},
|
},
|
||||||
|
@ -28,8 +29,8 @@ pub enum InputMedia {
|
||||||
/// File to send.File to send.
|
/// File to send.File to send.
|
||||||
media: InputFile,
|
media: InputFile,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
|
/// Thumbnail of the file sent; can be ignored if thumbnail generation
|
||||||
/// supported server-side.
|
/// for the file is supported server-side.
|
||||||
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||||
/// A thumbnail‘s width and height should not exceed 320.
|
/// A thumbnail‘s width and height should not exceed 320.
|
||||||
/// Ignored if the file is not uploaded using [InputFile::File].
|
/// Ignored if the file is not uploaded using [InputFile::File].
|
||||||
|
@ -40,12 +41,13 @@ pub enum InputMedia {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
caption: Option<String>,
|
caption: Option<String>,
|
||||||
/// Send [Markdown] or [HTML],
|
/// Send [Markdown] or [HTML],
|
||||||
/// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs]
|
/// if you want Telegram apps to show [bold, italic, fixed-width text or
|
||||||
/// in the media caption.
|
/// inline URLs] in the media caption.
|
||||||
///
|
///
|
||||||
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
||||||
/// [Html]: crate::core::types::ParseMode::Html
|
/// [Html]: crate::core::types::ParseMode::Html
|
||||||
/// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode
|
/// [bold, italic, fixed-width text or inline URLs]:
|
||||||
|
/// crate::core::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
|
||||||
|
@ -61,12 +63,13 @@ pub enum InputMedia {
|
||||||
#[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 sound) to be sent.
|
/// Represents an animation file (GIF or H.264/MPEG-4 AVC video without
|
||||||
|
/// sound) to be sent.
|
||||||
Animation {
|
Animation {
|
||||||
/// File to send.
|
/// File to send.
|
||||||
media: InputFile,
|
media: InputFile,
|
||||||
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
|
/// Thumbnail of the file sent; can be ignored if thumbnail generation
|
||||||
/// supported server-side.
|
/// for the file is supported server-side.
|
||||||
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||||
/// A thumbnail‘s width and height should not exceed 320.
|
/// A thumbnail‘s width and height should not exceed 320.
|
||||||
/// Ignored if the file is not uploaded using [InputFile::File].
|
/// Ignored if the file is not uploaded using [InputFile::File].
|
||||||
|
@ -78,12 +81,13 @@ pub enum InputMedia {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
caption: Option<String>,
|
caption: Option<String>,
|
||||||
/// Send [Markdown] or [HTML],
|
/// Send [Markdown] or [HTML],
|
||||||
/// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs]
|
/// if you want Telegram apps to show [bold, italic, fixed-width text or
|
||||||
/// in the media caption.
|
/// inline URLs] in the media caption.
|
||||||
///
|
///
|
||||||
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
||||||
/// [Html]: crate::core::types::ParseMode::Html
|
/// [Html]: crate::core::types::ParseMode::Html
|
||||||
/// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode
|
/// [bold, italic, fixed-width text or inline URLs]:
|
||||||
|
/// crate::core::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
|
||||||
|
@ -100,8 +104,8 @@ pub enum InputMedia {
|
||||||
Audio {
|
Audio {
|
||||||
/// File to send,
|
/// File to send,
|
||||||
media: InputFile,
|
media: InputFile,
|
||||||
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
|
/// Thumbnail of the file sent; can be ignored if thumbnail generation
|
||||||
/// supported server-side.
|
/// for the file is supported server-side.
|
||||||
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||||
/// A thumbnail‘s width and height should not exceed 320.
|
/// A thumbnail‘s width and height should not exceed 320.
|
||||||
/// Ignored if the file is not uploaded using [InputFile::File].
|
/// Ignored if the file is not uploaded using [InputFile::File].
|
||||||
|
@ -113,12 +117,13 @@ pub enum InputMedia {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
caption: Option<String>,
|
caption: Option<String>,
|
||||||
/// Send [Markdown] or [HTML],
|
/// Send [Markdown] or [HTML],
|
||||||
/// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs]
|
/// if you want Telegram apps to show [bold, italic, fixed-width text or
|
||||||
/// in the media caption.
|
/// inline URLs] in the media caption.
|
||||||
///
|
///
|
||||||
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
||||||
/// [Html]: crate::core::types::ParseMode::Html
|
/// [Html]: crate::core::types::ParseMode::Html
|
||||||
/// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode
|
/// [bold, italic, fixed-width text or inline URLs]:
|
||||||
|
/// crate::core::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
|
||||||
|
@ -129,14 +134,14 @@ pub enum InputMedia {
|
||||||
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.
|
||||||
Document {
|
Document {
|
||||||
/// File to send.
|
/// File to send.
|
||||||
media: InputFile,
|
media: InputFile,
|
||||||
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is
|
/// Thumbnail of the file sent; can be ignored if thumbnail generation
|
||||||
/// supported server-side.
|
/// for the file is supported server-side.
|
||||||
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
/// The thumbnail should be in JPEG format and less than 200 kB in size.
|
||||||
/// A thumbnail‘s width and height should not exceed 320.
|
/// A thumbnail‘s width and height should not exceed 320.
|
||||||
/// Ignored if the file is not uploaded using [InputFile::File].
|
/// Ignored if the file is not uploaded using [InputFile::File].
|
||||||
|
@ -148,12 +153,13 @@ pub enum InputMedia {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
caption: Option<String>,
|
caption: Option<String>,
|
||||||
/// Send [Markdown] or [HTML],
|
/// Send [Markdown] or [HTML],
|
||||||
/// if you want Telegram apps to show [bold, italic, fixed-width text or inline URLs]
|
/// if you want Telegram apps to show [bold, italic, fixed-width text or
|
||||||
/// in the media caption.
|
/// inline URLs] in the media caption.
|
||||||
///
|
///
|
||||||
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
/// [Markdown]: crate::core::types::ParseMode::Markdown
|
||||||
/// [Html]: crate::core::types::ParseMode::Html
|
/// [Html]: crate::core::types::ParseMode::Html
|
||||||
/// [bold, italic, fixed-width text or inline URLs]: crate::core::types::ParseMode
|
/// [bold, italic, fixed-width text or inline URLs]:
|
||||||
|
/// crate::core::types::ParseMode
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
parse_mode: Option<ParseMode>,
|
parse_mode: Option<ParseMode>,
|
||||||
},
|
},
|
||||||
|
@ -221,7 +227,7 @@ mod tests {
|
||||||
parse_mode: None,
|
parse_mode: None,
|
||||||
duration: None,
|
duration: None,
|
||||||
performer: None,
|
performer: None,
|
||||||
title: None
|
title: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let actual_json = serde_json::to_string(&video).unwrap();
|
let actual_json = serde_json::to_string(&video).unwrap();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/// This object represents one button of the reply keyboard.
|
/// This object represents one button of the reply keyboard.
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct KeyboardButton {
|
pub struct KeyboardButton {
|
||||||
text: String,
|
pub text: String,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
request_contact: bool,
|
pub request_contact: bool,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
request_location: bool,
|
pub request_location: bool,
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ use serde::{Serialization, Deserialization};
|
||||||
/// This object represents a point on the map.
|
/// This object represents a point on the map.
|
||||||
struct Location {
|
struct Location {
|
||||||
/// Longitude as defined by sender
|
/// Longitude as defined by sender
|
||||||
longitude: f64,
|
pub longitude: f64,
|
||||||
/// Latitude as defined by sender
|
/// Latitude as defined by sender
|
||||||
latitude: f64,
|
pub latitude: f64,
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct LoginUrl {
|
pub struct LoginUrl {
|
||||||
url: String,
|
pub url: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
forward_text: Option<String>,
|
pub forward_text: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
bot_username: Option<String>,
|
pub bot_username: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
request_write_access: Option<bool>,
|
pub request_write_access: Option<bool>,
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::core::types::User;
|
use crate::core::types::User;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
pub struct MessageEntity {
|
pub struct MessageEntity {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
@ -9,7 +8,6 @@ pub struct MessageEntity {
|
||||||
pub length: usize,
|
pub length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
|
|
|
@ -1,49 +1,34 @@
|
||||||
use self::not_implemented_types::*;
|
use self::not_implemented_types::*;
|
||||||
|
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
answer_pre_checkout_query::AnswerPreCheckoutQuery,
|
answer_pre_checkout_query::AnswerPreCheckoutQuery, answer_shipping_query::AnswerShippingQuery,
|
||||||
answer_shipping_query::AnswerShippingQuery,
|
audio::Audio, chat::Chat, chat_member::ChatMember, chat_permissions::ChatPermissions,
|
||||||
audio::Audio,
|
chat_photo::ChatPhoto, document::Document, input_file::InputFile, input_media::InputMedia,
|
||||||
chat::Chat,
|
invoice::Invoice, label_price::LabeledPrice, message::Message, message_entity::MessageEntity,
|
||||||
chat_permissions::ChatPermissions,
|
order_info::OrderInfo, parse_mode::ParseMode, photo_size::PhotoSize,
|
||||||
chat_photo::ChatPhoto,
|
pre_checkout_query::PreCheckoutQuery, send_invoice::SendInvoice,
|
||||||
chat_member::ChatMember,
|
shipping_address::ShippingAddress, shipping_option::ShippingOption,
|
||||||
document::Document,
|
shipping_query::ShippingQuery, sticker::Sticker, successful_payment::SuccessfulPayment,
|
||||||
invoice::Invoice,
|
user::User, video::Video,
|
||||||
label_price::LabeledPrice,
|
|
||||||
message::Message,
|
|
||||||
message_entity::MessageEntity,
|
|
||||||
order_info::OrderInfo,
|
|
||||||
photo_size::PhotoSize,
|
|
||||||
pre_checkout_query::PreCheckoutQuery,
|
|
||||||
send_invoice::SendInvoice,
|
|
||||||
shipping_address::ShippingAddress,
|
|
||||||
shipping_option::ShippingOption,
|
|
||||||
shipping_query::ShippingQuery,
|
|
||||||
sticker::Sticker,
|
|
||||||
successful_payment::SuccessfulPayment,
|
|
||||||
user::User,
|
|
||||||
input_file::InputFile,
|
|
||||||
input_media::InputMedia,
|
|
||||||
parse_mode::ParseMode,
|
|
||||||
video::Video
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod answer_pre_checkout_query;
|
mod answer_pre_checkout_query;
|
||||||
mod answer_shipping_query;
|
mod answer_shipping_query;
|
||||||
mod audio;
|
mod audio;
|
||||||
mod chat;
|
mod chat;
|
||||||
|
mod chat_member;
|
||||||
mod chat_permissions;
|
mod chat_permissions;
|
||||||
mod chat_photo;
|
mod chat_photo;
|
||||||
mod chat_member;
|
|
||||||
mod document;
|
mod document;
|
||||||
|
mod input_file;
|
||||||
|
mod input_media;
|
||||||
mod invoice;
|
mod invoice;
|
||||||
mod label_price;
|
mod label_price;
|
||||||
mod message;
|
mod message;
|
||||||
mod message_entity;
|
mod message_entity;
|
||||||
mod not_implemented_types;
|
mod not_implemented_types;
|
||||||
mod order_info;
|
mod order_info;
|
||||||
|
mod parse_mode;
|
||||||
mod photo_size;
|
mod photo_size;
|
||||||
mod pre_checkout_query;
|
mod pre_checkout_query;
|
||||||
mod send_invoice;
|
mod send_invoice;
|
||||||
|
@ -53,7 +38,4 @@ mod shipping_query;
|
||||||
mod sticker;
|
mod sticker;
|
||||||
mod successful_payment;
|
mod successful_payment;
|
||||||
mod user;
|
mod user;
|
||||||
mod input_file;
|
|
||||||
mod input_media;
|
|
||||||
mod parse_mode;
|
|
||||||
mod video;
|
mod video;
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
/// ## 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) and `pre-formatted code` in
|
||||||
/// your bots' messages. Telegram clients will render them accordingly. You can use either
|
/// your bots' messages. Telegram clients will render them accordingly. You can
|
||||||
/// markdown-style or HTML-style formatting.
|
/// use either markdown-style or HTML-style formatting.
|
||||||
///
|
///
|
||||||
/// Note that Telegram clients will display an alert to the user before opening an inline link
|
/// Note that Telegram clients will display an alert to the user before opening
|
||||||
/// (‘Open this link?’ together with the full URL).
|
/// an inline link (‘Open this link?’ together with the full URL).
|
||||||
///
|
///
|
||||||
/// Links `tg://user?id=<user_id>` can be used to mention a user by their id without using a username.
|
/// Links `tg://user?id=<user_id>` can be used to mention a user by their id
|
||||||
/// Please note:
|
/// without using a username. Please note:
|
||||||
///
|
///
|
||||||
/// - These links will work only if they are used inside an inline link.
|
/// - These links will work only if they are used inside an inline link. For
|
||||||
/// For example, they will not work, when used in an inline keyboard button or in a message text.
|
/// example, they will not work, when used in an inline keyboard button or in
|
||||||
/// - The mentions are only guaranteed to work if: **A**. the user is a member in the group where he
|
/// a message text.
|
||||||
/// was mentioned or **B**. the user has contacted the bot in the past or has sent a callback
|
/// - The mentions are only guaranteed to work if: **A**. the user is a member
|
||||||
/// query to the bot via inline button and has not restricted linking to their account in
|
/// in the group where he was mentioned or **B**. the user has contacted the
|
||||||
/// `Settings > Privacy & Security > Forwarded Messages`.
|
/// bot in the past or has sent a callback query to the bot via inline button
|
||||||
|
/// and has not restricted linking to their account in `Settings > Privacy &
|
||||||
|
/// Security > Forwarded Messages`.
|
||||||
///
|
///
|
||||||
/// ## Markdown style
|
/// ## Markdown style
|
||||||
/// To use this mode, pass [Markdown] in the `parse_mode` field when using [SendMessage] (or other methods).
|
/// To use this mode, pass [Markdown] in the `parse_mode` field when using
|
||||||
|
/// [SendMessage] (or other methods).
|
||||||
///
|
///
|
||||||
/// Use the following syntax in your message:
|
/// Use the following syntax in your message:
|
||||||
///
|
///
|
||||||
|
@ -37,7 +40,8 @@ use serde::{Serialize, Deserialize};
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## HTML style
|
/// ## HTML style
|
||||||
/// To use this mode, pass [HTML] in the `parse_mode` field when using [SendMessage] (or other methods).
|
/// To use this mode, pass [HTML] in the `parse_mode` field when using
|
||||||
|
/// [SendMessage] (or other methods).
|
||||||
///
|
///
|
||||||
/// The following tags are currently supported:
|
/// The following tags are currently supported:
|
||||||
///
|
///
|
||||||
|
@ -54,9 +58,12 @@ use serde::{Serialize, Deserialize};
|
||||||
///
|
///
|
||||||
/// - Only the tags mentioned above are currently supported.
|
/// - Only the tags mentioned above are currently supported.
|
||||||
/// - Tags must not be nested.
|
/// - Tags must not be nested.
|
||||||
/// - All `<`, `>` and `&` symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (`<` with `<`, `>` with `>` and `&` with `&`).
|
/// - All `<`, `>` and `&` symbols that are not a part of a tag or an HTML
|
||||||
|
/// entity must be replaced with the corresponding HTML entities (`<` with
|
||||||
|
/// `<`, `>` with `>` and `&` with `&`).
|
||||||
/// - All numerical HTML entities are supported.
|
/// - All numerical HTML entities are supported.
|
||||||
/// - The API currently supports only the following named HTML entities: `<`, `>`, `&` and `"`.
|
/// - The API currently supports only the following named HTML entities: `<`,
|
||||||
|
/// `>`, `&` and `"`.
|
||||||
pub enum ParseMode {
|
pub enum ParseMode {
|
||||||
HTML,
|
HTML,
|
||||||
Markdown,
|
Markdown,
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
pub struct PhotoSize {
|
pub struct PhotoSize {
|
||||||
pub file_id: String,
|
pub file_id: String,
|
||||||
pub width: i32,
|
pub width: i32,
|
||||||
pub heigth: i32,
|
pub height: i32,
|
||||||
pub file_size: Option<u32>
|
pub file_size: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/// This object represents a custom keyboard with reply options.
|
/// This object represents a custom keyboard with reply options.
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct ReplyKeyboardMarkup {
|
pub struct ReplyKeyboardMarkup {
|
||||||
keyboard: Vec<Vec<KeyboardButton>>,
|
pub keyboard: Vec<Vec<KeyboardButton>>,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
resize_keyboard: bool,
|
pub resize_keyboard: bool,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
one_time_keyboard: bool,
|
pub one_time_keyboard: bool,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
selective: bool,
|
pub selective: bool,
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
/// immediately after the user presses a button (see ReplyKeyboardMarkup).
|
/// immediately after the user presses a button (see ReplyKeyboardMarkup).
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct ReplyKeyboardRemove {
|
pub struct ReplyKeyboardRemove {
|
||||||
remove_keyboard: True,
|
pub remove_keyboard: True,
|
||||||
#[serde(skip_serializing_if = "Not::not")]
|
#[serde(skip_serializing_if = "Not::not")]
|
||||||
selective: bool,
|
pub selective: bool,
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||||
pub struct ResponseParameters {
|
pub struct ResponseParameters {
|
||||||
migrate_to_chat_id: Option<i64>,
|
pub migrate_to_chat_id: Option<i64>,
|
||||||
retry_after: Option<i64>,
|
pub retry_after: Option<i64>,
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::core::types::PhotoSize;
|
use crate::core::types::PhotoSize;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||||
pub struct Video {
|
pub struct Video {
|
||||||
pub file_id: String,
|
pub file_id: String,
|
||||||
|
@ -9,5 +8,5 @@ pub struct Video {
|
||||||
pub duration: u32,
|
pub duration: u32,
|
||||||
pub thumb: Option<PhotoSize>,
|
pub thumb: Option<PhotoSize>,
|
||||||
pub mime_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
pub file_size: Option<u32>
|
pub file_size: Option<u32>,
|
||||||
}
|
}
|
|
@ -5,13 +5,13 @@ use serde::Deserialize;
|
||||||
/// (available in Telegram apps as of v.4.0).
|
/// (available in Telegram apps as of v.4.0).
|
||||||
struct VideoNote {
|
struct VideoNote {
|
||||||
/// Identifier for this file
|
/// Identifier for this file
|
||||||
file_id: String,
|
pub file_id: String,
|
||||||
/// Video width and height (diameter of the video message) as defined by sender
|
/// Video width and height (diameter of the video message) as defined by sender
|
||||||
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
|
||||||
duration: u32,
|
pub duration: u32,
|
||||||
/// Optional. Video thumbnail
|
/// Optional. Video thumbnail
|
||||||
thumb: Option<PhotoSize>,
|
pub thumb: Option<PhotoSize>,
|
||||||
/// Optional. File size
|
/// Optional. File size
|
||||||
file_size: Option<u32>,
|
pub file_size: Option<u32>,
|
||||||
}
|
}
|
|
@ -4,11 +4,11 @@ use serde::Deserialize;
|
||||||
/// This object represents a voice note.
|
/// This object represents a voice note.
|
||||||
struct Voice {
|
struct Voice {
|
||||||
/// Identifier for this file
|
/// Identifier for this file
|
||||||
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
|
||||||
duration: u32,
|
pub duration: u32,
|
||||||
/// Optional. MIME type of the file as defined by sender
|
/// Optional. MIME type of the file as defined by sender
|
||||||
mime_type: Option<String>,
|
pub mime_type: Option<String>,
|
||||||
/// Optional. File size
|
/// Optional. File size
|
||||||
file_size: Option<u64>
|
pub file_size: Option<u64>
|
||||||
}
|
}
|
Loading…
Reference in a new issue