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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use super::{
message_contents::*, message_entity::*, utils::unix_date_formatting, CallbackQuery,
ChatLocation, ChatMemberUpdated, ChatPhoto, ChatType, ChosenInlineResult, Game,
InlineKeyboardMarkup, InlineQuery, Invoice, PassportData, PreCheckoutQuery, ShippingQuery,
Sticker, SuccessfulPayment, User,
};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct RawMessage {
pub message_id: i64,
pub from: Option<super::User>,
pub sender_chat: Option<RawChat>,
#[serde(with = "unix_date_formatting")]
pub date: DateTime<Utc>,
pub chat: RawChat,
pub forward_from: Option<super::User>,
pub forward_from_chat: Option<RawChat>,
pub forward_from_message_id: Option<i64>,
pub forward_signature: Option<String>,
pub forward_sender_name: Option<String>,
#[serde(default)]
#[serde(with = "unix_date_formatting::optional")]
pub forward_date: Option<DateTime<Utc>>,
pub reply_to_message: Option<Box<RawMessage>>,
pub via_bot: Option<User>,
#[serde(default)]
#[serde(with = "unix_date_formatting::optional")]
pub edit_date: Option<DateTime<Utc>>,
pub media_group_id: Option<String>,
pub author_signature: Option<String>,
pub text: Option<String>,
pub entities: Option<Vec<MessageEntity>>,
pub caption_entities: Option<Vec<MessageEntity>>,
pub audio: Option<Audio>,
pub document: Option<Document>,
pub animation: Option<Animation>,
pub game: Option<Game>,
pub photo: Option<Vec<PhotoSize>>,
pub sticker: Option<Sticker>,
pub video: Option<Video>,
pub voice: Option<Voice>,
pub video_note: Option<VideoNote>,
pub caption: Option<String>,
pub contact: Option<Contact>,
pub location: Option<Location>,
pub venue: Option<Venue>,
pub poll: Option<Poll>,
pub dice: Option<Dice>,
pub new_chat_members: Option<Vec<User>>,
pub left_chat_member: Option<User>,
pub new_chat_title: Option<String>,
pub new_chat_photo: Option<Vec<PhotoSize>>,
#[serde(default)]
pub delete_chat_photo: bool,
#[serde(default)]
pub group_chat_created: bool,
#[serde(default)]
pub supergroup_chat_created: bool,
#[serde(default)]
pub channel_chat_created: bool,
pub message_auto_delete_timer_changed: Option<MessageAutoDeleteTimerChanged>,
pub migrate_to_chat_id: Option<i64>,
pub migrate_from_chat_id: Option<i64>,
pub pinned_message: Option<Box<RawMessage>>,
pub invoice: Option<Invoice>,
pub successful_payment: Option<SuccessfulPayment>,
pub connected_website: Option<String>,
pub passport_data: Option<PassportData>,
pub proximity_alert_triggered: Option<ProximityAlertTriggered>,
pub reply_markup: Option<InlineKeyboardMarkup>,
pub voice_chat_scheduled: Option<VoiceChatScheduled>,
pub voice_chat_started: Option<VoiceChatStarted>,
pub voice_chat_ended: Option<VoiceChatEnded>,
pub voice_chat_participants_invited: Option<VoiceChatParticipantsInvited>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct RawChat {
pub id: i64,
#[serde(rename = "type")]
pub chat_type: ChatType,
pub title: Option<String>,
pub username: Option<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub photo: Option<ChatPhoto>,
pub bio: Option<String>,
pub description: Option<String>,
pub invite_link: Option<String>,
pub pinned_message: Option<Box<RawMessage>>,
pub permissions: Option<super::ChatPermissions>,
pub slow_mode_delay: Option<usize>,
pub sticker_set_name: Option<String>,
pub can_set_sticker_set: Option<bool>,
pub linked_chat_id: Option<i64>,
pub location: Option<ChatLocation>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct RawUpdate {
pub update_id: i64,
pub message: Option<RawMessage>,
pub edited_message: Option<RawMessage>,
pub channel_post: Option<RawMessage>,
pub edited_channel_post: Option<RawMessage>,
pub inline_query: Option<InlineQuery>,
pub chosen_inline_result: Option<ChosenInlineResult>,
pub callback_query: Option<CallbackQuery>,
pub shipping_query: Option<ShippingQuery>,
pub pre_checkout_query: Option<PreCheckoutQuery>,
pub poll: Option<Poll>,
pub poll_answer: Option<PollAnswer>,
pub my_chat_member: Option<ChatMemberUpdated>,
pub chat_member: Option<ChatMemberUpdated>,
}