-
Notifications
You must be signed in to change notification settings - Fork 3
/
inline-mode.go
451 lines (405 loc) · 21 KB
/
inline-mode.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
package telegram
import "context"
type ChatType string
const (
ChatTypeSender ChatType = "sender"
ChatTypePrivate ChatType = "private"
ChatTypeGroup ChatType = "group"
ChatTypeSupergroup ChatType = "supergroup"
ChatTypeChannel ChatType = "channel"
)
// InlineQuery struct
type InlineQuery struct {
ID string `json:"id"`
From User `json:"from"`
Query string `json:"query"`
Offset string `json:"offset"`
ChatType *ChatType `json:"chat_type,omitempty"`
Location *Location `json:"location,omitempty"`
}
// AnswerInlineQueryResponse interface
type AnswerInlineQueryResponse interface {
Response
}
type answerInlineQueryResponse struct {
response
}
func (b *bot) AnswerInlineQuery(ctx context.Context, options ...MethodOption) (AnswerInlineQueryResponse, error) {
var res answerInlineQueryResponse
err := b.doRequest(ctx, "answerInlineQuery", &res, options...)
if err != nil {
return nil, err
}
return &res, nil
}
// InlineQueryResult interface
type InlineQueryResult interface{}
type InlineQueryResultType string
const (
InlineQueryResultTypeArticle = "article"
InlineQueryResultTypePhoto = "photo"
InlineQueryResultTypeGif = "gif"
InlineQueryResultTypeMpeg4Gif = "mpeg4_gif"
InlineQueryResultTypeVideo = "video"
InlineQueryResultTypeAudio = "audio"
InlineQueryResultTypeVoice = "voice"
InlineQueryResultTypeDocument = "document"
InlineQueryResultTypeLocation = "location"
InlineQueryResultTypeVenue = "venue"
InlineQueryResultTypeContact = "contact"
InlineQueryResultTypeGame = "game"
InlineQueryResultTypeSticker = "sticker"
)
// InlineQueryResultArticle struct
type InlineQueryResultArticle struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
InputMessageContent InputMessageContent `json:"input_message_content"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
URL *string `json:"url,omitempty"`
HideURL *bool `json:"hide_url,omitempty"`
Description *string `json:"description,omitempty"`
ThumbURL *string `json:"thumb_url,omitempty"`
ThumbWidth *int `json:"thumb_width,omitempty"`
ThumbHeight *int `json:"thumb_height,omitempty"`
}
// InlineQueryResultPhoto struct
type InlineQueryResultPhoto struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
PhotoURL string `json:"photo_url"`
ThumbURL string `json:"thumb_url"`
PhotoWidth *int `json:"photo_width,omitempty"`
PhotoHeight *int `json:"photo_height,omitempty"`
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultGif struct
type InlineQueryResultGif struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
GifURL string `json:"gif_url"`
GifWidth *int `json:"gif_width,omitempty"`
GifHeight *int `json:"gif_height,omitempty"`
GifDuration *int `json:"gif_duration,omitempty"`
ThumbURL string `json:"thumb_url"`
ThumbMimeType string `json:"thumb_mime_type,omitempty"`
Title *string `json:"title,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultMpeg4Gif struct
type InlineQueryResultMpeg4Gif struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Mpeg4URL string `json:"mpeg4_url"`
Mpeg4Width *int `json:"mpeg4_width,omitempty"`
Mpeg4Height *int `json:"mpeg4_height,omitempty"`
Mpeg4Duration *int `json:"mpeg4_duration,omitempty"`
ThumbURL string `json:"thumb_url"`
ThumbMimeType string `json:"thumb_mime_type,omitempty"`
Title *string `json:"title,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultVideo struct
type InlineQueryResultVideo struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
VideoURL string `json:"video_url"`
MimeType string `json:"mime_type"`
ThumbURL string `json:"thumb_url"`
Title string `json:"title"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
VideoWidth *int `json:"video_width,omitempty"`
VideoHeight *int `json:"video_height,omitempty"`
VideoDuration *int `json:"video_duration,omitempty"`
Description *string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultAudio struct
type InlineQueryResultAudio struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
AudioURL string `json:"audio_url"`
Title string `json:"title"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
Performer *string `json:"performer,omitempty"`
AudioDuration *int `json:"audio_duration,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultVoice struct
type InlineQueryResultVoice struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
VoiceURL string `json:"voice_url"`
Title string `json:"title"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
VoiceDuration *string `json:"voice_duration,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultDocument struct
type InlineQueryResultDocument struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
DocumentURL string `json:"document_url"`
MimeType string `json:"mime_type"`
Description *string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
ThumbURL *string `json:"thumb_url,omitempty"`
ThumbWidth *int `json:"thumb_width,omitempty"`
ThumbHeight *int `json:"thumb_height,omitempty"`
}
// InlineQueryResultLocation struct
type InlineQueryResultLocation struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
HorizontalAccuracy *float32 `json:"horizontal_accuracy,omitempty"`
LivePeriod *int `json:"live_period,omitempty"`
Heading *int `json:"heading,omitempty"`
ProximityAlertRadius *int `json:"proximity_alert_radius,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
ThumbURL *string `json:"thumb_url,omitempty"`
ThumbWidth *int `json:"thumb_width,omitempty"`
ThumbHeight *int `json:"thumb_height,omitempty"`
}
// InlineQueryResultVenue struct
type InlineQueryResultVenue struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID *string `json:"foursquare_id,omitempty"`
FoursquareType *string `json:"foursquare_type,omitempty"`
GooglePlaceID *string `json:"google_place_id,omitempty"`
GooglePlaceType *string `json:"google_place_type,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
ThumbURL *string `json:"thumb_url,omitempty"`
ThumbWidth *int `json:"thumb_width,omitempty"`
ThumbHeight *int `json:"thumb_height,omitempty"`
}
// InlineQueryResultContact struct
type InlineQueryResultContact struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName *string `json:"last_name,omitempty"`
VCard *string `json:"vcard,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
ThumbURL *string `json:"thumb_url,omitempty"`
ThumbWidth *int `json:"thumb_width,omitempty"`
ThumbHeight *int `json:"thumb_height,omitempty"`
}
// InlineQueryResultGame struct
type InlineQueryResultGame struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
GameShortName string `json:"game_short_name"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// InlineQueryResultCachedPhoto struct
type InlineQueryResultCachedPhoto struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
PhotoFileID string `json:"photo_file_id"`
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedGif struct
type InlineQueryResultCachedGif struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
GifFileID string `json:"gif_file_id"`
Title *string `json:"title,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedMpeg4Gif struct
type InlineQueryResultCachedMpeg4Gif struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Mpeg4FileID string `json:"mpeg4_file_id"`
Title *string `json:"title,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedSticker struct
type InlineQueryResultCachedSticker struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
StickerFileID string `json:"sticker_file_id"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedDocument struct
type InlineQueryResultCachedDocument struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
DocumentFileID string `json:"document_file_id"`
Description *string `json:"description,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVideo struct
type InlineQueryResultCachedVideo struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
VideoFileID string `json:"video_file_id"`
Title string `json:"title"`
Description *string `json:"description,omitempty"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVoice struct
type InlineQueryResultCachedVoice struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
VoiceFileID string `json:"voice_file_id"`
Title string `json:"title"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedAudio struct
type InlineQueryResultCachedAudio struct {
Type InlineQueryResultType `json:"type"`
ID string `json:"id"`
AudioFileID string `json:"audio_file_id"`
Caption *string `json:"caption,omitempty"`
ParseMode *string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent *InputMessageContent `json:"input_message_content,omitempty"`
}
// InputMessageContent interface
type InputMessageContent interface{}
// InputTextMessageContent struct
type InputTextMessageContent struct {
MessageText string `json:"message_text"`
ParseMode *string `json:"parse_mode,omitempty"`
DisableWebPagePreview *bool `json:"disable_web_page_preview,omitempty"`
}
// InputLocationMessageContent struct
type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
HorizontalAccuracy *float32 `json:"horizontal_accuracy,omitempty"`
LivePeriod *int `json:"live_period,omitempty"`
Heading *int `json:"heading,omitempty"`
ProximityAlertRadius *int `json:"proximity_alert_radius,omitempty"`
}
// InputVenueMessageContent struct
type InputVenueMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID *string `json:"foursquare_id,omitempty"`
FoursquareType *string `json:"foursquare_type,omitempty"`
GooglePlaceID *string `json:"google_place_id,omitempty"`
GooglePlaceType *string `json:"google_place_type,omitempty"`
}
// InputContactMessageContent struct
type InputContactMessageContent struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName *string `json:"last_name,omitempty"`
VCard *string `json:"vcard,omitempty"`
}
// InputInvoiceMessageContent represents the content of an invoice message to be sent as the result of an inline query.
type InputInvoiceMessageContent struct {
Title string `json:"title"`
Description string `json:"description"`
Payload string `json:"payload"`
ProviderToken string `json:"provider_token"`
Currency Currency `json:"currency"`
Prices []LabeledPrice `json:"prices"`
MaxTipAmount *int `json:"max_tip_amount,omitempty"`
SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
ProviderData *string `json:"provider_data,omitempty"`
PhotoURL *string `json:"photo_url,omitempty"`
PhotoSize *int `json:"photo_size,omitempty"`
PhotoWidth *int `json:"photo_width,omitempty"`
PhotoHeight *int `json:"photo_height,omitempty"`
NeedName *bool `json:"need_name,omitempty"`
NeedPhoneNumber *bool `json:"need_phone_number,omitempty"`
NeedEmail *bool `json:"need_email,omitempty"`
NeedShippingAddress *bool `json:"need_shipping_address,omitempty"`
SendPhoneNumberToProvider *bool `json:"send_phone_number_to_provider,omitempty"`
SendEmailToProvider *bool `json:"send_email_to_provider,omitempty"`
IsFlexible *bool `json:"is_flexible,omitempty"`
}
// ChosenInlineResult struct
type ChosenInlineResult struct {
ResultID string `json:"result_id"`
From User `json:"from"`
Location *Location `json:"location,omitempty"`
InlineMessageID *string `json:"inline_message_id,omitempty"`
Query string `json:"query"`
}
// AnswerWebAppQueryResponse interface.
type AnswerWebAppQueryResponse interface {
Response
GetMessage() *Message
}
type answerWebAppQueryResponse struct {
response
Result *Message `json:"result,omitempty"`
}
func (r *answerWebAppQueryResponse) GetMessage() *Message {
return r.Result
}
func (b *bot) AnswerWebAppQuery(ctx context.Context, options ...MethodOption) (AnswerWebAppQueryResponse, error) {
var res answerWebAppQueryResponse
err := b.doRequest(ctx, "answerWebAppQuery", &res, options...)
if err != nil {
return nil, err
}
return &res, nil
}
// SentWebAppMessage describes an inline message sent by a Web App on behalf of a user.
type SentWebAppMessage struct {
InlineMessageID *string `json:"inline_message_id,omitempty"` // Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message.
}