forked from NicoNex/echotron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
274 lines (245 loc) · 10.2 KB
/
types.go
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
* Echotron
* Copyright (C) 2019 Nicolò Santamaria, Michele Dimaggio
*
* Echotron is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Echotron is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package echotron
// This object represents a chat.
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
AllMembersAreAdmin bool `json:"all_members_are_administrators,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
}
// This object represents a Telegram user or bot.
type User struct {
ID int `json:"id"`
IsBot bool `json:"is_bot"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Username string `json:"username,omitempty"`
LanguageCode string `json:"language_code,omitempty"`
}
// This object represents one special entity in a text message.
// For example, hashtags, usernames, URLs, etc.
type MessageEntity struct {
Type string `json:"type"`
Offset int `json:"offset"`
Length int `json:"Length"`
Url string `json:"url,omitempty"`
User *User `json:"user,omitempty"`
}
// WIP: this object represents a message.
type Message struct {
ID int `json:"message_id"`
User *User `json:"from"`
Chat *Chat `json:"chat"`
Date int64 `json:"date"`
Text string `json:"text"`
Entities []*MessageEntity `json:"entities,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Document *Document `json:"document,omitempty"`
Photo []*PhotoSize `json:"photo,omitempty"`
MediaGroupId string `json:"media_group_id,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
Video *Video `json:"video,omitempty"`
VideoNote *VideoNote `json:"video_note,omitempty"`
Voice *Voice `json:"voice,omitempty"`
Caption string `json:"caption,omitempty"`
Contact *Contact `json:"contact,omitempty"`
Location *Location `json:"location,omitempty"`
NewChatMember []*User `json:"new_chat_members,omitempty"`
LeftChatMember *User `json:"left_chat_member,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
}
// This object represents an incoming update.
// At most one of the optional parameters can be present in any given update.
type Update struct {
ID int `json:"update_id"`
Message *Message `json:"message,omitempty"`
EditedMessage *Message `json:"edited_message,omitempty"`
ChannelPost *Message `json:"channel_post,omitempty"`
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
InlineQuery *InlineQuery `json:"inline_query,omitempty"`
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
}
// This object represents the incoming response from Telegram servers.
// Used by getUpdates (since it returns an array of Updates).
type APIResponseUpdate struct {
Ok bool `json:"ok"`
Result []*Update `json:"result,omitempty"`
ErrorCode int `json:"error_code,omitempty"`
Description string `json:"description,omitempty"`
}
// This object represents the incoming response from Telegram servers.
// Used by the methods in the api.go module (since they return a Message).
type APIResponseMessage struct {
Ok bool `json:"ok"`
Result *Message `json:"result,omitempty"`
ErrorCode int `json:"error_code,omitempty"`
Description string `json:"description,omitempty"`
}
// This object represents a phone contact.
type Contact struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
UserID int `json:"user_id,omitempty"`
Vcard string `json:"vcard,omitempty"`
}
// This object represents a point on the map.
type Location struct {
Longitude float32
Latitude float32
}
// This object represents an incoming inline query.
// When the user sends an empty query, your bot could return some default or trending results.
type InlineQuery struct {
ID string `json:"id"`
User *User `json:"user"`
Query string `json:"query"`
Offset string `json:"offset"`
}
// Represents a result of an inline query that was chosen by the user and sent to their chat partner.
type ChosenInlineResult struct {
ID string `json:"result_id"`
User *User `json:"user"`
InlineMessageId string `json:"inline_message_id,omitempty"`
Query string `json:"query,omitempty"`
}
// 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.
type CallbackQuery struct {
ID string `json:"id"`
User *User `json:"user"`
Message string `json:"message,omitempty"`
InlineMessageId string `json:"inline_message_id,omitempty"`
}
// This object represents an audio file to be treated as music by the Telegram clients.
type Audio struct {
FileId string `json:"file_id"`
Duration int `json:"duration"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
Thumb *PhotoSize `json:"thumb,omitempty"`
}
// This object represents a video file.
type Video struct {
FileId string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumb *PhotoSize `json:"thumb,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
// This object represents a video message.
type VideoNote struct {
FileId string `json:"file_id"`
Length int `json:"length"`
Duration int `json:"duration"`
Thumb *PhotoSize `json:"thumb,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
// This object represents a general file (as opposed to photos, voice messages and audio files).
type Document struct {
FileId string `json:"file_id"`
Thumb *PhotoSize `json:"thumb,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
// This object represents one size of a photo or a file / sticker thumbnail.
type PhotoSize struct {
FileId string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
FileSize int `json:"FileSize"`
}
// This object represents a voice note.
type Voice struct {
FileId string `json:"file_id"`
Duration int `json:"duration"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"FileSize,omitempty"`
}
// This object describes the position on faces where a mask should be placed by default.
type MaskPosition struct {
Point string `json:"point"`
XShift float32 `json:"x_shift"`
YShift float32 `json:"y_shift"`
Scale float32 `json:"scale"`
}
// This object represents a sticker.
type Sticker struct {
FileId string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
Thumb *PhotoSize `json:"thumb,omitempty"`
Emoji string `json:"emoji,omitempty"`
SetName string `json:"set_name,omitempty"`
FileSize int `json:"file_size,omitempty"`
MaskPosition MaskPosition `json:"mask_position"`
}
// This object represents a sticker set.
type StickerSet struct {
Name string `json:"name"`
Title string `json:"title"`
ContainsMasks bool `json:"contains_masks"`
Stickers []*Sticker `json:"sticker"`
}
// This object represents a button in a keyboard.
type Button struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact,omitempty"`
RequestLocation bool `json:"request_location,omitempty"`
}
// This object represents a row of buttons in a keyboard.
type KbdRow []Button
// This object represents a keyboard.
type Keyboard struct {
Keyboard []KbdRow `json:"keyboard"`
ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
Selective bool `json:"selective,omitempty"`
}
// This object represents a keyboard removal request.
type KeyboardRemove struct {
RemoveKeyboard bool `json:"remove_keyboard"`
Selective bool `json:"selective,omitempty"`
}
// This object represents a button in an inline keyboard.
type InlineButton struct {
Text string `json:"text"`
URL string `json:"url,omitempty"`
CallbackData string `json:"callback_data,omitempty"`
}
// This object represents a row of buttons in an inline keyboard.
type InlineKbdRow []InlineButton
// This object represents an inline keyboard.
type InlineKeyboard struct {
InlineKeyboard []InlineKbdRow `json:"inline_keyboard"`
}