forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline_types.go
690 lines (547 loc) · 19.7 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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
package telebot
import (
"encoding/json"
)
// InlineQueryResultArticle represents a link to an article or web page.
// See also: https://core.telegram.org/bots/api#inlinequeryresultarticle
type InlineQueryResultArticle struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// Title of the result.
Title string `json:"title"`
// Message text. Shortcut (and mutually exclusive to) specifying
// InputMessageContent.
Text string `json:"message_text,omitempty"`
// Content of the message to be sent.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,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:"thumb_url,omitempty"`
// Optional. Thumbnail width.
ThumbWidth int `json:"thumb_width,omitempty"`
// Optional. Thumbnail height.
ThumbHeight int `json:"thumb_height,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultArticle InlineQueryResultArticle
func (r *InlineQueryResultArticle) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultArticle
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultArticle: wrappedInlineQueryResultArticle(*r),
ID: id,
Type: "article",
})
}
func (r *InlineQueryResultArticle) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultAudio represents a link to an mp3 audio file.
type InlineQueryResultAudio struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// A valid URL for the audio file.
AudioURL string `json:"audio_url"`
// Title.
Title string `json:"title"`
// Optional. Performer.
Performer string `json:"performer,omitempty"`
// Optional. Audio duration in seconds.
Duration int `json:"audio_duration,omitempty"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultAudio InlineQueryResultAudio
func (r *InlineQueryResultAudio) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultAudio
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultAudio: wrappedInlineQueryResultAudio(*r),
ID: id,
Type: "audio",
})
}
func (r *InlineQueryResultAudio) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultContact represents a contact with a phone number.
// See also: https://core.telegram.org/bots/api#inlinequeryresultcontact
type InlineQueryResultContact struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// Contact's phone number.
PhoneNumber string `json:"phone_number"`
// Contact's first name.
FirstName string `json:"first_name"`
// Optional. Contact's last name.
LastName string `json:"last_name,omitempty"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Optional. Url of the thumbnail for the result.
ThumbURL string `json:"thumb_url,omitempty"`
// Optional. Thumbnail width.
ThumbWidth int `json:"thumb_width,omitempty"`
// Optional. Thumbnail height.
ThumbHeight int `json:"thumb_height,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultContact InlineQueryResultContact
func (r *InlineQueryResultContact) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultContact
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultContact: wrappedInlineQueryResultContact(*r),
ID: id,
Type: "contact",
})
}
func (r *InlineQueryResultContact) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultDocument represents a link to a file.
// See also: https://core.telegram.org/bots/api#inlinequeryresultdocument
type InlineQueryResultDocument struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// Title for the result.
Title string `json:"title"`
// A valid URL for the file
DocumentURL string `json:"document_url"`
// Mime type of the content of the file, either “application/pdf” or
// “application/zip”.
MimeType 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. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Optional. URL of the thumbnail (jpeg only) for the file.
ThumbURL string `json:"thumb_url,omitempty"`
// Optional. Thumbnail width.
ThumbWidth int `json:"thumb_width,omitempty"`
// Optional. Thumbnail height.
ThumbHeight int `json:"thumb_height,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultDocument InlineQueryResultDocument
func (r *InlineQueryResultDocument) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultDocument
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultDocument: wrappedInlineQueryResultDocument(*r),
ID: id,
Type: "document",
})
}
func (r *InlineQueryResultDocument) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultGif represents a link to an animated GIF file.
// See also: https://core.telegram.org/bots/api#inlinequeryresultgif
type InlineQueryResultGif struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// A valid URL for the GIF file. File size must not exceed 1MB.
GifURL string `json:"gif_url"`
// URL of the static thumbnail for the result (jpeg or gif).
ThumbURL string `json:"thumb_url"`
// Optional. Width of the GIF.
GifWidth int `json:"gif_width,omitempty"`
// Optional. Height of the GIF.
GifHeight int `json:"gif_height,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"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultGif InlineQueryResultGif
func (r *InlineQueryResultGif) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultGif
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultGif: wrappedInlineQueryResultGif(*r),
ID: id,
Type: "gif",
})
}
func (r *InlineQueryResultGif) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultLocation represents a location on a map.
// See also: https://core.telegram.org/bots/api#inlinequeryresultlocation
type InlineQueryResultLocation struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// Latitude of the location in degrees.
Latitude float32 `json:"latitude"`
// Longitude of the location in degrees.
Longitude float32 `json:"longitude"`
// Location title.
Title string `json:"title"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Optional. Url of the thumbnail for the result.
ThumbURL string `json:"thumb_url,omitempty"`
// Optional. Thumbnail width.
ThumbWidth int `json:"thumb_width,omitempty"`
// Optional. Thumbnail height.
ThumbHeight int `json:"thumb_height,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultLocation InlineQueryResultLocation
func (r *InlineQueryResultLocation) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultLocation
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultLocation: wrappedInlineQueryResultLocation(*r),
ID: id,
Type: "location",
})
}
func (r *InlineQueryResultLocation) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultMpeg4Gif represents a link to a video animation
// (H.264/MPEG-4 AVC video without sound).
// See also: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
type InlineQueryResultMpeg4Gif struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// 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"`
// URL of the static thumbnail (jpeg or gif) for the result.
ThumbURL string `json:"thumb_url,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"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultMpeg4Gif InlineQueryResultMpeg4Gif
func (r *InlineQueryResultMpeg4Gif) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultMpeg4Gif
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultMpeg4Gif: wrappedInlineQueryResultMpeg4Gif(*r),
ID: id,
Type: "mpeg4_gif",
})
}
func (r *InlineQueryResultMpeg4Gif) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultPhoto represents a link to a photo.
// See also: https://core.telegram.org/bots/api#inlinequeryresultphoto
type InlineQueryResultPhoto struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// A valid URL of the photo. Photo must be in jpeg format.
// Photo size must not exceed 5MB.
PhotoURL string `json:"photo_url"`
// URL of the thumbnail for the photo.
ThumbURL string `json:"thumb_url"`
// Optional. Width of the photo.
PhotoWidth int `json:"photo_width,omitempty"`
// Optional. Height of the photo.
PhotoHeight 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"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultPhoto InlineQueryResultPhoto
func (r *InlineQueryResultPhoto) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultPhoto
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultPhoto: wrappedInlineQueryResultPhoto(*r),
ID: id,
Type: "photo",
})
}
func (r *InlineQueryResultPhoto) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultVenue represents a venue.
// See also: https://core.telegram.org/bots/api#inlinequeryresultvenue
type InlineQueryResultVenue struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// Latitude of the venue location in degrees.
Latitude float32 `json:"latitude"`
// Longitude of the venue location in degrees.
Longitude float32 `json:"longitude"`
// 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. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Optional. Url of the thumbnail for the result.
ThumbURL string `json:"thumb_url,omitempty"`
// Optional. Thumbnail width.
ThumbWidth int `json:"thumb_width,omitempty"`
// Optional. Thumbnail height.
ThumbHeight int `json:"thumb_height,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultVenue InlineQueryResultVenue
func (r *InlineQueryResultVenue) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultVenue
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultVenue: wrappedInlineQueryResultVenue(*r),
ID: id,
Type: "venue",
})
}
func (r *InlineQueryResultVenue) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultVideo represents a link to a page containing an embedded
// video player or a video file.
// See also: https://core.telegram.org/bots/api#inlinequeryresultvideo
type InlineQueryResultVideo struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// A valid URL for the embedded video player or video file.
VideoURL string `json:"video_url"`
// Mime type of the content of video url, “text/html” or “video/mp4”.
MimeType string `json:"mime_type"`
// URL of the thumbnail (jpeg only) for the video.
ThumbURL string `json:"thumb_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.
VideoWidth int `json:"video_width,omitempty"`
// Optional. Video height.
VideoHeight int `json:"video_height,omitempty"`
// Optional. Video duration in seconds.
VideoDuration int `json:"video_duration,omitempty"`
// Optional. Short description of the result.
Description string `json:"description,omitempty"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultVideo InlineQueryResultVideo
func (r *InlineQueryResultVideo) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultVideo
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultVideo: wrappedInlineQueryResultVideo(*r),
ID: id,
Type: "video",
})
}
func (r *InlineQueryResultVideo) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}
// InlineQueryResultVoice represents a link to a voice recording in a
// .ogg container encoded with OPUS.
// See also: https://core.telegram.org/bots/api#inlinequeryresultvoice
type InlineQueryResultVoice struct {
// Unique identifier for this result, 1-64 Bytes.
// If left unspecified, a 64-bit FNV-1 hash will be calculated
// from the other fields and used automatically.
ID string `json:"id",hash:"ignore"`
// A valid URL for the voice recording.
VoiceURL string `json:"voice_url"`
// Recording title.
Title string `json:"title"`
// Optional. Recording duration in seconds.
VoiceDuration int `json:"voice_duration"`
// Optional. Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Optional. Content of the message to be sent instead of the audio.
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// Used to avoid endless recursion in MarshalJSON.
type wrappedInlineQueryResultVoice InlineQueryResultVoice
func (r *InlineQueryResultVoice) MarshalJSON() ([]byte, error) {
id, err := r.id()
if err != nil {
return nil, err
}
return json.Marshal(struct {
wrappedInlineQueryResultVoice
Type string `json:"type"`
ID string `json:"id",hash:"ignore"`
}{
wrappedInlineQueryResultVoice: wrappedInlineQueryResultVoice(*r),
ID: id,
Type: "voice",
})
}
func (r *InlineQueryResultVoice) id() (string, error) {
if r.ID == "" {
return hashInlineQueryResult(r)
} else {
return r.ID, nil
}
}