├── .gitignore ├── src ├── raw │ ├── mod.rs │ ├── types │ │ ├── enums │ │ │ ├── chat_id_or_username.rs │ │ │ ├── message_or_true.rs │ │ │ ├── input_file_or_string.rs │ │ │ ├── input_media_photo_or_input_media_video.rs │ │ │ ├── reply_markup.rs │ │ │ ├── input_media.rs │ │ │ ├── input_message_content.rs │ │ │ ├── passport_element_error.rs │ │ │ ├── mod.rs │ │ │ └── inline_query_result.rs │ │ ├── location.rs │ │ ├── poll_option.rs │ │ ├── game_high_score.rs │ │ ├── user_profile_photos.rs │ │ ├── shipping_option.rs │ │ ├── poll.rs │ │ ├── sticker_set.rs │ │ ├── chat_photo.rs │ │ ├── inline_keyboard_markup.rs │ │ ├── passport_data.rs │ │ ├── passport_file.rs │ │ ├── shipping_query.rs │ │ ├── photo_size.rs │ │ ├── shipping_address.rs │ │ ├── labeled_price.rs │ │ ├── voice.rs │ │ ├── inline_query_result_game.rs │ │ ├── input_location_message_content.rs │ │ ├── passport_element_error_unspecified.rs │ │ ├── order_info.rs │ │ ├── input_contact_message_content.rs │ │ ├── venue.rs │ │ ├── passport_element_error_selfie.rs │ │ ├── contact.rs │ │ ├── passport_element_error_file.rs │ │ ├── inline_query.rs │ │ ├── video_note.rs │ │ ├── input_text_message_content.rs │ │ ├── passport_element_error_reverse_side.rs │ │ ├── encrypted_credentials.rs │ │ ├── passport_element_error_files.rs │ │ ├── passport_element_error_front_side.rs │ │ ├── user.rs │ │ ├── invoice.rs │ │ ├── file.rs │ │ ├── document.rs │ │ ├── passport_element_error_data_field.rs │ │ ├── passport_element_error_translation_file.rs │ │ ├── response_parameters.rs │ │ ├── passport_element_error_translation_files.rs │ │ ├── video.rs │ │ ├── force_reply.rs │ │ ├── keyboard_button.rs │ │ ├── input_venue_message_content.rs │ │ ├── chosen_inline_result.rs │ │ ├── mask_position.rs │ │ ├── input_media_photo.rs │ │ ├── inline_query_result_cached_sticker.rs │ │ ├── message_entity.rs │ │ ├── sticker.rs │ │ ├── animation.rs │ │ ├── pre_checkout_query.rs │ │ ├── audio.rs │ │ ├── successful_payment.rs │ │ ├── game.rs │ │ ├── reply_keyboard_remove.rs │ │ ├── webhook_info.rs │ │ ├── inline_query_result_cached_audio.rs │ │ ├── inline_query_result_cached_voice.rs │ │ ├── inline_query_result_article.rs │ │ ├── inline_query_result_cached_gif.rs │ │ ├── inline_query_result_voice.rs │ │ ├── input_media_document.rs │ │ ├── reply_keyboard_markup.rs │ │ ├── inline_query_result_cached_document.rs │ │ ├── inline_query_result_cached_mpeg4_gif.rs │ │ ├── inline_query_result_cached_video.rs │ │ ├── callback_query.rs │ │ ├── inline_query_result_audio.rs │ │ ├── inline_query_result_cached_photo.rs │ │ ├── inline_query_result_location.rs │ │ ├── inline_query_result_contact.rs │ │ ├── login_url.rs │ │ ├── inline_query_result_venue.rs │ │ ├── input_media_audio.rs │ │ ├── inline_query_result_photo.rs │ │ ├── inline_query_result_gif.rs │ │ ├── input_media_animation.rs │ │ ├── inline_query_result_mpeg4_gif.rs │ │ └── input_media_video.rs │ └── methods │ │ ├── get_sticker_set.rs │ │ ├── delete_sticker_from_set.rs │ │ ├── leave_chat.rs │ │ ├── get_chat_members_count.rs │ │ ├── set_sticker_position_in_set.rs │ │ ├── get_chat.rs │ │ ├── get_chat_member.rs │ │ ├── export_chat_invite_link.rs │ │ ├── unpin_chat_message.rs │ │ ├── delete_chat_sticker_set.rs │ │ ├── get_chat_administrators.rs │ │ ├── upload_sticker_file.rs │ │ ├── unban_chat_member.rs │ │ ├── delete_chat_photo.rs │ │ ├── get_file.rs │ │ ├── set_chat_description.rs │ │ ├── stop_poll.rs │ │ ├── set_chat_sticker_set.rs │ │ ├── set_chat_title.rs │ │ ├── get_user_profile_photos.rs │ │ ├── set_chat_photo.rs │ │ ├── forward_message.rs │ │ ├── pin_chat_message.rs │ │ ├── set_passport_data_errors.rs │ │ ├── delete_message.rs │ │ ├── send_media_group.rs │ │ ├── send_game.rs │ │ ├── add_sticker_to_set.rs │ │ ├── edit_message_reply_markup.rs │ │ ├── stop_message_live_location.rs │ │ ├── answer_pre_checkout_query.rs │ │ ├── answer_shipping_query.rs │ │ ├── get_game_high_scores.rs │ │ ├── kick_chat_member.rs │ │ ├── send_poll.rs │ │ ├── send_chat_action.rs │ │ ├── send_sticker.rs │ │ ├── send_location.rs │ │ ├── edit_message_live_location.rs │ │ ├── send_contact.rs │ │ ├── send_message.rs │ │ ├── edit_message_caption.rs │ │ ├── edit_message_media.rs │ │ ├── set_game_score.rs │ │ ├── edit_message_text.rs │ │ ├── create_new_sticker_set.rs │ │ ├── send_venue.rs │ │ ├── send_photo.rs │ │ ├── restrict_chat_member.rs │ │ ├── answer_callback_query.rs │ │ ├── get_updates.rs │ │ ├── set_webhook.rs │ │ └── send_voice.rs ├── types │ ├── enums │ │ ├── mod.rs │ │ └── chat_id_or_username.rs │ ├── input_text_message_content.rs │ ├── message.rs │ ├── input_media_photo.rs │ ├── inline_query_result_cached_audio.rs │ ├── inline_query_result_cached_voice.rs │ ├── inline_query_result_cached_gif.rs │ ├── input_media_document.rs │ ├── inline_query_result_voice.rs │ ├── inline_query_result_cached_document.rs │ ├── inline_query_result_cached_mpeg4_gif.rs │ ├── inline_query_result_cached_video.rs │ ├── inline_query_result_audio.rs │ ├── inline_query_result_cached_photo.rs │ ├── input_media_audio.rs │ ├── input_media_animation.rs │ ├── inline_query_result_photo.rs │ └── inline_query_result_gif.rs ├── methods │ ├── get_me.rs │ ├── delete_webhook.rs │ ├── get_webhook_info.rs │ ├── mod.rs │ ├── send_message.rs │ ├── edit_message_caption.rs │ ├── edit_message_text.rs │ └── send_photo.rs ├── actors │ ├── mod.rs │ ├── telegram_server │ │ └── types.rs │ └── telegram_worker.rs ├── lib.rs └── application │ └── resourse.rs ├── actix-telegram-derive ├── Cargo.toml └── src │ └── types.rs ├── README.md ├── examples └── client.rs ├── Cargo.toml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /src/raw/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod methods; 2 | #[allow(unused_imports, dead_code)] 3 | pub mod types; 4 | -------------------------------------------------------------------------------- /src/types/enums/mod.rs: -------------------------------------------------------------------------------- 1 | mod chat_id_or_username; 2 | 3 | pub use self::chat_id_or_username::ChatIdOrUsername; 4 | -------------------------------------------------------------------------------- /src/methods/get_me.rs: -------------------------------------------------------------------------------- 1 | use crate::types::User; 2 | 3 | #[derive(Serialize, Debug, TelegramApi)] 4 | #[return_type = "User"] 5 | pub struct GetMe; 6 | -------------------------------------------------------------------------------- /src/methods/delete_webhook.rs: -------------------------------------------------------------------------------- 1 | use crate::types::True; 2 | 3 | #[derive(Serialize, Debug, TelegramApi)] 4 | #[return_type = "True"] 5 | pub struct DeleteWebhook; 6 | -------------------------------------------------------------------------------- /src/methods/get_webhook_info.rs: -------------------------------------------------------------------------------- 1 | use crate::types::WebhookInfo; 2 | 3 | #[derive(Serialize, Debug, TelegramApi)] 4 | #[return_type = "WebhookInfo"] 5 | pub struct GetWebhookInfo; 6 | -------------------------------------------------------------------------------- /src/raw/types/enums/chat_id_or_username.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum ChatIdOrUsername { 6 | Id(Integer), 7 | Username(String), 8 | } -------------------------------------------------------------------------------- /src/raw/types/enums/message_or_true.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Deserialize, Clone)] 4 | #[serde(untagged)] 5 | pub enum MessageOrTrue { 6 | Message(Message), 7 | True(True), 8 | } -------------------------------------------------------------------------------- /src/raw/types/enums/input_file_or_string.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum InputFileOrString { 6 | InputFile(InputFile), 7 | String(String), 8 | } -------------------------------------------------------------------------------- /src/raw/types/enums/input_media_photo_or_input_media_video.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum InputMediaPhotoOrInputMediaVideo { 6 | InputMediaPhoto(InputMediaPhoto), 7 | InputMediaVideo(InputMediaVideo), 8 | } -------------------------------------------------------------------------------- /src/raw/types/enums/reply_markup.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum ReplyMarkup { 6 | InlineKeyboardMarkup(InlineKeyboardMarkup), 7 | ReplyKeyboardMarkup(ReplyKeyboardMarkup), 8 | ReplyKeyboardRemove(ReplyKeyboardRemove), 9 | ForceReply(ForceReply), 10 | } -------------------------------------------------------------------------------- /src/raw/types/location.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a point on the map. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Location { 7 | /// Longitude as defined by sender 8 | pub(crate) longitude: Float, 9 | /// Latitude as defined by sender 10 | pub(crate) latitude: Float, 11 | } -------------------------------------------------------------------------------- /src/raw/types/enums/input_media.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum InputMedia { 6 | InputMediaAnimation(InputMediaAnimation), 7 | InputMediaDocument(InputMediaDocument), 8 | InputMediaAudio(InputMediaAudio), 9 | InputMediaPhoto(InputMediaPhoto), 10 | InputMediaVideo(InputMediaVideo), 11 | } -------------------------------------------------------------------------------- /src/actors/mod.rs: -------------------------------------------------------------------------------- 1 | mod telegram_api; 2 | mod telegram_bot; 3 | #[cfg(feature = "server")] 4 | pub mod telegram_server; 5 | mod telegram_worker; 6 | 7 | pub use self::telegram_api::TelegramApi; 8 | pub use self::telegram_bot::TelegramBot; 9 | #[cfg(feature = "server")] 10 | pub use self::telegram_server::TelegramServer; 11 | pub use self::telegram_worker::TelegramWorker; 12 | -------------------------------------------------------------------------------- /src/raw/methods/get_sticker_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get a sticker set. On success, a StickerSet object is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "StickerSet"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetStickerSet { 9 | /// Name of the sticker set 10 | pub(crate) name: String, 11 | } -------------------------------------------------------------------------------- /actix-telegram-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "actix-telegram-derive" 3 | version = "0.2.2" 4 | authors = ["Marat Safin "] 5 | description = "derive for actix-telegram" 6 | repository = "https://github.com/jeizsm/actix-telegram" 7 | license = "MIT" 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | syn = "0.15" 14 | quote = "0.6" 15 | proc-macro2 = "0.4" 16 | -------------------------------------------------------------------------------- /src/raw/types/enums/input_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum InputMessageContent { 6 | InputTextMessageContent(InputTextMessageContent), 7 | InputLocationMessageContent(InputLocationMessageContent), 8 | InputVenueMessageContent(InputVenueMessageContent), 9 | InputContactMessageContent(InputContactMessageContent), 10 | } -------------------------------------------------------------------------------- /src/raw/types/poll_option.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains information about one answer option in a poll. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct PollOption { 7 | /// Option text, 1-100 characters 8 | pub(crate) text: String, 9 | /// Number of users that voted for this option 10 | pub(crate) voter_count: Integer, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/delete_sticker_from_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to delete a sticker from a set created by the bot. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct DeleteStickerFromSet { 9 | /// File identifier of the sticker 10 | pub(crate) sticker: String, 11 | } -------------------------------------------------------------------------------- /src/raw/types/game_high_score.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents one row of the high scores table for a game. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct GameHighScore { 7 | /// Position in high score table for the game 8 | pub(crate) position: Integer, 9 | /// User 10 | pub(crate) user: User, 11 | /// Score 12 | pub(crate) score: Integer, 13 | } -------------------------------------------------------------------------------- /src/raw/types/user_profile_photos.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represent a user's profile pictures. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct UserProfilePhotos { 7 | /// Total number of profile pictures the target user has 8 | pub(crate) total_count: Integer, 9 | /// Requested profile pictures (in up to 4 sizes each) 10 | pub(crate) photos: Vec>, 11 | } -------------------------------------------------------------------------------- /src/raw/types/shipping_option.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents one shipping option. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct ShippingOption { 8 | /// Shipping option identifier 9 | pub(crate) id: String, 10 | /// Option title 11 | pub(crate) title: String, 12 | /// List of price portions 13 | pub(crate) prices: Vec, 14 | } -------------------------------------------------------------------------------- /src/raw/methods/leave_chat.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method for your bot to leave a group, supergroup or channel. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct LeaveChat { 9 | /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/get_chat_members_count.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get the number of members in a chat. Returns Int on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Integer"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetChatMembersCount { 9 | /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/types/poll.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains information about a poll. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Poll { 7 | /// Unique poll identifier 8 | pub(crate) id: String, 9 | /// Poll question, 1-255 characters 10 | pub(crate) question: String, 11 | /// List of poll options 12 | pub(crate) options: Vec, 13 | /// True, if the poll is closed 14 | pub(crate) is_closed: bool, 15 | } -------------------------------------------------------------------------------- /src/raw/types/sticker_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a sticker set. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct StickerSet { 7 | /// Sticker set name 8 | pub(crate) name: String, 9 | /// Sticker set title 10 | pub(crate) title: String, 11 | /// True, if the sticker set contains masks 12 | pub(crate) contains_masks: bool, 13 | /// List of all set stickers 14 | pub(crate) stickers: Vec, 15 | } -------------------------------------------------------------------------------- /src/raw/types/chat_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a chat photo. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct ChatPhoto { 7 | /// Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download. 8 | pub(crate) small_file_id: String, 9 | /// Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. 10 | pub(crate) big_file_id: String, 11 | } -------------------------------------------------------------------------------- /src/raw/types/inline_keyboard_markup.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents an inline keyboard that appears right next to the message it belongs to. 4 | #[derive(Debug, Deserialize, Clone, Getters, Serialize, Setters, New)] 5 | #[get(vis = "pub")] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct InlineKeyboardMarkup { 9 | /// Array of button rows, each represented by an Array of InlineKeyboardButton objects 10 | pub(crate) inline_keyboard: Vec>, 11 | } -------------------------------------------------------------------------------- /src/types/enums/chat_id_or_username.rs: -------------------------------------------------------------------------------- 1 | use crate::types::Integer; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum ChatIdOrUsername { 6 | Id(Integer), 7 | Username(String), 8 | } 9 | 10 | impl From for ChatIdOrUsername { 11 | fn from(number: i64) -> Self { 12 | ChatIdOrUsername::Id(number) 13 | } 14 | } 15 | 16 | impl From for ChatIdOrUsername { 17 | fn from(username: String) -> Self { 18 | ChatIdOrUsername::Username(username) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/raw/types/passport_data.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Contains information about Telegram Passport data shared with the bot by the user. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct PassportData { 7 | /// Array with information about documents and other Telegram Passport elements that was shared with the bot 8 | pub(crate) data: Vec, 9 | /// Encrypted credentials required to decrypt the data 10 | pub(crate) credentials: EncryptedCredentials, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/set_sticker_position_in_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SetStickerPositionInSet { 9 | /// File identifier of the sticker 10 | pub(crate) sticker: String, 11 | /// New sticker position in the set, zero-based 12 | pub(crate) position: Integer, 13 | } -------------------------------------------------------------------------------- /src/raw/types/passport_file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct PassportFile { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// File size 10 | pub(crate) file_size: Integer, 11 | /// Unix time when the file was uploaded 12 | pub(crate) file_date: Integer, 13 | } -------------------------------------------------------------------------------- /src/raw/types/shipping_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains information about an incoming shipping query. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct ShippingQuery { 7 | /// Unique query identifier 8 | pub(crate) id: String, 9 | /// User who sent the query 10 | pub(crate) from: User, 11 | /// Bot specified invoice payload 12 | pub(crate) invoice_payload: String, 13 | /// User specified shipping address 14 | pub(crate) shipping_address: ShippingAddress, 15 | } -------------------------------------------------------------------------------- /src/raw/types/photo_size.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents one size of a photo or a file / sticker thumbnail. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct PhotoSize { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Photo width 10 | pub(crate) width: Integer, 11 | /// Photo height 12 | pub(crate) height: Integer, 13 | /// File size 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) file_size: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/methods/get_chat.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Chat"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetChat { 9 | /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/get_chat_member.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get information about a member of a chat. Returns a ChatMember object on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "ChatMember"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetChatMember { 9 | /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Unique identifier of the target user 12 | pub(crate) user_id: Integer, 13 | } -------------------------------------------------------------------------------- /actix-telegram-derive/src/types.rs: -------------------------------------------------------------------------------- 1 | use syn::Meta; 2 | 3 | #[derive(Debug)] 4 | pub struct MetaAttributes { 5 | pub vis: Option, 6 | pub prefix: Option, 7 | pub suffix: Option, 8 | pub mutable: bool, 9 | pub copy: bool, 10 | pub consume: bool, 11 | pub optional: bool, 12 | } 13 | 14 | pub struct GenParams { 15 | pub attribute_name: &'static str, 16 | pub fn_name_prefix: Option<&'static str>, 17 | pub fn_name_suffix: Option<&'static str>, 18 | pub global_attr: Vec, 19 | } 20 | 21 | pub enum GenMode { 22 | Get, 23 | Set, 24 | GetMut, 25 | } 26 | -------------------------------------------------------------------------------- /src/raw/types/shipping_address.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a shipping address. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct ShippingAddress { 7 | /// ISO 3166-1 alpha-2 country code 8 | pub(crate) country_code: String, 9 | /// State, if applicable 10 | pub(crate) state: String, 11 | /// City 12 | pub(crate) city: String, 13 | /// First line for the address 14 | pub(crate) street_line1: String, 15 | /// Second line for the address 16 | pub(crate) street_line2: String, 17 | /// Address post code 18 | pub(crate) post_code: String, 19 | } -------------------------------------------------------------------------------- /src/raw/types/labeled_price.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a portion of the price for goods or services. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct LabeledPrice { 8 | /// Portion label 9 | pub(crate) label: String, 10 | /// Price of the product 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). 11 | pub(crate) amount: Integer, 12 | } -------------------------------------------------------------------------------- /src/raw/types/voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a voice note. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Voice { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Duration of the audio in seconds as defined by sender 10 | pub(crate) duration: Integer, 11 | /// MIME type of the file as defined by sender 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) mime_type: Option, 14 | /// File size 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) file_size: Option, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/export_chat_invite_link.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "String"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct ExportChatInviteLink { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/unpin_chat_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct UnpinChatMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_game.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a Game. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultGame { 8 | /// Type of the result, must be game 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// Short name of the game 14 | pub(crate) game_short_name: String, 15 | /// Inline keyboard attached to the message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) reply_markup: Option, 18 | } -------------------------------------------------------------------------------- /src/raw/types/input_location_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents the content of a location message to be sent as the result of an inline query. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputLocationMessageContent { 8 | /// Latitude of the location in degrees 9 | pub(crate) latitude: Float, 10 | /// Longitude of the location in degrees 11 | pub(crate) longitude: Float, 12 | /// Period in seconds for which the location can be updated, should be between 60 and 86400. 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) live_period: Option, 15 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_unspecified.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue in an unspecified place. The error is considered resolved when new data is added. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorUnspecified { 8 | /// Error source, must be unspecified 9 | pub(crate) source: String, 10 | /// Type of element of the user's Telegram Passport which has the issue 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded element hash 14 | pub(crate) element_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/delete_chat_sticker_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct DeleteChatStickerSet { 9 | /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/get_chat_administrators.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Vec"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetChatAdministrators { 9 | /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/upload_sticker_file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "File"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct UploadStickerFile { 9 | /// User identifier of sticker file owner 10 | pub(crate) user_id: Integer, 11 | /// Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. More info on Sending Files » 12 | pub(crate) png_sticker: InputFile, 13 | } -------------------------------------------------------------------------------- /src/raw/methods/unban_chat_member.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct UnbanChatMember { 9 | /// Unique identifier for the target group or username of the target supergroup or channel (in the format @username) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Unique identifier of the target user 12 | pub(crate) user_id: Integer, 13 | } -------------------------------------------------------------------------------- /src/raw/types/order_info.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents information about an order. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct OrderInfo { 7 | /// User name 8 | #[serde(skip_serializing_if = "Option::is_none")] 9 | pub(crate) name: Option, 10 | /// User's phone number 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) phone_number: Option, 13 | /// User email 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) email: Option, 16 | /// User shipping address 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) shipping_address: Option, 19 | } -------------------------------------------------------------------------------- /src/actors/telegram_server/types.rs: -------------------------------------------------------------------------------- 1 | use crate::actors::TelegramApi; 2 | use crate::application::UpdateHandler; 3 | use actix::Addr; 4 | 5 | bitflags! { 6 | pub(crate) struct OptionFlags: u8 { 7 | const SEND_SET_WEBHOOK = 0b0000_0001; 8 | #[cfg(feature = "tls-server")] 9 | const SELF_SIGNED = 0b0000_0010; 10 | } 11 | } 12 | 13 | impl Default for OptionFlags { 14 | fn default() -> Self { 15 | Self::new() 16 | } 17 | } 18 | 19 | impl OptionFlags { 20 | fn new() -> Self { 21 | OptionFlags::SEND_SET_WEBHOOK 22 | } 23 | } 24 | 25 | pub(super) struct ReqState 26 | where 27 | H: UpdateHandler + 'static, 28 | { 29 | pub(super) telegram_api: Addr, 30 | pub(super) apps: H, 31 | } 32 | -------------------------------------------------------------------------------- /src/raw/methods/delete_chat_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. 4 | /// 5 | /// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "True"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct DeleteChatPhoto { 11 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 12 | pub(crate) chat_id: ChatIdOrUsername, 13 | } -------------------------------------------------------------------------------- /src/raw/methods/get_file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. 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 getFile again. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "File"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetFile { 9 | /// File identifier to get info about 10 | pub(crate) file_id: String, 11 | } -------------------------------------------------------------------------------- /src/raw/methods/set_chat_description.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SetChatDescription { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// New chat description, 0-255 characters 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) description: Option, 14 | } -------------------------------------------------------------------------------- /src/raw/types/input_contact_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents the content of a contact message to be sent as the result of an inline query. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputContactMessageContent { 8 | /// Contact's phone number 9 | pub(crate) phone_number: String, 10 | /// Contact's first name 11 | pub(crate) first_name: String, 12 | /// Contact's last name 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) last_name: Option, 15 | /// Additional data about the contact in the form of a vCard, 0-2048 bytes 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) vcard: Option, 18 | } -------------------------------------------------------------------------------- /src/raw/types/venue.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a venue. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Venue { 7 | /// Venue location 8 | pub(crate) location: Location, 9 | /// Name of the venue 10 | pub(crate) title: String, 11 | /// Address of the venue 12 | pub(crate) address: String, 13 | /// Foursquare identifier of the venue 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) foursquare_id: Option, 16 | /// Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) foursquare_type: Option, 19 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Rust telegram bot library 2 | 3 | [![Crates.io](https://img.shields.io/crates/v/actix-telegram.svg)](https://crates.io/crates/actix-telegram) 4 | [![Docs.rs](https://docs.rs/actix-telegram/badge.svg)](https://docs.rs/actix-telegram/) 5 | 6 | A rust library for writing telegram bot built on top of actix. 7 | 8 | [Official API](https://core.telegram.org/bots/api). 9 | 10 | ### Examples 11 | 12 | [`example/polling.rs`](https://github.com/jeizsm/actix-telegram/blob/master/examples/polling.rs) 13 | 14 | [`example/server.rs`](https://github.com/jeizsm/actix-telegram/blob/master/examples/server.rs) 15 | 16 | ## Usage 17 | This library is available via `crates.io`. In order to use it, just add this to your `Cargo.toml`: 18 | 19 | ``` 20 | actix-telegram = "0.1.0-alpha5" 21 | ``` 22 | -------------------------------------------------------------------------------- /src/raw/types/enums/passport_element_error.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum PassportElementError { 6 | PassportElementErrorDataField(PassportElementErrorDataField), 7 | PassportElementErrorFrontSide(PassportElementErrorFrontSide), 8 | PassportElementErrorReverseSide(PassportElementErrorReverseSide), 9 | PassportElementErrorSelfie(PassportElementErrorSelfie), 10 | PassportElementErrorFile(PassportElementErrorFile), 11 | PassportElementErrorFiles(PassportElementErrorFiles), 12 | PassportElementErrorTranslationFile(PassportElementErrorTranslationFile), 13 | PassportElementErrorTranslationFiles(PassportElementErrorTranslationFiles), 14 | PassportElementErrorUnspecified(PassportElementErrorUnspecified), 15 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_selfie.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorSelfie { 8 | /// Error source, must be selfie 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded hash of the file with the selfie 14 | pub(crate) file_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/stop_poll.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Poll"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct StopPoll { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Identifier of the original message with the poll 12 | pub(crate) message_id: Integer, 13 | /// A JSON-serialized object for a new message inline keyboard. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) reply_markup: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/types/contact.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a phone contact. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Contact { 7 | /// Contact's phone number 8 | pub(crate) phone_number: String, 9 | /// Contact's first name 10 | pub(crate) first_name: String, 11 | /// Contact's last name 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) last_name: Option, 14 | /// Contact's user identifier in Telegram 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) user_id: Option, 17 | /// Additional data about the contact in the form of a vCard 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) vcard: Option, 20 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorFile { 8 | /// Error source, must be file 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded file hash 14 | pub(crate) file_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct InlineQuery { 7 | /// Unique identifier for this query 8 | pub(crate) id: String, 9 | /// Sender 10 | pub(crate) from: User, 11 | /// Sender location, only for bots that request user location 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) location: Option, 14 | /// Text of the query (up to 512 characters) 15 | pub(crate) query: String, 16 | /// Offset of the results to be returned, can be controlled by the bot 17 | pub(crate) offset: String, 18 | } -------------------------------------------------------------------------------- /src/raw/types/video_note.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a video message (available in Telegram apps as of v.4.0). 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct VideoNote { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Video width and height (diameter of the video message) as defined by sender 10 | pub(crate) length: Integer, 11 | /// Duration of the video in seconds as defined by sender 12 | pub(crate) duration: Integer, 13 | /// Video thumbnail 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// File size 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) file_size: Option, 19 | } -------------------------------------------------------------------------------- /src/raw/types/enums/mod.rs: -------------------------------------------------------------------------------- 1 | mod input_message_content; 2 | mod message_or_true; 3 | mod input_media; 4 | mod chat_id_or_username; 5 | mod passport_element_error; 6 | mod inline_query_result; 7 | mod input_media_photo_or_input_media_video; 8 | mod reply_markup; 9 | mod input_file_or_string; 10 | pub use self::input_file_or_string::InputFileOrString; 11 | pub use self::reply_markup::ReplyMarkup; 12 | pub use self::input_media_photo_or_input_media_video::InputMediaPhotoOrInputMediaVideo; 13 | pub use self::inline_query_result::InlineQueryResult; 14 | pub use self::passport_element_error::PassportElementError; 15 | pub use self::chat_id_or_username::ChatIdOrUsername; 16 | pub use self::input_media::InputMedia; 17 | pub use self::message_or_true::MessageOrTrue; 18 | pub use self::input_message_content::InputMessageContent; 19 | -------------------------------------------------------------------------------- /src/raw/types/input_text_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents the content of a text message to be sent as the result of an inline query. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputTextMessageContent { 8 | /// Text of the message to be sent, 1-4096 characters 9 | pub(crate) message_text: String, 10 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) parse_mode: Option, 13 | /// Disables link previews for links in the sent message 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_web_page_preview: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_reverse_side.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorReverseSide { 8 | /// Error source, must be reverse_side 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded hash of the file with the reverse side of the document 14 | pub(crate) file_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/types/encrypted_credentials.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct EncryptedCredentials { 7 | /// Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication 8 | pub(crate) data: String, 9 | /// Base64-encoded data hash for data authentication 10 | pub(crate) hash: String, 11 | /// Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption 12 | pub(crate) secret: String, 13 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_files.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorFiles { 8 | /// Error source, must be files 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// List of base64-encoded file hashes 14 | pub(crate) file_hashes: Vec, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/set_chat_sticker_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SetChatStickerSet { 9 | /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Name of the sticker set to be set as the group sticker set 12 | pub(crate) sticker_set_name: String, 13 | } -------------------------------------------------------------------------------- /src/types/input_text_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::ParseMode; 2 | 3 | /// Represents the content of a text message to be sent as the result of an inline query. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputTextMessageContent { 8 | /// Text of the message to be sent, 1-4096 characters 9 | pub(crate) message_text: String, 10 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) parse_mode: Option, 13 | /// Disables link previews for links in the sent message 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_web_page_preview: Option, 16 | } 17 | -------------------------------------------------------------------------------- /src/raw/methods/set_chat_title.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. 4 | /// 5 | /// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "True"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct SetChatTitle { 11 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 12 | pub(crate) chat_id: ChatIdOrUsername, 13 | /// New chat title, 1-255 characters 14 | pub(crate) title: String, 15 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_front_side.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorFrontSide { 8 | /// Error source, must be front_side 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded hash of the file with the front side of the document 14 | pub(crate) file_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/get_user_profile_photos.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "UserProfilePhotos"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetUserProfilePhotos { 9 | /// Unique identifier of the target user 10 | pub(crate) user_id: Integer, 11 | /// Sequential number of the first photo to be returned. By default, all photos are returned. 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) offset: Option, 14 | /// Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) limit: Option, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/set_chat_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. 4 | /// 5 | /// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "True"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct SetChatPhoto { 11 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 12 | pub(crate) chat_id: ChatIdOrUsername, 13 | /// New chat photo, uploaded using multipart/form-data 14 | pub(crate) photo: InputFile, 15 | } -------------------------------------------------------------------------------- /src/raw/types/user.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a Telegram user or bot. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct User { 7 | /// Unique identifier for this user or bot 8 | pub(crate) id: Integer, 9 | /// True, if this user is a bot 10 | pub(crate) is_bot: bool, 11 | /// User‘s or bot’s first name 12 | pub(crate) first_name: String, 13 | /// User‘s or bot’s last name 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) last_name: Option, 16 | /// User‘s or bot’s username 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) username: Option, 19 | /// IETF language tag of the user's language 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) language_code: Option, 22 | } -------------------------------------------------------------------------------- /src/types/message.rs: -------------------------------------------------------------------------------- 1 | pub use crate::raw::types::Message; 2 | use crate::types::MessageEntityType; 3 | 4 | impl Message { 5 | #[inline] 6 | pub fn bot_command<'a>(&'a self, command: &str) -> Option<&'a str> { 7 | self.bot_commands().and_then(|mut bot_commands| { 8 | bot_commands.find(|bot_command| { 9 | *bot_command == command || bot_command.starts_with(&format!("{}@", command)) 10 | }) 11 | }) 12 | } 13 | 14 | #[inline] 15 | pub fn bot_commands(&self) -> Option> { 16 | self.entities.as_ref().map(|entities| { 17 | entities 18 | .iter() 19 | .filter(|entity| MessageEntityType::BotCommand == entity.type_) 20 | .map(move |entity| unsafe { entity.unsafe_text(self.text.as_ref().unwrap()) }) 21 | }) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/raw/types/invoice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains basic information about an invoice. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Invoice { 7 | /// Product name 8 | pub(crate) title: String, 9 | /// Product description 10 | pub(crate) description: String, 11 | /// Unique bot deep-linking parameter that can be used to generate this invoice 12 | pub(crate) start_parameter: String, 13 | /// Three-letter ISO 4217 currency code 14 | pub(crate) currency: String, 15 | /// 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). 16 | pub(crate) total_amount: Integer, 17 | } -------------------------------------------------------------------------------- /src/raw/types/file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. 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 getFile. 4 | /// 5 | /// Maximum file size to download is 20 MB 6 | #[derive(Debug, Deserialize, Clone, Getters)] 7 | #[get(vis = "pub")] 8 | pub struct File { 9 | /// Unique identifier for this file 10 | pub(crate) file_id: String, 11 | /// File size, if known 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) file_size: Option, 14 | /// File path. Use https://api.telegram.org/file/bot/ to get the file. 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) file_path: Option, 17 | } -------------------------------------------------------------------------------- /src/raw/types/document.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a general file (as opposed to photos, voice messages and audio files). 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Document { 7 | /// Unique file identifier 8 | pub(crate) file_id: String, 9 | /// Document thumbnail as defined by sender 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) thumb: Option, 12 | /// Original filename as defined by sender 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) file_name: Option, 15 | /// MIME type of the file as defined by sender 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) mime_type: Option, 18 | /// File size 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) file_size: Option, 21 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_data_field.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorDataField { 8 | /// Error source, must be data 9 | pub(crate) source: String, 10 | /// The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Name of the data field which has the error 14 | pub(crate) field_name: String, 15 | /// Base64-encoded data hash 16 | pub(crate) data_hash: String, 17 | /// Error message 18 | pub(crate) message: String, 19 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_translation_file.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorTranslationFile { 8 | /// Error source, must be translation_file 9 | pub(crate) source: String, 10 | /// Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// Base64-encoded file hash 14 | pub(crate) file_hash: String, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/types/response_parameters.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Contains information about why a request was unsuccessful. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct ResponseParameters { 8 | /// 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. 9 | #[serde(skip_serializing_if = "Option::is_none")] 10 | pub(crate) migrate_to_chat_id: Option, 11 | /// In case of exceeding flood control, the number of seconds left to wait before the request can be repeated 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) retry_after: Option, 14 | } -------------------------------------------------------------------------------- /src/raw/types/passport_element_error_translation_files.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct PassportElementErrorTranslationFiles { 8 | /// Error source, must be translation_files 9 | pub(crate) source: String, 10 | /// Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” 11 | #[serde(rename = "type")] 12 | pub(crate) type_: String, 13 | /// List of base64-encoded file hashes 14 | pub(crate) file_hashes: Vec, 15 | /// Error message 16 | pub(crate) message: String, 17 | } -------------------------------------------------------------------------------- /src/raw/types/video.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a video file. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Video { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Video width as defined by sender 10 | pub(crate) width: Integer, 11 | /// Video height as defined by sender 12 | pub(crate) height: Integer, 13 | /// Duration of the video in seconds as defined by sender 14 | pub(crate) duration: Integer, 15 | /// Video thumbnail 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) thumb: Option, 18 | /// Mime type of a file as defined by sender 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) mime_type: Option, 21 | /// File size 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) file_size: Option, 24 | } -------------------------------------------------------------------------------- /src/raw/methods/forward_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to forward messages of any kind. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct ForwardMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) 12 | pub(crate) from_chat_id: ChatIdOrUsername, 13 | /// Sends the message silently. Users will receive a notification with no sound. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_notification: Option, 16 | /// Message identifier in the chat specified in from_chat_id 17 | pub(crate) message_id: Integer, 18 | } -------------------------------------------------------------------------------- /src/raw/types/force_reply.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct ForceReply { 8 | /// Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply' 9 | pub(crate) force_reply: True, 10 | /// Use this parameter if you want to force reply from specific 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. 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) selective: Option, 13 | } -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate actix; 2 | extern crate actix_net; 3 | extern crate actix_web; 4 | extern crate futures; 5 | extern crate tokio; 6 | #[macro_use] 7 | extern crate serde_derive; 8 | extern crate serde; 9 | extern crate serde_json; 10 | #[macro_use] 11 | extern crate log; 12 | #[macro_use] 13 | extern crate actix_telegram_derive; 14 | extern crate multipart_rfc7578; 15 | #[cfg(all(feature = "tls", feature = "tls-server"))] 16 | extern crate native_tls; 17 | #[cfg(all(feature = "ssl", feature = "tls-server"))] 18 | extern crate openssl; 19 | #[cfg(all(feature = "rust-tls", feature = "tls-server"))] 20 | extern crate rustls; 21 | #[macro_use] 22 | extern crate bitflags; 23 | #[macro_use] 24 | extern crate failure; 25 | 26 | pub mod actors; 27 | pub mod application; 28 | pub mod methods; 29 | pub(crate) mod raw; 30 | pub mod types; 31 | 32 | pub use crate::actors::{TelegramApi, TelegramBot}; 33 | pub use crate::application::App; 34 | 35 | #[cfg(feature = "server")] 36 | pub use crate::actors::TelegramServer; 37 | -------------------------------------------------------------------------------- /src/raw/types/keyboard_button.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields are mutually exclusive. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct KeyboardButton { 8 | /// Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed 9 | pub(crate) text: String, 10 | /// If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) request_contact: Option, 13 | /// If True, the user's current location will be sent when the button is pressed. Available in private chats only 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) request_location: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/types/input_venue_message_content.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents the content of a venue message to be sent as the result of an inline query. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputVenueMessageContent { 8 | /// Latitude of the venue in degrees 9 | pub(crate) latitude: Float, 10 | /// Longitude of the venue in degrees 11 | pub(crate) longitude: Float, 12 | /// Name of the venue 13 | pub(crate) title: String, 14 | /// Address of the venue 15 | pub(crate) address: String, 16 | /// Foursquare identifier of the venue, if known 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) foursquare_id: Option, 19 | /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) foursquare_type: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/methods/pin_chat_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct PinChatMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Identifier of a message to pin 12 | pub(crate) message_id: Integer, 13 | /// Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_notification: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/methods/set_passport_data_errors.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. 4 | /// Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. 5 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 6 | #[return_type = "True"] 7 | #[new(vis = "pub")] 8 | #[set(vis = "pub")] 9 | pub struct SetPassportDataErrors { 10 | /// User identifier 11 | pub(crate) user_id: Integer, 12 | /// A JSON-serialized array describing the errors 13 | pub(crate) errors: Vec, 14 | } -------------------------------------------------------------------------------- /src/raw/types/chosen_inline_result.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a result of an inline query that was chosen by the user and sent to their chat partner. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct ChosenInlineResult { 7 | /// The unique identifier for the result that was chosen 8 | pub(crate) result_id: String, 9 | /// The user that chose the result 10 | pub(crate) from: User, 11 | /// Sender location, only for bots that require user location 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) location: Option, 14 | /// Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) inline_message_id: Option, 17 | /// The query that was used to obtain the result 18 | pub(crate) query: String, 19 | } -------------------------------------------------------------------------------- /src/raw/types/mask_position.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object describes the position on faces where a mask should be placed by default. 4 | #[derive(Debug, Deserialize, Clone, Getters, Serialize, Setters, New)] 5 | #[get(vis = "pub")] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct MaskPosition { 9 | /// The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. 10 | pub(crate) point: String, 11 | /// 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. 12 | pub(crate) x_shift: Float, 13 | /// 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. 14 | pub(crate) y_shift: Float, 15 | /// Mask scaling coefficient. For example, 2.0 means double size. 16 | pub(crate) scale: Float, 17 | } -------------------------------------------------------------------------------- /src/methods/mod.rs: -------------------------------------------------------------------------------- 1 | mod delete_webhook; 2 | mod edit_message_caption; 3 | mod edit_message_text; 4 | mod get_me; 5 | mod get_webhook_info; 6 | mod optimized_get_updates; 7 | mod send_animation; 8 | mod send_audio; 9 | mod send_document; 10 | mod send_message; 11 | mod send_photo; 12 | mod send_video; 13 | mod send_voice; 14 | mod set_webhook; 15 | 16 | pub use self::delete_webhook::DeleteWebhook; 17 | pub use self::edit_message_caption::EditMessageCaption; 18 | pub use self::edit_message_text::EditMessageText; 19 | pub use self::get_me::GetMe; 20 | pub use self::get_webhook_info::GetWebhookInfo; 21 | pub use self::optimized_get_updates::OptimizedGetUpdates; 22 | pub use self::send_animation::SendAnimation; 23 | pub use self::send_audio::SendAudio; 24 | pub use self::send_document::SendDocument; 25 | pub use self::send_message::SendMessage; 26 | pub use self::send_photo::SendPhoto; 27 | pub use self::send_video::SendVideo; 28 | pub use self::send_voice::SendVoice; 29 | pub use self::set_webhook::SetWebhook; 30 | pub use crate::raw::methods::*; 31 | -------------------------------------------------------------------------------- /src/raw/methods/delete_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to delete a message, including service messages, with the following limitations:- A message can only be deleted if it was sent less than 48 hours ago.- Bots can delete outgoing messages in private chats, groups, and supergroups.- Bots can delete incoming messages in private chats.- Bots granted can_post_messages permissions can delete outgoing messages in channels.- If the bot is an administrator of a group, it can delete any message there.- If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct DeleteMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Identifier of the message to delete 12 | pub(crate) message_id: Integer, 13 | } -------------------------------------------------------------------------------- /examples/client.rs: -------------------------------------------------------------------------------- 1 | extern crate actix_telegram; 2 | extern crate actix_web; 3 | extern crate env_logger; 4 | extern crate futures; 5 | extern crate log; 6 | extern crate serde_json; 7 | 8 | use actix_telegram::actors::TelegramApi; 9 | use actix_telegram::methods::*; 10 | use actix_web::actix::{Actor, System}; 11 | use futures::Future; 12 | use std::env; 13 | 14 | fn main() { 15 | env_logger::init(); 16 | let sys = System::new("example"); 17 | let token = env::var("TELEGRAM_TOKEN").unwrap(); 18 | let api = TelegramApi::new(token, 10).start(); 19 | let user_id: i64 = env::var("USER_ID").unwrap().parse().unwrap(); 20 | let chat_id: i64 = env::var("CHAT_ID").unwrap().parse().unwrap(); 21 | let get_chat_member = GetChatMember::new(chat_id, user_id); 22 | actix::spawn( 23 | api.send(get_chat_member) 24 | .map(|a| { 25 | println!("{:?}", a); 26 | actix::System::current().stop(); 27 | () 28 | }) 29 | .map_err(|_| ()), 30 | ); 31 | sys.run(); 32 | } 33 | -------------------------------------------------------------------------------- /src/raw/methods/send_media_group.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Vec"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendMediaGroup { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// A JSON-serialized array describing photos and videos to be sent, must include 2–10 items 12 | pub(crate) media: Vec, 13 | /// Sends the messages silently. Users will receive a notification with no sound. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_notification: Option, 16 | /// If the messages are a reply, ID of the original message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) reply_to_message_id: Option, 19 | } -------------------------------------------------------------------------------- /src/raw/types/input_media_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a photo to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Caption of the photo to be sent, 0-1024 characters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) caption: Option, 16 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) parse_mode: Option, 19 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_sticker.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedSticker { 8 | /// Type of the result, must be sticker 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier of the sticker 14 | pub(crate) sticker_file_id: String, 15 | /// Inline keyboard attached to the message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) reply_markup: Option, 18 | /// Content of the message to be sent instead of the sticker 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) input_message_content: Option, 21 | } -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "actix-telegram" 3 | version = "0.0.5" 4 | authors = ["Marat Safin "] 5 | description = "telegram bot api lib based on actix" 6 | repository = "https://github.com/jeizsm/actix-telegram" 7 | license = "MIT" 8 | 9 | [dependencies] 10 | actix = "0.7.9" 11 | actix-web = "0.7.18" 12 | actix-net = "0.2.6" 13 | actix-telegram-derive = { path="./actix-telegram-derive", version="0.2" } 14 | multipart-rfc7578 = { version = "0.6", features = ["actix-web"] } 15 | futures = "0.1" 16 | serde = "1.0" 17 | serde_derive = "1.0" 18 | serde_json = "1.0" 19 | tokio = "0.1" 20 | log = "0.4" 21 | env_logger = "0.6" 22 | rustls = { version = "0.14", optional = true } 23 | openssl = { version = "0.10", optional = true } 24 | native-tls = { version = "0.2", optional = true } 25 | bitflags = "1.0" 26 | failure = "0.1" 27 | 28 | [features] 29 | default = ["tls-server", "rust-tls"] 30 | server = [] 31 | tls-server = ["server"] 32 | rust-tls = ["rustls", "actix-web/rust-tls", "actix-net/rust-tls"] 33 | ssl = ["openssl", "actix-web/ssl", "actix-net/ssl"] 34 | tls = ["native-tls", "actix-web/tls", "actix-net/tls"] 35 | -------------------------------------------------------------------------------- /src/types/input_media_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InputFileOrString, ParseMode}; 2 | 3 | /// Represents a photo to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Caption of the photo to be sent, 0-1024 characters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) caption: Option, 16 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) parse_mode: Option, 19 | } 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/raw/types/message_entity.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct MessageEntity { 7 | /// Type of the entity. Can be mention (@username), hashtag, cashtag, bot_command, url, email, phone_number, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames) 8 | #[serde(rename = "type")] 9 | pub(crate) type_: String, 10 | /// Offset in UTF-16 code units to the start of the entity 11 | pub(crate) offset: Integer, 12 | /// Length of the entity in UTF-16 code units 13 | pub(crate) length: Integer, 14 | /// For “text_link” only, url that will be opened after user taps on the text 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) url: Option, 17 | /// For “text_mention” only, the mentioned user 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) user: Option, 20 | } -------------------------------------------------------------------------------- /src/raw/types/sticker.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a sticker. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Sticker { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Sticker width 10 | pub(crate) width: Integer, 11 | /// Sticker height 12 | pub(crate) height: Integer, 13 | /// Sticker thumbnail in the .webp or .jpg format 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Emoji associated with the sticker 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) emoji: Option, 19 | /// Name of the sticker set to which the sticker belongs 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) set_name: Option, 22 | /// For mask stickers, the position where the mask should be placed 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) mask_position: Option, 25 | /// File size 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) file_size: Option, 28 | } -------------------------------------------------------------------------------- /src/raw/types/animation.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Animation { 7 | /// Unique file identifier 8 | pub(crate) file_id: String, 9 | /// Video width as defined by sender 10 | pub(crate) width: Integer, 11 | /// Video height as defined by sender 12 | pub(crate) height: Integer, 13 | /// Duration of the video in seconds as defined by sender 14 | pub(crate) duration: Integer, 15 | /// Animation thumbnail as defined by sender 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) thumb: Option, 18 | /// Original animation filename as defined by sender 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) file_name: Option, 21 | /// MIME type of the file as defined by sender 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) mime_type: Option, 24 | /// File size 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) file_size: Option, 27 | } -------------------------------------------------------------------------------- /src/raw/methods/send_game.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send a game. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendGame { 9 | /// Unique identifier for the target chat 10 | pub(crate) chat_id: Integer, 11 | /// Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. 12 | pub(crate) game_short_name: String, 13 | /// Sends the message silently. Users will receive a notification with no sound. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_notification: Option, 16 | /// If the message is a reply, ID of the original message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) reply_to_message_id: Option, 19 | /// A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) reply_markup: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/methods/add_sticker_to_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to add a new sticker to a set created by the bot. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct AddStickerToSet { 9 | /// User identifier of sticker set owner 10 | pub(crate) user_id: Integer, 11 | /// Sticker set name 12 | pub(crate) name: String, 13 | /// Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files » 14 | pub(crate) png_sticker: InputFileOrString, 15 | /// One or more emoji corresponding to the sticker 16 | pub(crate) emojis: String, 17 | /// A JSON-serialized object for position where the mask should be placed on faces 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) mask_position: Option, 20 | } -------------------------------------------------------------------------------- /src/raw/types/pre_checkout_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains information about an incoming pre-checkout query. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct PreCheckoutQuery { 7 | /// Unique query identifier 8 | pub(crate) id: String, 9 | /// User who sent the query 10 | pub(crate) from: User, 11 | /// Three-letter ISO 4217 currency code 12 | pub(crate) currency: String, 13 | /// 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). 14 | pub(crate) total_amount: Integer, 15 | /// Bot specified invoice payload 16 | pub(crate) invoice_payload: String, 17 | /// Identifier of the shipping option chosen by the user 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) shipping_option_id: Option, 20 | /// Order info provided by the user 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) order_info: Option, 23 | } -------------------------------------------------------------------------------- /src/raw/types/audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents an audio file to be treated as music by the Telegram clients. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Audio { 7 | /// Unique identifier for this file 8 | pub(crate) file_id: String, 9 | /// Duration of the audio in seconds as defined by sender 10 | pub(crate) duration: Integer, 11 | /// Performer of the audio as defined by sender or by audio tags 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) performer: Option, 14 | /// Title of the audio as defined by sender or by audio tags 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) title: Option, 17 | /// MIME type of the file as defined by sender 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) mime_type: Option, 20 | /// File size 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) file_size: Option, 23 | /// Thumbnail of the album cover to which the music file belongs 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) thumb: Option, 26 | } -------------------------------------------------------------------------------- /src/raw/types/successful_payment.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object contains basic information about a successful payment. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct SuccessfulPayment { 7 | /// Three-letter ISO 4217 currency code 8 | pub(crate) currency: String, 9 | /// 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). 10 | pub(crate) total_amount: Integer, 11 | /// Bot specified invoice payload 12 | pub(crate) invoice_payload: String, 13 | /// Identifier of the shipping option chosen by the user 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) shipping_option_id: Option, 16 | /// Order info provided by the user 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) order_info: Option, 19 | /// Telegram payment identifier 20 | pub(crate) telegram_payment_charge_id: String, 21 | /// Provider payment identifier 22 | pub(crate) provider_payment_charge_id: String, 23 | } -------------------------------------------------------------------------------- /src/raw/types/game.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct Game { 7 | /// Title of the game 8 | pub(crate) title: String, 9 | /// Description of the game 10 | pub(crate) description: String, 11 | /// Photo that will be displayed in the game message in chats. 12 | pub(crate) photo: Vec, 13 | /// Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) text: Option, 16 | /// Special entities that appear in text, such as usernames, URLs, bot commands, etc. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) text_entities: Option>, 19 | /// Animation that will be displayed in the game message in chats. Upload via BotFather 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) animation: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/methods/edit_message_reply_markup.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to edit only the reply markup of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct EditMessageReplyMarkup { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// A JSON-serialized object for an inline keyboard. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) reply_markup: Option, 21 | } -------------------------------------------------------------------------------- /src/raw/methods/stop_message_live_location.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to stop updating a live location message before live_period expires. On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct StopMessageLiveLocation { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message with live location to stop 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// A JSON-serialized object for a new inline keyboard. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) reply_markup: Option, 21 | } -------------------------------------------------------------------------------- /src/raw/methods/answer_pre_checkout_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct AnswerPreCheckoutQuery { 9 | /// Unique identifier for the query to be answered 10 | pub(crate) pre_checkout_query_id: String, 11 | /// Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. 12 | pub(crate) ok: bool, 13 | /// Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) error_message: Option, 16 | } -------------------------------------------------------------------------------- /src/raw/methods/answer_shipping_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct AnswerShippingQuery { 9 | /// Unique identifier for the query to be answered 10 | pub(crate) shipping_query_id: String, 11 | /// Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) 12 | pub(crate) ok: bool, 13 | /// Required if ok is True. A JSON-serialized array of available shipping options. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) shipping_options: Option>, 16 | /// Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) error_message: Option, 19 | } -------------------------------------------------------------------------------- /src/raw/types/reply_keyboard_remove.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct ReplyKeyboardRemove { 8 | /// Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) 9 | pub(crate) remove_keyboard: True, 10 | /// Use this parameter if you want to remove the keyboard for specific 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.Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) selective: Option, 13 | } -------------------------------------------------------------------------------- /src/raw/methods/get_game_high_scores.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects. 4 | /// 5 | /// This method will currently return scores for the target user, plus two of his closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "Vec"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct GetGameHighScores { 11 | /// Target user id 12 | pub(crate) user_id: Integer, 13 | /// Required if inline_message_id is not specified. Unique identifier for the target chat 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) chat_id: Option, 16 | /// Required if inline_message_id is not specified. Identifier of the sent message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) message_id: Option, 19 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) inline_message_id: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/methods/kick_chat_member.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. 4 | /// 5 | /// Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. Otherwise members may only be removed by the group's creator or by the member that added them. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "True"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct KickChatMember { 11 | /// Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) 12 | pub(crate) chat_id: ChatIdOrUsername, 13 | /// Unique identifier of the target user 14 | pub(crate) user_id: Integer, 15 | /// Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) until_date: Option, 18 | } -------------------------------------------------------------------------------- /src/raw/types/enums/inline_query_result.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Serialize)] 4 | #[serde(untagged)] 5 | pub enum InlineQueryResult { 6 | InlineQueryResultCachedAudio(InlineQueryResultCachedAudio), 7 | InlineQueryResultCachedDocument(InlineQueryResultCachedDocument), 8 | InlineQueryResultCachedGif(InlineQueryResultCachedGif), 9 | InlineQueryResultCachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif), 10 | InlineQueryResultCachedPhoto(InlineQueryResultCachedPhoto), 11 | InlineQueryResultCachedSticker(InlineQueryResultCachedSticker), 12 | InlineQueryResultCachedVideo(InlineQueryResultCachedVideo), 13 | InlineQueryResultCachedVoice(InlineQueryResultCachedVoice), 14 | InlineQueryResultArticle(InlineQueryResultArticle), 15 | InlineQueryResultAudio(InlineQueryResultAudio), 16 | InlineQueryResultContact(InlineQueryResultContact), 17 | InlineQueryResultGame(InlineQueryResultGame), 18 | InlineQueryResultDocument(InlineQueryResultDocument), 19 | InlineQueryResultGif(InlineQueryResultGif), 20 | InlineQueryResultLocation(InlineQueryResultLocation), 21 | InlineQueryResultMpeg4Gif(InlineQueryResultMpeg4Gif), 22 | InlineQueryResultPhoto(InlineQueryResultPhoto), 23 | InlineQueryResultVenue(InlineQueryResultVenue), 24 | InlineQueryResultVideo(InlineQueryResultVideo), 25 | InlineQueryResultVoice(InlineQueryResultVoice), 26 | } -------------------------------------------------------------------------------- /src/raw/methods/send_poll.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send a native poll. A native poll can't be sent to a private chat. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendPoll { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername). A native poll can't be sent to a private chat. 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Poll question, 1-255 characters 12 | pub(crate) question: String, 13 | /// List of answer options, 2-10 strings 1-100 characters each 14 | pub(crate) options: Vec, 15 | /// Sends the message silently. Users will receive a notification with no sound. 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) disable_notification: Option, 18 | /// If the message is a reply, ID of the original message 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) reply_to_message_id: Option, 21 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) reply_markup: Option, 24 | } -------------------------------------------------------------------------------- /src/raw/types/webhook_info.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Contains information about the current status of a webhook. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct WebhookInfo { 7 | /// Webhook URL, may be empty if webhook is not set up 8 | pub(crate) url: String, 9 | /// True, if a custom certificate was provided for webhook certificate checks 10 | pub(crate) has_custom_certificate: bool, 11 | /// Number of updates awaiting delivery 12 | pub(crate) pending_update_count: Integer, 13 | /// Unix time for the most recent error that happened when trying to deliver an update via webhook 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) last_error_date: Option, 16 | /// Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) last_error_message: Option, 19 | /// Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) max_connections: Option, 22 | /// A list of update types the bot is subscribed to. Defaults to all update types 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) allowed_updates: Option>, 25 | } -------------------------------------------------------------------------------- /src/raw/methods/send_chat_action.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. 4 | /// 5 | /// Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. 6 | /// 7 | /// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. 8 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 9 | #[return_type = "True"] 10 | #[new(vis = "pub")] 11 | #[set(vis = "pub")] 12 | pub struct SendChatAction { 13 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 14 | pub(crate) chat_id: ChatIdOrUsername, 15 | /// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes. 16 | pub(crate) action: String, 17 | } -------------------------------------------------------------------------------- /src/raw/methods/send_sticker.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send .webp stickers. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendSticker { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files » 12 | pub(crate) sticker: InputFileOrString, 13 | /// Sends the message silently. Users will receive a notification with no sound. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) disable_notification: Option, 16 | /// If the message is a reply, ID of the original message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) reply_to_message_id: Option, 19 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) reply_markup: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the audio file 14 | pub(crate) audio_file_id: String, 15 | /// Caption, 0-1024 characters 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) caption: Option, 18 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) parse_mode: Option, 21 | /// Inline keyboard attached to the message 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) reply_markup: Option, 24 | /// Content of the message to be sent instead of the audio 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) input_message_content: Option, 27 | } -------------------------------------------------------------------------------- /src/raw/methods/send_location.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send point on the map. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendLocation { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Latitude of the location 12 | pub(crate) latitude: Float, 13 | /// Longitude of the location 14 | pub(crate) longitude: Float, 15 | /// Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400. 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) live_period: Option, 18 | /// Sends the message silently. Users will receive a notification with no sound. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) disable_notification: Option, 21 | /// If the message is a reply, ID of the original message 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) reply_to_message_id: Option, 24 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | } -------------------------------------------------------------------------------- /src/actors/telegram_worker.rs: -------------------------------------------------------------------------------- 1 | use super::TelegramApi; 2 | use crate::application::UpdateHandler; 3 | use crate::types::Update; 4 | use actix::{Actor, Addr, Context, Handler, Message}; 5 | 6 | pub struct TelegramWorker 7 | where 8 | H: UpdateHandler + 'static, 9 | { 10 | apps: H, 11 | telegram_api: Addr, 12 | } 13 | 14 | impl TelegramWorker 15 | where 16 | H: UpdateHandler + 'static, 17 | { 18 | pub(crate) fn new(telegram_api: Addr, apps: H) -> Self { 19 | Self { apps, telegram_api } 20 | } 21 | } 22 | 23 | impl Actor for TelegramWorker 24 | where 25 | H: UpdateHandler + 'static, 26 | { 27 | type Context = Context; 28 | 29 | fn started(&mut self, _ctx: &mut Context) { 30 | debug!("TelegramWorker is alive"); 31 | } 32 | 33 | fn stopped(&mut self, _ctx: &mut Context) { 34 | debug!("TelegramWorker is stopped"); 35 | } 36 | } 37 | 38 | impl Handler for TelegramWorker 39 | where 40 | H: UpdateHandler + 'static, 41 | { 42 | type Result = Result<(), ()>; 43 | 44 | fn handle(&mut self, msg: Update, _ctx: &mut Context) -> Self::Result { 45 | debug!("TelegramWorker.Update received {:?}", msg); 46 | if self.apps.handle(msg, &self.telegram_api).is_some() { 47 | debug!("update is not handled"); 48 | Err(()) 49 | } else { 50 | Ok(()) 51 | } 52 | } 53 | } 54 | 55 | impl Message for Update { 56 | type Result = Result<(), ()>; 57 | } 58 | -------------------------------------------------------------------------------- /src/raw/methods/edit_message_live_location.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct EditMessageLiveLocation { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// Latitude of new location 19 | pub(crate) latitude: Float, 20 | /// Longitude of new location 21 | pub(crate) longitude: Float, 22 | /// A JSON-serialized object for a new inline keyboard. 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) reply_markup: Option, 25 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the audio file 14 | pub(crate) audio_file_id: String, 15 | /// Caption, 0-1024 characters 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) caption: Option, 18 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) parse_mode: Option, 21 | /// Inline keyboard attached to the message 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) reply_markup: Option, 24 | /// Content of the message to be sent instead of the audio 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) input_message_content: Option, 27 | } 28 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedVoice { 8 | /// Type of the result, must be voice 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the voice message 14 | pub(crate) voice_file_id: String, 15 | /// Voice message title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Inline keyboard attached to the message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) reply_markup: Option, 26 | /// Content of the message to be sent instead of the voice message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) input_message_content: Option, 29 | } -------------------------------------------------------------------------------- /src/raw/methods/send_contact.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send phone contacts. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendContact { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Contact's phone number 12 | pub(crate) phone_number: String, 13 | /// Contact's first name 14 | pub(crate) first_name: String, 15 | /// Contact's last name 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) last_name: Option, 18 | /// Additional data about the contact in the form of a vCard, 0-2048 bytes 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) vcard: Option, 21 | /// Sends the message silently. Users will receive a notification with no sound. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) disable_notification: Option, 24 | /// If the message is a reply, ID of the original message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_to_message_id: Option, 27 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user. 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) reply_markup: Option, 30 | } -------------------------------------------------------------------------------- /src/raw/methods/send_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send text messages. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Text of the message to be sent 12 | pub(crate) text: String, 13 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) parse_mode: Option, 16 | /// Disables link previews for links in this message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) disable_web_page_preview: Option, 19 | /// Sends the message silently. Users will receive a notification with no sound. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) disable_notification: Option, 22 | /// If the message is a reply, ID of the original message 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) reply_to_message_id: Option, 25 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) reply_markup: Option, 28 | } -------------------------------------------------------------------------------- /src/raw/methods/edit_message_caption.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct EditMessageCaption { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// New caption of the message 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// A JSON-serialized object for an inline keyboard. 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedVoice { 8 | /// Type of the result, must be voice 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the voice message 14 | pub(crate) voice_file_id: String, 15 | /// Voice message title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Inline keyboard attached to the message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) reply_markup: Option, 26 | /// Content of the message to be sent instead of the voice message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) input_message_content: Option, 29 | } 30 | -------------------------------------------------------------------------------- /src/raw/methods/edit_message_media.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct EditMessageMedia { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// A JSON-serialized object for a new media content of the message 19 | pub(crate) media: InputMedia, 20 | /// A JSON-serialized object for a new inline keyboard. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) reply_markup: Option, 23 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_article.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a link to an article or web page. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultArticle { 8 | /// Type of the result, must be article 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 Bytes 12 | pub(crate) id: String, 13 | /// Title of the result 14 | pub(crate) title: String, 15 | /// Content of the message to be sent 16 | pub(crate) input_message_content: InputMessageContent, 17 | /// Inline keyboard attached to the message 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) reply_markup: Option, 20 | /// URL of the result 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) url: Option, 23 | /// Pass True, if you don't want the URL to be shown in the message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) hide_url: Option, 26 | /// Short description of the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) description: Option, 29 | /// Url of the thumbnail for the result 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) thumb_url: Option, 32 | /// Thumbnail width 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) thumb_width: Option, 35 | /// Thumbnail height 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) thumb_height: Option, 38 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedGif { 8 | /// Type of the result, must be gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the GIF file 14 | pub(crate) gif_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Caption of the GIF file to be sent, 0-1024 characters 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// Inline keyboard attached to the message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | /// Content of the message to be sent instead of the GIF animation 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) input_message_content: Option, 30 | } -------------------------------------------------------------------------------- /src/raw/methods/set_game_score.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SetGameScore { 9 | /// User identifier 10 | pub(crate) user_id: Integer, 11 | /// New score, must be non-negative 12 | pub(crate) score: Integer, 13 | /// Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) force: Option, 16 | /// Pass True, if the game message should not be automatically edited to include the current scoreboard 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) disable_edit_message: Option, 19 | /// Required if inline_message_id is not specified. Unique identifier for the target chat 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) chat_id: Option, 22 | /// Required if inline_message_id is not specified. Identifier of the sent message 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) message_id: Option, 25 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) inline_message_id: Option, 28 | } -------------------------------------------------------------------------------- /src/methods/send_message.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{ChatIdOrUsername, Integer, Message, ParseMode, ReplyMarkup}; 2 | 3 | /// Use this method to send text messages. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[set(vis = "pub", optional)] 7 | #[new(vis = "pub")] 8 | pub struct SendMessage { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Text of the message to be sent 12 | pub(crate) text: String, 13 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) parse_mode: Option, 16 | /// Disables link previews for links in this message 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) disable_web_page_preview: Option, 19 | /// Sends the message silently. Users will receive a notification with no sound. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) disable_notification: Option, 22 | /// If the message is a reply, ID of the original message 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) reply_to_message_id: Option, 25 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) reply_markup: Option, 28 | } 29 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultVoice { 8 | /// Type of the result, must be voice 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the voice recording 14 | pub(crate) voice_url: String, 15 | /// Recording title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Recording duration in seconds 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) voice_duration: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the voice recording 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } -------------------------------------------------------------------------------- /src/methods/edit_message_caption.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{ChatIdOrUsername, InlineKeyboardMarkup, Integer, MessageOrTrue, ParseMode}; 2 | 3 | /// Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[set(vis = "pub", optional)] 7 | #[new(vis = "pub")] 8 | pub struct EditMessageCaption { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// New caption of the message 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// A JSON-serialized object for an inline keyboard. 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | } 28 | -------------------------------------------------------------------------------- /src/raw/types/input_media_document.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a general file to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaDocument { 8 | /// Type of the result, must be document 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the document to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | } -------------------------------------------------------------------------------- /src/raw/methods/edit_message_text.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to edit text and game messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct EditMessageText { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// New text of the message 19 | pub(crate) text: String, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Disables link previews for links in this message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) disable_web_page_preview: Option, 26 | /// A JSON-serialized object for an inline keyboard. 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | } -------------------------------------------------------------------------------- /src/raw/types/reply_keyboard_markup.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct ReplyKeyboardMarkup { 8 | /// Array of button rows, each represented by an Array of KeyboardButton objects 9 | pub(crate) keyboard: Vec>, 10 | /// 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. 11 | #[serde(skip_serializing_if = "Option::is_none")] 12 | pub(crate) resize_keyboard: Option, 13 | /// 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. 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) one_time_keyboard: Option, 16 | /// Use this parameter if you want to show the keyboard to specific 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.Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) selective: Option, 19 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedGif { 8 | /// Type of the result, must be gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the GIF file 14 | pub(crate) gif_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Caption of the GIF file to be sent, 0-1024 characters 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// Inline keyboard attached to the message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | /// Content of the message to be sent instead of the GIF animation 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) input_message_content: Option, 30 | } 31 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_document.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedDocument { 8 | /// Type of the result, must be document 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// Title for the result 14 | pub(crate) title: String, 15 | /// A valid file identifier for the file 16 | pub(crate) document_file_id: String, 17 | /// Short description of the result 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) description: Option, 20 | /// Caption of the document to be sent, 0-1024 characters 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) caption: Option, 23 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) parse_mode: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the file 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_mpeg4_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedMpeg4Gif { 8 | /// Type of the result, must be mpeg4_gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the MP4 file 14 | pub(crate) mpeg4_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Caption of the MPEG-4 file to be sent, 0-1024 characters 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// Inline keyboard attached to the message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | /// Content of the message to be sent instead of the video animation 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) input_message_content: Option, 30 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_video.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedVideo { 8 | /// Type of the result, must be video 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the video file 14 | pub(crate) video_file_id: String, 15 | /// Title for the result 16 | pub(crate) title: String, 17 | /// Short description of the result 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) description: Option, 20 | /// Caption of the video to be sent, 0-1024 characters 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) caption: Option, 23 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) parse_mode: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the video 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } -------------------------------------------------------------------------------- /src/raw/types/callback_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Deserialize, Clone, Getters)] 5 | #[get(vis = "pub")] 6 | pub struct CallbackQuery { 7 | /// Unique identifier for this query 8 | pub(crate) id: String, 9 | /// Sender 10 | pub(crate) from: User, 11 | /// 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 12 | #[serde(skip_serializing_if = "Option::is_none")] 13 | pub(crate) message: Option, 14 | /// Identifier of the message sent via the bot in inline mode, that originated the query. 15 | #[serde(skip_serializing_if = "Option::is_none")] 16 | pub(crate) inline_message_id: Option, 17 | /// Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. 18 | pub(crate) chat_instance: String, 19 | /// Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) data: Option, 22 | /// Short name of a Game to be returned, serves as the unique identifier for the game 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) game_short_name: Option, 25 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the audio file 14 | pub(crate) audio_url: String, 15 | /// Title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Performer 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) performer: Option, 26 | /// Audio duration in seconds 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) audio_duration: Option, 29 | /// Inline keyboard attached to the message 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) reply_markup: Option, 32 | /// Content of the message to be sent instead of the audio 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) input_message_content: Option, 35 | } -------------------------------------------------------------------------------- /src/types/input_media_document.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InputFileOrString, ParseMode}; 2 | 3 | /// Represents a general file to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaDocument { 8 | /// Type of the result, must be document 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the document to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | } 23 | -------------------------------------------------------------------------------- /src/types/inline_query_result_voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, Integer, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultVoice { 8 | /// Type of the result, must be voice 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the voice recording 14 | pub(crate) voice_url: String, 15 | /// Recording title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Recording duration in seconds 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) voice_duration: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the voice recording 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } 33 | -------------------------------------------------------------------------------- /src/raw/methods/create_new_sticker_set.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct CreateNewStickerSet { 9 | /// User identifier of created sticker set owner 10 | pub(crate) user_id: Integer, 11 | /// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_”. is case insensitive. 1-64 characters. 12 | pub(crate) name: String, 13 | /// Sticker set title, 1-64 characters 14 | pub(crate) title: String, 15 | /// Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files » 16 | pub(crate) png_sticker: InputFileOrString, 17 | /// One or more emoji corresponding to the sticker 18 | pub(crate) emojis: String, 19 | /// Pass True, if a set of mask stickers should be created 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) contains_masks: Option, 22 | /// A JSON-serialized object for position where the mask should be placed on faces 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) mask_position: Option, 25 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_cached_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier of the photo 14 | pub(crate) photo_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Short description of the result 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) description: Option, 21 | /// Caption of the photo to be sent, 0-1024 characters 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) caption: Option, 24 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) parse_mode: Option, 27 | /// Inline keyboard attached to the message 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) reply_markup: Option, 30 | /// Content of the message to be sent instead of the photo 31 | #[serde(skip_serializing_if = "Option::is_none")] 32 | pub(crate) input_message_content: Option, 33 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_document.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedDocument { 8 | /// Type of the result, must be document 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// Title for the result 14 | pub(crate) title: String, 15 | /// A valid file identifier for the file 16 | pub(crate) document_file_id: String, 17 | /// Short description of the result 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) description: Option, 20 | /// Caption of the document to be sent, 0-1024 characters 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) caption: Option, 23 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) parse_mode: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the file 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } 33 | -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_mpeg4_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedMpeg4Gif { 8 | /// Type of the result, must be mpeg4_gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the MP4 file 14 | pub(crate) mpeg4_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Caption of the MPEG-4 file to be sent, 0-1024 characters 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) caption: Option, 21 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) parse_mode: Option, 24 | /// Inline keyboard attached to the message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_markup: Option, 27 | /// Content of the message to be sent instead of the video animation 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) input_message_content: Option, 30 | } 31 | -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_video.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedVideo { 8 | /// Type of the result, must be video 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier for the video file 14 | pub(crate) video_file_id: String, 15 | /// Title for the result 16 | pub(crate) title: String, 17 | /// Short description of the result 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) description: Option, 20 | /// Caption of the video to be sent, 0-1024 characters 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) caption: Option, 23 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) parse_mode: Option, 26 | /// Inline keyboard attached to the message 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | /// Content of the message to be sent instead of the video 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) input_message_content: Option, 32 | } 33 | -------------------------------------------------------------------------------- /src/methods/edit_message_text.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{ChatIdOrUsername, InlineKeyboardMarkup, Integer, MessageOrTrue, ParseMode}; 2 | 3 | /// Use this method to edit text and game messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "MessageOrTrue"] 6 | #[set(vis = "pub", optional)] 7 | #[new(vis = "pub")] 8 | pub struct EditMessageText { 9 | /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) chat_id: Option, 12 | /// Required if inline_message_id is not specified. Identifier of the message to edit 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) message_id: Option, 15 | /// Required if chat_id and message_id are not specified. Identifier of the inline message 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) inline_message_id: Option, 18 | /// New text of the message 19 | pub(crate) text: String, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Disables link previews for links in this message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) disable_web_page_preview: Option, 26 | /// A JSON-serialized object for an inline keyboard. 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) reply_markup: Option, 29 | } 30 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_location.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultLocation { 8 | /// Type of the result, must be location 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 Bytes 12 | pub(crate) id: String, 13 | /// Location latitude in degrees 14 | pub(crate) latitude: Float, 15 | /// Location longitude in degrees 16 | pub(crate) longitude: Float, 17 | /// Location title 18 | pub(crate) title: String, 19 | /// Period in seconds for which the location can be updated, should be between 60 and 86400. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) live_period: Option, 22 | /// Inline keyboard attached to the message 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) reply_markup: Option, 25 | /// Content of the message to be sent instead of the location 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) input_message_content: Option, 28 | /// Url of the thumbnail for the result 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) thumb_url: Option, 31 | /// Thumbnail width 32 | #[serde(skip_serializing_if = "Option::is_none")] 33 | pub(crate) thumb_width: Option, 34 | /// Thumbnail height 35 | #[serde(skip_serializing_if = "Option::is_none")] 36 | pub(crate) thumb_height: Option, 37 | } -------------------------------------------------------------------------------- /src/raw/methods/send_venue.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send information about a venue. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendVenue { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Latitude of the venue 12 | pub(crate) latitude: Float, 13 | /// Longitude of the venue 14 | pub(crate) longitude: Float, 15 | /// Name of the venue 16 | pub(crate) title: String, 17 | /// Address of the venue 18 | pub(crate) address: String, 19 | /// Foursquare identifier of the venue 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) foursquare_id: Option, 22 | /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) foursquare_type: Option, 25 | /// Sends the message silently. Users will receive a notification with no sound. 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) disable_notification: Option, 28 | /// If the message is a reply, ID of the original message 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) reply_to_message_id: Option, 31 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 32 | #[serde(skip_serializing_if = "Option::is_none")] 33 | pub(crate) reply_markup: Option, 34 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, Integer, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the audio file 14 | pub(crate) audio_url: String, 15 | /// Title 16 | pub(crate) title: String, 17 | /// Caption, 0-1024 characters 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) caption: Option, 20 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) parse_mode: Option, 23 | /// Performer 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) performer: Option, 26 | /// Audio duration in seconds 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) audio_duration: Option, 29 | /// Inline keyboard attached to the message 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) reply_markup: Option, 32 | /// Content of the message to be sent instead of the audio 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) input_message_content: Option, 35 | } 36 | -------------------------------------------------------------------------------- /src/types/inline_query_result_cached_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultCachedPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid file identifier of the photo 14 | pub(crate) photo_file_id: String, 15 | /// Title for the result 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) title: Option, 18 | /// Short description of the result 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) description: Option, 21 | /// Caption of the photo to be sent, 0-1024 characters 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) caption: Option, 24 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) parse_mode: Option, 27 | /// Inline keyboard attached to the message 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) reply_markup: Option, 30 | /// Content of the message to be sent instead of the photo 31 | #[serde(skip_serializing_if = "Option::is_none")] 32 | pub(crate) input_message_content: Option, 33 | } 34 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_contact.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultContact { 8 | /// Type of the result, must be contact 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 Bytes 12 | pub(crate) id: String, 13 | /// Contact's phone number 14 | pub(crate) phone_number: String, 15 | /// Contact's first name 16 | pub(crate) first_name: String, 17 | /// Contact's last name 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) last_name: Option, 20 | /// Additional data about the contact in the form of a vCard, 0-2048 bytes 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) vcard: Option, 23 | /// Inline keyboard attached to the message 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) reply_markup: Option, 26 | /// Content of the message to be sent instead of the contact 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) input_message_content: Option, 29 | /// Url of the thumbnail for the result 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) thumb_url: Option, 32 | /// Thumbnail width 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) thumb_width: Option, 35 | /// Thumbnail height 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) thumb_height: Option, 38 | } -------------------------------------------------------------------------------- /src/raw/methods/send_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send photos. On success, the sent Message is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendPhoto { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. More info on Sending Files » 12 | pub(crate) photo: InputFileOrString, 13 | /// Photo caption (may also be used when resending photos by file_id), 0-1024 characters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) caption: Option, 16 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) parse_mode: Option, 19 | /// Sends the message silently. Users will receive a notification with no sound. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) disable_notification: Option, 22 | /// If the message is a reply, ID of the original message 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) reply_to_message_id: Option, 25 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) reply_markup: Option, 28 | } -------------------------------------------------------------------------------- /src/raw/types/login_url.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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: 4 | /// 5 | /// 6 | /// 7 | /// Telegram apps support these buttons as of version 5.7. 8 | /// 9 | /// Sample bot: @discussbot 10 | #[derive(Debug, Deserialize, Clone, Getters, Serialize, Setters, New)] 11 | #[get(vis = "pub")] 12 | #[new(vis = "pub")] 13 | #[set(vis = "pub")] 14 | pub struct LoginUrl { 15 | /// An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization. 16 | pub(crate) url: String, 17 | /// New text of the button in forwarded messages. 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) forward_text: Option, 20 | /// Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) bot_username: Option, 23 | /// Pass True to request the permission for your bot to send messages to the user. 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) request_write_access: Option, 26 | } -------------------------------------------------------------------------------- /src/raw/methods/restrict_chat_member.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "True"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct RestrictChatMember { 9 | /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Unique identifier of the target user 12 | pub(crate) user_id: Integer, 13 | /// Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) until_date: Option, 16 | /// Pass True, if the user can send text messages, contacts, locations and venues 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) can_send_messages: Option, 19 | /// Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) can_send_media_messages: Option, 22 | /// Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) can_send_other_messages: Option, 25 | /// Pass True, if the user may add web page previews to their messages, implies can_send_media_messages 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) can_add_web_page_previews: Option, 28 | } -------------------------------------------------------------------------------- /src/methods/send_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{ 2 | ChatIdOrUsername, InputFile, InputFileOrString, Integer, Message, ParseMode, ReplyMarkup, 3 | }; 4 | 5 | /// Use this method to send photos. On success, the sent Message is returned. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "Message"] 8 | #[set(vis = "pub", optional)] 9 | #[new(vis = "pub")] 10 | pub struct SendPhoto { 11 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 12 | pub(crate) chat_id: ChatIdOrUsername, 13 | /// Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. More info on Sending Files » 14 | pub(crate) photo: InputFileOrString, 15 | /// Photo caption (may also be used when resending photos by file_id), 0-1024 characters 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) caption: Option, 18 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) parse_mode: Option, 21 | /// Sends the message silently. Users will receive a notification with no sound. 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) disable_notification: Option, 24 | /// If the message is a reply, ID of the original message 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) reply_to_message_id: Option, 27 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) reply_markup: Option, 30 | } 31 | -------------------------------------------------------------------------------- /src/raw/methods/answer_callback_query.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. 4 | /// 5 | /// Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. 6 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 7 | #[return_type = "True"] 8 | #[new(vis = "pub")] 9 | #[set(vis = "pub")] 10 | pub struct AnswerCallbackQuery { 11 | /// Unique identifier for the query to be answered 12 | pub(crate) callback_query_id: String, 13 | /// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) text: Option, 16 | /// If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) show_alert: Option, 19 | /// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button.Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) url: Option, 22 | /// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) cache_time: Option, 25 | } -------------------------------------------------------------------------------- /src/raw/methods/get_updates.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Vec"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct GetUpdates { 9 | /// Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten. 10 | #[serde(skip_serializing_if = "Option::is_none")] 11 | pub(crate) offset: Option, 12 | /// Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100. 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) limit: Option, 15 | /// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) timeout: Option, 18 | /// List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) allowed_updates: Option>, 21 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_venue.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultVenue { 8 | /// Type of the result, must be venue 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 Bytes 12 | pub(crate) id: String, 13 | /// Latitude of the venue location in degrees 14 | pub(crate) latitude: Float, 15 | /// Longitude of the venue location in degrees 16 | pub(crate) longitude: Float, 17 | /// Title of the venue 18 | pub(crate) title: String, 19 | /// Address of the venue 20 | pub(crate) address: String, 21 | /// Foursquare identifier of the venue if known 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) foursquare_id: Option, 24 | /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) 25 | #[serde(skip_serializing_if = "Option::is_none")] 26 | pub(crate) foursquare_type: Option, 27 | /// Inline keyboard attached to the message 28 | #[serde(skip_serializing_if = "Option::is_none")] 29 | pub(crate) reply_markup: Option, 30 | /// Content of the message to be sent instead of the venue 31 | #[serde(skip_serializing_if = "Option::is_none")] 32 | pub(crate) input_message_content: Option, 33 | /// Url of the thumbnail for the result 34 | #[serde(skip_serializing_if = "Option::is_none")] 35 | pub(crate) thumb_url: Option, 36 | /// Thumbnail width 37 | #[serde(skip_serializing_if = "Option::is_none")] 38 | pub(crate) thumb_width: Option, 39 | /// Thumbnail height 40 | #[serde(skip_serializing_if = "Option::is_none")] 41 | pub(crate) thumb_height: Option, 42 | } -------------------------------------------------------------------------------- /src/raw/methods/set_webhook.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. 4 | /// If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. 5 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 6 | #[return_type = "True"] 7 | #[new(vis = "pub")] 8 | #[set(vis = "pub")] 9 | pub struct SetWebhook { 10 | /// HTTPS url to send updates to. Use an empty string to remove webhook integration 11 | pub(crate) url: String, 12 | /// Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details. 13 | #[serde(skip_serializing_if = "Option::is_none")] 14 | pub(crate) certificate: Option, 15 | /// Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot‘s server, and higher values to increase your bot’s throughput. 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) max_connections: Option, 18 | /// List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) allowed_updates: Option>, 21 | } -------------------------------------------------------------------------------- /src/raw/types/input_media_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an audio file to be treated as music to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the audio to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | /// Duration of the audio in seconds 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) duration: Option, 25 | /// Performer of the audio 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) performer: Option, 28 | /// Title of the audio 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) title: Option, 31 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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 to send a message with the specified content instead of the photo. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB 14 | pub(crate) photo_url: String, 15 | /// URL of the thumbnail for the photo 16 | pub(crate) thumb_url: String, 17 | /// Width of the photo 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) photo_width: Option, 20 | /// Height of the photo 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) photo_height: Option, 23 | /// Title for the result 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) title: Option, 26 | /// Short description of the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) description: Option, 29 | /// Caption of the photo to be sent, 0-1024 characters 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) caption: Option, 32 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) parse_mode: Option, 35 | /// Inline keyboard attached to the message 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) reply_markup: Option, 38 | /// Content of the message to be sent instead of the photo 39 | #[serde(skip_serializing_if = "Option::is_none")] 40 | pub(crate) input_message_content: Option, 41 | } -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultGif { 8 | /// Type of the result, must be gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the GIF file. File size must not exceed 1MB 14 | pub(crate) gif_url: String, 15 | /// Width of the GIF 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) gif_width: Option, 18 | /// Height of the GIF 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) gif_height: Option, 21 | /// Duration of the GIF 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) gif_duration: Option, 24 | /// URL of the static thumbnail for the result (jpeg or gif) 25 | pub(crate) thumb_url: String, 26 | /// Title for the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) title: Option, 29 | /// Caption of the GIF file to be sent, 0-1024 characters 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) caption: Option, 32 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) parse_mode: Option, 35 | /// Inline keyboard attached to the message 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) reply_markup: Option, 38 | /// Content of the message to be sent instead of the GIF animation 39 | #[serde(skip_serializing_if = "Option::is_none")] 40 | pub(crate) input_message_content: Option, 41 | } -------------------------------------------------------------------------------- /src/raw/types/input_media_animation.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaAnimation { 8 | /// Type of the result, must be animation 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the animation to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | /// Animation width 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) width: Option, 25 | /// Animation height 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) height: Option, 28 | /// Animation duration 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) duration: Option, 31 | } -------------------------------------------------------------------------------- /src/types/input_media_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InputFileOrString, Integer, ParseMode}; 2 | 3 | /// Represents an audio file to be treated as music to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaAudio { 8 | /// Type of the result, must be audio 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the audio to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | /// Duration of the audio in seconds 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) duration: Option, 25 | /// Performer of the audio 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) performer: Option, 28 | /// Title of the audio 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) title: Option, 31 | } 32 | -------------------------------------------------------------------------------- /src/types/input_media_animation.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InputFileOrString, Integer, ParseMode}; 2 | 3 | /// Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaAnimation { 8 | /// Type of the result, must be animation 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the animation to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | /// Animation width 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) width: Option, 25 | /// Animation height 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) height: Option, 28 | /// Animation duration 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) duration: Option, 31 | } 32 | -------------------------------------------------------------------------------- /src/raw/types/inline_query_result_mpeg4_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultMpeg4Gif { 8 | /// Type of the result, must be mpeg4_gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the MP4 file. File size must not exceed 1MB 14 | pub(crate) mpeg4_url: String, 15 | /// Video width 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) mpeg4_width: Option, 18 | /// Video height 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) mpeg4_height: Option, 21 | /// Video duration 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) mpeg4_duration: Option, 24 | /// URL of the static thumbnail (jpeg or gif) for the result 25 | pub(crate) thumb_url: String, 26 | /// Title for the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) title: Option, 29 | /// Caption of the MPEG-4 file to be sent, 0-1024 characters 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) caption: Option, 32 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) parse_mode: Option, 35 | /// Inline keyboard attached to the message 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) reply_markup: Option, 38 | /// Content of the message to be sent instead of the video animation 39 | #[serde(skip_serializing_if = "Option::is_none")] 40 | pub(crate) input_message_content: Option, 41 | } -------------------------------------------------------------------------------- /src/types/inline_query_result_photo.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, Integer, ParseMode}; 2 | 3 | /// 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 to send a message with the specified content instead of the photo. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultPhoto { 8 | /// Type of the result, must be photo 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB 14 | pub(crate) photo_url: String, 15 | /// URL of the thumbnail for the photo 16 | pub(crate) thumb_url: String, 17 | /// Width of the photo 18 | #[serde(skip_serializing_if = "Option::is_none")] 19 | pub(crate) photo_width: Option, 20 | /// Height of the photo 21 | #[serde(skip_serializing_if = "Option::is_none")] 22 | pub(crate) photo_height: Option, 23 | /// Title for the result 24 | #[serde(skip_serializing_if = "Option::is_none")] 25 | pub(crate) title: Option, 26 | /// Short description of the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) description: Option, 29 | /// Caption of the photo to be sent, 0-1024 characters 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) caption: Option, 32 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) parse_mode: Option, 35 | /// Inline keyboard attached to the message 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) reply_markup: Option, 38 | /// Content of the message to be sent instead of the photo 39 | #[serde(skip_serializing_if = "Option::is_none")] 40 | pub(crate) input_message_content: Option, 41 | } 42 | -------------------------------------------------------------------------------- /src/types/inline_query_result_gif.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{InlineKeyboardMarkup, InputMessageContent, Integer, ParseMode}; 2 | 3 | /// 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. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InlineQueryResultGif { 8 | /// Type of the result, must be gif 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// Unique identifier for this result, 1-64 bytes 12 | pub(crate) id: String, 13 | /// A valid URL for the GIF file. File size must not exceed 1MB 14 | pub(crate) gif_url: String, 15 | /// Width of the GIF 16 | #[serde(skip_serializing_if = "Option::is_none")] 17 | pub(crate) gif_width: Option, 18 | /// Height of the GIF 19 | #[serde(skip_serializing_if = "Option::is_none")] 20 | pub(crate) gif_height: Option, 21 | /// Duration of the GIF 22 | #[serde(skip_serializing_if = "Option::is_none")] 23 | pub(crate) gif_duration: Option, 24 | /// URL of the static thumbnail for the result (jpeg or gif) 25 | pub(crate) thumb_url: String, 26 | /// Title for the result 27 | #[serde(skip_serializing_if = "Option::is_none")] 28 | pub(crate) title: Option, 29 | /// Caption of the GIF file to be sent, 0-1024 characters 30 | #[serde(skip_serializing_if = "Option::is_none")] 31 | pub(crate) caption: Option, 32 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 33 | #[serde(skip_serializing_if = "Option::is_none")] 34 | pub(crate) parse_mode: Option, 35 | /// Inline keyboard attached to the message 36 | #[serde(skip_serializing_if = "Option::is_none")] 37 | pub(crate) reply_markup: Option, 38 | /// Content of the message to be sent instead of the GIF animation 39 | #[serde(skip_serializing_if = "Option::is_none")] 40 | pub(crate) input_message_content: Option, 41 | } 42 | -------------------------------------------------------------------------------- /src/application/resourse.rs: -------------------------------------------------------------------------------- 1 | use crate::actors::TelegramApi; 2 | use crate::types::{ 3 | update::{Update, UpdateKind}, 4 | Message, 5 | }; 6 | use actix::Addr; 7 | use failure::Error; 8 | 9 | pub struct Resource<'a, U, S> { 10 | pub(super) value: U, 11 | pub(super) state: &'a S, 12 | pub(super) telegram_api: &'a Addr, 13 | } 14 | 15 | impl<'a, V, S> Resource<'a, V, S> { 16 | #[inline] 17 | pub fn map(self, function: F) -> Result, Error> 18 | where 19 | F: FnOnce(V) -> Result, 20 | { 21 | Ok(Resource { 22 | value: function(self.value)?, 23 | state: self.state, 24 | telegram_api: self.telegram_api, 25 | }) 26 | } 27 | 28 | #[inline] 29 | pub fn f(self, function: F) -> Result<(), Error> 30 | where 31 | F: FnOnce(V, &'a Addr, &'a S) -> Result<(), Error>, 32 | { 33 | function(self.value, self.telegram_api, self.state) 34 | } 35 | } 36 | 37 | impl<'a, S> Resource<'a, &'a Message, S> { 38 | #[inline] 39 | pub fn command(self, function: F, command: &str) -> Result<(), Error> 40 | where 41 | F: FnOnce(&'a Message, &'a Addr, &'a S) -> Result<(), Error>, 42 | { 43 | let message = self.value; 44 | ensure!(message.bot_command(command).is_some(), "is not bot command"); 45 | function(message, self.telegram_api, self.state) 46 | } 47 | } 48 | 49 | impl<'a, S> Resource<'a, &'a Update, S> { 50 | #[inline] 51 | pub fn message(self) -> Result, Error> { 52 | if let UpdateKind::Message(message) = self.value.kind() { 53 | Ok(Resource { 54 | value: message, 55 | state: self.state, 56 | telegram_api: self.telegram_api, 57 | }) 58 | } else { 59 | bail!("is not a message") 60 | } 61 | } 62 | 63 | #[inline(always)] 64 | pub fn command(self, function: F, starts_with: &str) -> Result<(), Error> 65 | where 66 | F: FnOnce(&'a Message, &'a Addr, &'a S) -> Result<(), Error>, 67 | { 68 | self.message()?.command(function, starts_with) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/raw/types/input_media_video.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Represents a video to be sent. 4 | #[derive(Debug, Serialize, Setters, New)] 5 | #[new(vis = "pub")] 6 | #[set(vis = "pub")] 7 | pub struct InputMediaVideo { 8 | /// Type of the result, must be video 9 | #[serde(rename = "type")] 10 | pub(crate) type_: String, 11 | /// File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » 12 | pub(crate) media: InputFileOrString, 13 | /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) thumb: Option, 16 | /// Caption of the video to be sent, 0-1024 characters 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) caption: Option, 19 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) parse_mode: Option, 22 | /// Video width 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) width: Option, 25 | /// Video height 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) height: Option, 28 | /// Video duration 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) duration: Option, 31 | /// Pass True, if the uploaded video is suitable for streaming 32 | #[serde(skip_serializing_if = "Option::is_none")] 33 | pub(crate) supports_streaming: Option, 34 | } -------------------------------------------------------------------------------- /src/raw/methods/send_voice.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | /// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. 4 | #[derive(Debug, Serialize, TelegramApi, Setters, New)] 5 | #[return_type = "Message"] 6 | #[new(vis = "pub")] 7 | #[set(vis = "pub")] 8 | pub struct SendVoice { 9 | /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) 10 | pub(crate) chat_id: ChatIdOrUsername, 11 | /// Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files » 12 | pub(crate) voice: InputFileOrString, 13 | /// Voice message caption, 0-1024 characters 14 | #[serde(skip_serializing_if = "Option::is_none")] 15 | pub(crate) caption: Option, 16 | /// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub(crate) parse_mode: Option, 19 | /// Duration of the voice message in seconds 20 | #[serde(skip_serializing_if = "Option::is_none")] 21 | pub(crate) duration: Option, 22 | /// Sends the message silently. Users will receive a notification with no sound. 23 | #[serde(skip_serializing_if = "Option::is_none")] 24 | pub(crate) disable_notification: Option, 25 | /// If the message is a reply, ID of the original message 26 | #[serde(skip_serializing_if = "Option::is_none")] 27 | pub(crate) reply_to_message_id: Option, 28 | /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. 29 | #[serde(skip_serializing_if = "Option::is_none")] 30 | pub(crate) reply_markup: Option, 31 | } --------------------------------------------------------------------------------