forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline_types.go
395 lines (284 loc) · 10.8 KB
/
inline_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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
package telebot
// ResultBase must be embedded into all IQRs.
type ResultBase struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
ID string `json:"id"`
// Ignore. This field gets set automatically.
Type string `json:"type"`
// Optional. Send Markdown or HTML, if you want Telegram apps to show
// bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode ParseMode `json:"parse_mode,omitempty"`
// Optional. Content of the message to be sent.
Content InputMessageContent `json:"input_message_content,omitempty"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// ResultID returns ResultBase.ID.
func (r *ResultBase) ResultID() string {
return r.ID
}
// SetResultID sets ResultBase.ID.
func (r *ResultBase) SetResultID(id string) {
r.ID = id
}
// SetParseMode sets ResultBase.ParseMode.
func (r *ResultBase) SetParseMode(mode ParseMode) {
r.ParseMode = mode
}
// SetContent sets ResultBase.Content.
func (r *ResultBase) SetContent(content InputMessageContent) {
r.Content = content
}
// SetReplyMarkup sets ResultBase.ReplyMarkup.
func (r *ResultBase) SetReplyMarkup(markup *ReplyMarkup) {
r.ReplyMarkup = markup
}
func (r *ResultBase) Process(b *Bot) {
if r.ParseMode == ModeDefault {
r.ParseMode = b.parseMode
}
if r.Content != nil {
c, ok := r.Content.(*InputTextMessageContent)
if ok && c.ParseMode == ModeDefault {
c.ParseMode = r.ParseMode
}
}
if r.ReplyMarkup != nil {
processButtons(r.ReplyMarkup.InlineKeyboard)
}
}
// GameResult represents a game. Game is a content type
// supported by Telegram, which can be sent back to the
// user as a result for an inline query.
type GameResult struct {
ResultBase
// ShortName is a unique identifier of the game.
ShortName string `json:"game_short_name"`
}
// ArticleResult represents a link to an article or web page.
type ArticleResult struct {
ResultBase
// Title of the result.
Title string `json:"title"`
// Message text. Shortcut (and mutually exclusive to) specifying
// InputMessageContent.
Text string `json:"message_text,omitempty"`
// Optional. URL of the result.
URL string `json:"url,omitempty"`
// Optional. Pass True, if you don't want the URL to be shown in the message.
HideURL bool `json:"hide_url,omitempty"`
// Optional. Short description of the result.
Description string `json:"description,omitempty"`
// Optional. URL of the thumbnail for the result.
ThumbURL string `json:"thumbnail_url,omitempty"`
// Optional. Width of the thumbnail for the result.
ThumbWidth int `json:"thumbnail_width,omitempty"`
// Optional. Height of the thumbnail for the result.
ThumbHeight int `json:"thumbnail_height,omitempty"`
}
// AudioResult represents a link to an mp3 audio file.
type AudioResult struct {
ResultBase
// Title.
Title string `json:"title"`
// A valid URL for the audio file.
URL string `json:"audio_url"`
// Optional. Performer.
Performer string `json:"performer,omitempty"`
// Optional. Audio duration in seconds.
Duration int `json:"audio_duration,omitempty"`
// Optional. Caption, 0-1024 characters.
Caption string `json:"caption,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"audio_file_id,omitempty"`
}
// ContactResult represents a contact with a phone number.
type ContactResult struct {
ResultBase
// Contact's phone number.
PhoneNumber string `json:"phone_number"`
// Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes.
VCard string `json:"vcard,omitempty"`
// Contact's first name.
FirstName string `json:"first_name"`
// Optional. Contact's last name.
LastName string `json:"last_name,omitempty"`
// Optional. URL of the thumbnail for the result.
ThumbURL string `json:"thumbnail_url,omitempty"`
// Optional. Width of the thumbnail for the result.
ThumbWidth int `json:"thumbnail_width,omitempty"`
// Optional. Height of the thumbnail for the result.
ThumbHeight int `json:"thumbnail_height,omitempty"`
}
// DocumentResult represents a link to a file.
type DocumentResult struct {
ResultBase
// Title for the result.
Title string `json:"title"`
// A valid URL for the file
URL string `json:"document_url"`
// Mime type of the content of the file, either “application/pdf” or
// “application/zip”.
MIME string `json:"mime_type"`
// Optional. Caption of the document to be sent, 0-200 characters.
Caption string `json:"caption,omitempty"`
// Optional. Short description of the result.
Description string `json:"description,omitempty"`
// Optional. URL of the thumbnail (jpeg only) for the file.
ThumbURL string `json:"thumbnail_url,omitempty"`
// Optional. Width of the thumbnail for the result.
ThumbWidth int `json:"thumbnail_width,omitempty"`
// Optional. Height of the thumbnail for the result.
ThumbHeight int `json:"thumbnail_height,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"document_file_id,omitempty"`
}
// GifResult represents a link to an animated GIF file.
type GifResult struct {
ResultBase
// A valid URL for the GIF file. File size must not exceed 1MB.
URL string `json:"gif_url"`
// Optional. Width of the GIF.
Width int `json:"gif_width,omitempty"`
// Optional. Height of the GIF.
Height int `json:"gif_height,omitempty"`
// Optional. Duration of the GIF.
Duration int `json:"gif_duration,omitempty"`
// URL of the static thumbnail for the result (jpeg or gif).
ThumbURL string `json:"thumbnail_url"`
// Optional. MIME type of the thumbnail, must be one of
// “image/jpeg”, “image/gif”, or “video/mp4”.
ThumbMIME string `json:"thumbnail_mime_type,omitempty"`
// Optional. Title for the result.
Title string `json:"title,omitempty"`
// Optional. Caption of the GIF file to be sent, 0-200 characters.
Caption string `json:"caption,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"gif_file_id,omitempty"`
// (Optional) Pass True, if the caption must be shown above the message media
CaptionAbove bool `json:"show_caption_above_media,omitempty"`
}
// LocationResult represents a location on a map.
type LocationResult struct {
ResultBase
Location
// Location title.
Title string `json:"title"`
// Optional. Url of the thumbnail for the result.
ThumbURL string `json:"thumbnail_url,omitempty"`
}
// Mpeg4GifResult represents a link to a video animation
// (H.264/MPEG-4 AVC video without sound).
type Mpeg4GifResult struct {
ResultBase
// A valid URL for the MP4 file.
URL string `json:"mpeg4_url"`
// Optional. Video width.
Width int `json:"mpeg4_width,omitempty"`
// Optional. Video height.
Height int `json:"mpeg4_height,omitempty"`
// Optional. Video duration.
Duration int `json:"mpeg4_duration,omitempty"`
// URL of the static thumbnail (jpeg or gif) for the result.
ThumbURL string `json:"thumbnail_url,omitempty"`
// Optional. MIME type of the thumbnail, must be one of
// “image/jpeg”, “image/gif”, or “video/mp4”.
ThumbMIME string `json:"thumbnail_mime_type,omitempty"`
// Optional. Title for the result.
Title string `json:"title,omitempty"`
// Optional. Caption of the MPEG-4 file to be sent, 0-200 characters.
Caption string `json:"caption,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"mpeg4_file_id,omitempty"`
// (Optional) Pass True, if the caption must be shown above the message media
CaptionAbove bool `json:"show_caption_above_media,omitempty"`
}
// PhotoResult represents a link to a photo.
type PhotoResult struct {
ResultBase
// A valid URL of the photo. Photo must be in jpeg format.
// Photo size must not exceed 5MB.
URL string `json:"photo_url"`
// Optional. Width of the photo.
Width int `json:"photo_width,omitempty"`
// Optional. Height of the photo.
Height int `json:"photo_height,omitempty"`
// Optional. Title for the result.
Title string `json:"title,omitempty"`
// Optional. Short description of the result.
Description string `json:"description,omitempty"`
// Optional. Caption of the photo to be sent, 0-200 characters.
Caption string `json:"caption,omitempty"`
// URL of the thumbnail for the photo.
ThumbURL string `json:"thumbnail_url"`
// If Cache != "", it'll be used instead
Cache string `json:"photo_file_id,omitempty"`
// (Optional) Pass True, if the caption must be shown above the message media
CaptionAbove bool `json:"show_caption_above_media,omitempty"`
}
// VenueResult represents a venue.
type VenueResult struct {
ResultBase
Location
// Title of the venue.
Title string `json:"title"`
// Address of the venue.
Address string `json:"address"`
// Optional. Foursquare identifier of the venue if known.
FoursquareID string `json:"foursquare_id,omitempty"`
// Optional. URL of the thumbnail for the result.
ThumbURL string `json:"thumbnail_url,omitempty"`
// Optional. Width of the thumbnail for the result.
ThumbWidth int `json:"thumbnail_width,omitempty"`
// Optional. Height of the thumbnail for the result.
ThumbHeight int `json:"thumbnail_height,omitempty"`
}
// VideoResult represents a link to a page containing an embedded
// video player or a video file.
type VideoResult struct {
ResultBase
// A valid URL for the embedded video player or video file.
URL string `json:"video_url"`
// Mime type of the content of video url, “text/html” or “video/mp4”.
MIME string `json:"mime_type"`
// URL of the thumbnail (jpeg only) for the video.
ThumbURL string `json:"thumbnail_url"`
// Title for the result.
Title string `json:"title"`
// Optional. Caption of the video to be sent, 0-200 characters.
Caption string `json:"caption,omitempty"`
// Optional. Video width.
Width int `json:"video_width,omitempty"`
// Optional. Video height.
Height int `json:"video_height,omitempty"`
// Optional. Video duration in seconds.
Duration int `json:"video_duration,omitempty"`
// Optional. Short description of the result.
Description string `json:"description,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"video_file_id,omitempty"`
// (Optional) Pass True, if the caption must be shown above the message media
CaptionAbove bool `json:"show_caption_above_media,omitempty"`
}
// VoiceResult represents a link to a voice recording in an .ogg
// container encoded with OPUS.
type VoiceResult struct {
ResultBase
// A valid URL for the voice recording.
URL string `json:"voice_url"`
// Recording title.
Title string `json:"title"`
// Optional. Recording duration in seconds.
Duration int `json:"voice_duration"`
// Optional. Caption, 0-1024 characters.
Caption string `json:"caption,omitempty"`
// If Cache != "", it'll be used instead
Cache string `json:"voice_file_id,omitempty"`
}
// StickerResult represents an inline cached sticker response.
type StickerResult struct {
ResultBase
// If Cache != "", it'll be used instead
Cache string `json:"sticker_file_id,omitempty"`
}