add struct

This commit is contained in:
fedechkin_alexey 2019-09-02 20:51:03 +07:00
parent e1be16fba2
commit b41f3cbe27
8 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,19 @@
use serde::Deserialize;
/// This object represents an incoming callback query from a callback button in an inline keyboard.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct CallbackQuery {
/// Unique identifier for this query
pub id: CallbackQueryId,
/// Sender
pub from: User,
/// Message with the callback button that originated the query.
/// Note that message content and message date will not be available if the message is too old
pub message: Message,
/// Global identifier, uniquely corresponding to the chat to which the message
/// with the callback button was sent. Useful for high scores in games.
pub chat_instance: String,
/// Data associated with the callback button. Be aware that a bad client can
/// send arbitrary data in this field.
pub data: String,
}

View file

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

View file

@ -0,0 +1,13 @@
use serde::Deserialize;
/// 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 bots 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 mod
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct ForceReply {
force_reply: True,
#[serde(skip_serializing_if = "Not::not")]
selective: bool,
}

View file

@ -0,0 +1,20 @@
use serde::Deserialize;
/// This object represents one button of an inline keyboard.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct InlineKeyboardButton {
text: String,
#[serde(flatten)]
kind: InlineKeyboardButtonKind,
}
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
pub enum InlineKeyboardButtonKind {
#[serde(rename = "url")]
Url(String), // TODO(knsd): Url?
#[serde(rename = "callback_data")]
CallbackData(String), // TODO(knsd) Validate size?
// SwitchInlineQuery(String),
// SwitchInlineQueryCurrentChat(String),
// CallbackGame(CallbackGame),
}

View file

@ -0,0 +1,7 @@
use serde::Deserialize;
/// This object represents an inline keyboard that appears right next to the message it belongs to.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct InlineKeyboardMarkup {
inline_keyboard: Vec<Vec<InlineKeyboardButton>>,
}

View file

@ -0,0 +1,11 @@
use serde::Deserialize;
/// This object represents one button of the reply keyboard.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct KeyboardButton {
text: String,
#[serde(skip_serializing_if = "Not::not")]
request_contact: bool,
#[serde(skip_serializing_if = "Not::not")]
request_location: bool,
}

View file

@ -0,0 +1,13 @@
use serde::Deserialize;
/// This object represents a custom keyboard with reply options.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct ReplyKeyboardMarkup {
keyboard: Vec<Vec<KeyboardButton>>,
#[serde(skip_serializing_if = "Not::not")]
resize_keyboard: bool,
#[serde(skip_serializing_if = "Not::not")]
one_time_keyboard: bool,
#[serde(skip_serializing_if = "Not::not")]
selective: bool,
}

View file

@ -0,0 +1,13 @@
use serde::Deserialize;
/// 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).
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
pub struct ReplyKeyboardRemove {
remove_keyboard: True,
#[serde(skip_serializing_if = "Not::not")]
selective: bool,
}