1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use serde::Deserialize;
use serde_json::Value;

#[derive(Deserialize, Debug, PartialEq)]
pub struct Ctx {
    pub ts: String,
    pub updates: Vec<Update>,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Update {
    pub event_id: String,
    // Bot group ID                         (bot)
    pub group_id: u64,
    // Update object                        (anything)
    pub object: UpdateObject,
    #[serde(rename = "type")]
    pub update_type: String,
    // VK api version                       (const / DO NOT CHANGE)
    pub v: String,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct UpdateObject {
    // Information about user               (message)
    pub client_info: Option<ClientInfo>,
    // Message object                       (message)
    pub message: Option<Message>,
    // Conversation message ID              (message)
    pub cmid: Option<i32>,
    // unique ID for your button            (keyboard)
    pub event_id: Option<String>,
    // Unique ID for conversation / groups  (message)
    pub peer_id: Option<u64>,
    // Who wrote message                    (message)
    pub user_id: Option<u64>,
    // Your custom payload for your button  (keyboard)
    pub payload: Option<Value>,
    // Reacted id                           (message)
    pub reacted_id: Option<u64>,
    // Reaction id                          (message)
    pub reaction_id: Option<u64>,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct ClientInfo {
    pub button_actions: Vec<String>,
    pub carousel: bool,
    pub inline_keyboard: bool,
    pub keyboard: bool,
    pub lang_id: usize,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct Message {
    pub attachments: Vec<Attachment>,
    pub conversation_message_id: u64,
    pub date: u64,
    pub from_id: u64,
    pub fwd_message: Option<Vec<String>>,
    pub id: u64,
    pub important: bool,
    pub is_hidden: bool,
    pub is_unavailable: bool,
    pub out: u64,
    pub peer_id: u64,
    pub random_id: u64,
    pub text: String,
    pub version: u64,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct Attachments {
    photo: Option<Vec<Attachment>>,
    video: Option<Vec<Attachment>>,
    #[serde(rename = "type")]
    attachment_type: String,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct Attachment {
    #[serde(rename = "type")]
    pub attachment_type: String,
    pub photo: Option<Photo>,
    pub video: Option<Video>,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct Photo {
    pub access_key: String,
    pub album_id: i32,
    pub date: u32,
    pub has_tags: bool,
    pub id: u64,
    pub owner_id: u64,
    pub sizes: Vec<AttachmentSize>,
    pub text: String,
    pub web_view_token: String,
}

#[derive(Debug, Deserialize, PartialEq)]
pub struct AttachmentSize {
    height: usize,
    #[serde(rename = "type")]
    size_type: String,
    url: String,
    width: usize,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Video {
    access_key: String,
    can_add: i32,
    content_restricted: i32,
    date: i64,
    duration: i64,
    height: i32,
    id: i64,
    image: Vec<Image>,
    is_private: i32,
    owner_id: i64,
    response_type: String,
    restriction: Restriction,
    title: String,
    track_code: String,
    #[serde(rename = "type")]
    video_type: String,
    views: i32,
    width: i32,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Image {
    height: i32,
    url: String,
    width: i32,
    with_padding: i32,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Restriction {
    blur: i32,
    can_play: i32,
    can_preview: i32,
    card_icon: Vec<Icon>,
    disclaimer_type: i32,
    icon_name: String,
    list_icon: Vec<Icon>,
    text: String,
    title: String,
}

#[derive(Deserialize, Debug, PartialEq)]
pub struct Icon {
    height: i32,
    url: String,
    width: i32,
}