mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
add struct
This commit is contained in:
parent
e1be16fba2
commit
b41f3cbe27
8 changed files with 134 additions and 0 deletions
19
src/core/types/CallbackQuery.rs
Normal file
19
src/core/types/CallbackQuery.rs
Normal 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,
|
||||
}
|
38
src/core/types/ChatMember.rs
Normal file
38
src/core/types/ChatMember.rs
Normal 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>,
|
||||
}
|
13
src/core/types/ForceReply.rs
Normal file
13
src/core/types/ForceReply.rs
Normal 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 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 mod
|
||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq)]
|
||||
pub struct ForceReply {
|
||||
force_reply: True,
|
||||
#[serde(skip_serializing_if = "Not::not")]
|
||||
selective: bool,
|
||||
}
|
20
src/core/types/InlineKeyboardButton.rs
Normal file
20
src/core/types/InlineKeyboardButton.rs
Normal 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),
|
||||
}
|
7
src/core/types/InlineKeyboardMarkup.rs
Normal file
7
src/core/types/InlineKeyboardMarkup.rs
Normal 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>>,
|
||||
}
|
11
src/core/types/KeyboardButton.rs
Normal file
11
src/core/types/KeyboardButton.rs
Normal 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,
|
||||
}
|
13
src/core/types/ReplyKeyboardMarkup.rs
Normal file
13
src/core/types/ReplyKeyboardMarkup.rs
Normal 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,
|
||||
}
|
13
src/core/types/ReplyKeyboardRemove.rs
Normal file
13
src/core/types/ReplyKeyboardRemove.rs
Normal 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,
|
||||
}
|
Loading…
Reference in a new issue