helpers.go (view raw)
1package tgbotapi
2
3import (
4 "net/url"
5)
6
7// NewMessage creates a new Message.
8//
9// chatID is where to send it, text is the message text.
10func NewMessage(chatID int64, text string) MessageConfig {
11 return MessageConfig{
12 BaseChat: BaseChat{
13 ChatID: chatID,
14 ReplyToMessageID: 0,
15 },
16 Text: text,
17 DisableWebPagePreview: false,
18 }
19}
20
21// NewDice creates a new DiceConfig.
22//
23// chatID is where to send it
24func NewDice(chatID int64) DiceConfig {
25 return DiceConfig{
26 BaseChat: BaseChat{
27 ChatID: chatID,
28 },
29 }
30}
31
32// NewDiceWithEmoji creates a new DiceConfig.
33//
34// chatID is where to send it
35// emoji is type of the Dice
36func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig {
37 return DiceConfig{
38 BaseChat: BaseChat{
39 ChatID: chatID,
40 },
41 Emoji: emoji,
42 }
43}
44
45// NewDeleteMessage creates a request to delete a message.
46func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
47 return DeleteMessageConfig{
48 ChatID: chatID,
49 MessageID: messageID,
50 }
51}
52
53// NewMessageToChannel creates a new Message that is sent to a channel
54// by username.
55//
56// username is the username of the channel, text is the message text,
57// and the username should be in the form of `@username`.
58func NewMessageToChannel(username string, text string) MessageConfig {
59 return MessageConfig{
60 BaseChat: BaseChat{
61 ChannelUsername: username,
62 },
63 Text: text,
64 }
65}
66
67// NewForward creates a new forward.
68//
69// chatID is where to send it, fromChatID is the source chat,
70// and messageID is the ID of the original message.
71func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
72 return ForwardConfig{
73 BaseChat: BaseChat{ChatID: chatID},
74 FromChatID: fromChatID,
75 MessageID: messageID,
76 }
77}
78
79// NewPhotoUpload creates a new photo uploader.
80//
81// chatID is where to send it, file is a string path to the file,
82// FileReader, or FileBytes.
83//
84// Note that you must send animated GIFs as a document.
85func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig {
86 return PhotoConfig{
87 BaseFile: BaseFile{
88 BaseChat: BaseChat{ChatID: chatID},
89 File: file,
90 UseExisting: false,
91 },
92 }
93}
94
95// NewPhotoShare shares an existing photo.
96// You may use this to reshare an existing photo without reuploading it.
97//
98// chatID is where to send it, fileID is the ID of the file
99// already uploaded.
100func NewPhotoShare(chatID int64, fileID string) PhotoConfig {
101 return PhotoConfig{
102 BaseFile: BaseFile{
103 BaseChat: BaseChat{ChatID: chatID},
104 FileID: fileID,
105 UseExisting: true,
106 },
107 }
108}
109
110// NewAudioUpload creates a new audio uploader.
111//
112// chatID is where to send it, file is a string path to the file,
113// FileReader, or FileBytes.
114func NewAudioUpload(chatID int64, file interface{}) AudioConfig {
115 return AudioConfig{
116 BaseFile: BaseFile{
117 BaseChat: BaseChat{ChatID: chatID},
118 File: file,
119 UseExisting: false,
120 },
121 }
122}
123
124// NewAudioShare shares an existing audio file.
125// You may use this to reshare an existing audio file without
126// reuploading it.
127//
128// chatID is where to send it, fileID is the ID of the audio
129// already uploaded.
130func NewAudioShare(chatID int64, fileID string) AudioConfig {
131 return AudioConfig{
132 BaseFile: BaseFile{
133 BaseChat: BaseChat{ChatID: chatID},
134 FileID: fileID,
135 UseExisting: true,
136 },
137 }
138}
139
140// NewDocumentUpload creates a new document uploader.
141//
142// chatID is where to send it, file is a string path to the file,
143// FileReader, or FileBytes.
144func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig {
145 return DocumentConfig{
146 BaseFile: BaseFile{
147 BaseChat: BaseChat{ChatID: chatID},
148 File: file,
149 UseExisting: false,
150 },
151 }
152}
153
154// NewDocumentShare shares an existing document.
155// You may use this to reshare an existing document without
156// reuploading it.
157//
158// chatID is where to send it, fileID is the ID of the document
159// already uploaded.
160func NewDocumentShare(chatID int64, fileID string) DocumentConfig {
161 return DocumentConfig{
162 BaseFile: BaseFile{
163 BaseChat: BaseChat{ChatID: chatID},
164 FileID: fileID,
165 UseExisting: true,
166 },
167 }
168}
169
170// NewStickerUpload creates a new sticker uploader.
171//
172// chatID is where to send it, file is a string path to the file,
173// FileReader, or FileBytes.
174func NewStickerUpload(chatID int64, file interface{}) StickerConfig {
175 return StickerConfig{
176 BaseFile: BaseFile{
177 BaseChat: BaseChat{ChatID: chatID},
178 File: file,
179 UseExisting: false,
180 },
181 }
182}
183
184// NewStickerShare shares an existing sticker.
185// You may use this to reshare an existing sticker without
186// reuploading it.
187//
188// chatID is where to send it, fileID is the ID of the sticker
189// already uploaded.
190func NewStickerShare(chatID int64, fileID string) StickerConfig {
191 return StickerConfig{
192 BaseFile: BaseFile{
193 BaseChat: BaseChat{ChatID: chatID},
194 FileID: fileID,
195 UseExisting: true,
196 },
197 }
198}
199
200// NewVideoUpload creates a new video uploader.
201//
202// chatID is where to send it, file is a string path to the file,
203// FileReader, or FileBytes.
204func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
205 return VideoConfig{
206 BaseFile: BaseFile{
207 BaseChat: BaseChat{ChatID: chatID},
208 File: file,
209 UseExisting: false,
210 },
211 }
212}
213
214// NewVideoShare shares an existing video.
215// You may use this to reshare an existing video without reuploading it.
216//
217// chatID is where to send it, fileID is the ID of the video
218// already uploaded.
219func NewVideoShare(chatID int64, fileID string) VideoConfig {
220 return VideoConfig{
221 BaseFile: BaseFile{
222 BaseChat: BaseChat{ChatID: chatID},
223 FileID: fileID,
224 UseExisting: true,
225 },
226 }
227}
228
229// NewAnimationUpload creates a new animation uploader.
230//
231// chatID is where to send it, file is a string path to the file,
232// FileReader, or FileBytes.
233func NewAnimationUpload(chatID int64, file interface{}) AnimationConfig {
234 return AnimationConfig{
235 BaseFile: BaseFile{
236 BaseChat: BaseChat{ChatID: chatID},
237 File: file,
238 UseExisting: false,
239 },
240 }
241}
242
243// NewAnimationShare shares an existing animation.
244// You may use this to reshare an existing animation without reuploading it.
245//
246// chatID is where to send it, fileID is the ID of the animation
247// already uploaded.
248func NewAnimationShare(chatID int64, fileID string) AnimationConfig {
249 return AnimationConfig{
250 BaseFile: BaseFile{
251 BaseChat: BaseChat{ChatID: chatID},
252 FileID: fileID,
253 UseExisting: true,
254 },
255 }
256}
257
258// NewVideoNoteUpload creates a new video note uploader.
259//
260// chatID is where to send it, file is a string path to the file,
261// FileReader, or FileBytes.
262func NewVideoNoteUpload(chatID int64, length int, file interface{}) VideoNoteConfig {
263 return VideoNoteConfig{
264 BaseFile: BaseFile{
265 BaseChat: BaseChat{ChatID: chatID},
266 File: file,
267 UseExisting: false,
268 },
269 Length: length,
270 }
271}
272
273// NewVideoNoteShare shares an existing video.
274// You may use this to reshare an existing video without reuploading it.
275//
276// chatID is where to send it, fileID is the ID of the video
277// already uploaded.
278func NewVideoNoteShare(chatID int64, length int, fileID string) VideoNoteConfig {
279 return VideoNoteConfig{
280 BaseFile: BaseFile{
281 BaseChat: BaseChat{ChatID: chatID},
282 FileID: fileID,
283 UseExisting: true,
284 },
285 Length: length,
286 }
287}
288
289// NewVoiceUpload creates a new voice uploader.
290//
291// chatID is where to send it, file is a string path to the file,
292// FileReader, or FileBytes.
293func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig {
294 return VoiceConfig{
295 BaseFile: BaseFile{
296 BaseChat: BaseChat{ChatID: chatID},
297 File: file,
298 UseExisting: false,
299 },
300 }
301}
302
303// NewVoiceShare shares an existing voice.
304// You may use this to reshare an existing voice without reuploading it.
305//
306// chatID is where to send it, fileID is the ID of the video
307// already uploaded.
308func NewVoiceShare(chatID int64, fileID string) VoiceConfig {
309 return VoiceConfig{
310 BaseFile: BaseFile{
311 BaseChat: BaseChat{ChatID: chatID},
312 FileID: fileID,
313 UseExisting: true,
314 },
315 }
316}
317
318// NewMediaGroup creates a new media group. Files should be an array of
319// two to ten InputMediaPhoto or InputMediaVideo.
320func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
321 return MediaGroupConfig{
322 BaseChat: BaseChat{
323 ChatID: chatID,
324 },
325 InputMedia: files,
326 }
327}
328
329// NewInputMediaPhoto creates a new InputMediaPhoto.
330func NewInputMediaPhoto(media string) InputMediaPhoto {
331 return InputMediaPhoto{
332 Type: "photo",
333 Media: media,
334 }
335}
336
337// NewInputMediaVideo creates a new InputMediaVideo.
338func NewInputMediaVideo(media string) InputMediaVideo {
339 return InputMediaVideo{
340 Type: "video",
341 Media: media,
342 }
343}
344
345// NewContact allows you to send a shared contact.
346func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
347 return ContactConfig{
348 BaseChat: BaseChat{
349 ChatID: chatID,
350 },
351 PhoneNumber: phoneNumber,
352 FirstName: firstName,
353 }
354}
355
356// NewLocation shares your location.
357//
358// chatID is where to send it, latitude and longitude are coordinates.
359func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
360 return LocationConfig{
361 BaseChat: BaseChat{
362 ChatID: chatID,
363 },
364 Latitude: latitude,
365 Longitude: longitude,
366 }
367}
368
369// NewVenue allows you to send a venue and its location.
370func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
371 return VenueConfig{
372 BaseChat: BaseChat{
373 ChatID: chatID,
374 },
375 Title: title,
376 Address: address,
377 Latitude: latitude,
378 Longitude: longitude,
379 }
380}
381
382// NewChatAction sets a chat action.
383// Actions last for 5 seconds, or until your next action.
384//
385// chatID is where to send it, action should be set via Chat constants.
386func NewChatAction(chatID int64, action string) ChatActionConfig {
387 return ChatActionConfig{
388 BaseChat: BaseChat{ChatID: chatID},
389 Action: action,
390 }
391}
392
393// NewUserProfilePhotos gets user profile photos.
394//
395// userID is the ID of the user you wish to get profile photos from.
396func NewUserProfilePhotos(userID int) UserProfilePhotosConfig {
397 return UserProfilePhotosConfig{
398 UserID: userID,
399 Offset: 0,
400 Limit: 0,
401 }
402}
403
404// NewUpdate gets updates since the last Offset.
405//
406// offset is the last Update ID to include.
407// You likely want to set this to the last Update ID plus 1.
408func NewUpdate(offset int) UpdateConfig {
409 return UpdateConfig{
410 Offset: offset,
411 Limit: 0,
412 Timeout: 0,
413 }
414}
415
416// NewWebhook creates a new webhook.
417//
418// link is the url parsable link you wish to get the updates.
419func NewWebhook(link string) WebhookConfig {
420 u, _ := url.Parse(link)
421
422 return WebhookConfig{
423 URL: u,
424 }
425}
426
427// NewWebhookWithCert creates a new webhook with a certificate.
428//
429// link is the url you wish to get webhooks,
430// file contains a string to a file, FileReader, or FileBytes.
431func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
432 u, _ := url.Parse(link)
433
434 return WebhookConfig{
435 URL: u,
436 Certificate: file,
437 }
438}
439
440// NewInlineQueryResultArticle creates a new inline query article.
441func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
442 return InlineQueryResultArticle{
443 Type: "article",
444 ID: id,
445 Title: title,
446 InputMessageContent: InputTextMessageContent{
447 Text: messageText,
448 },
449 }
450}
451
452// NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
453func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle {
454 return InlineQueryResultArticle{
455 Type: "article",
456 ID: id,
457 Title: title,
458 InputMessageContent: InputTextMessageContent{
459 Text: messageText,
460 ParseMode: "Markdown",
461 },
462 }
463}
464
465// NewInlineQueryResultArticleMarkdownV2 creates a new inline query article with MarkdownV2 parsing.
466func NewInlineQueryResultArticleMarkdownV2(id, title, messageText string) InlineQueryResultArticle {
467 return InlineQueryResultArticle{
468 Type: "article",
469 ID: id,
470 Title: title,
471 InputMessageContent: InputTextMessageContent{
472 Text: messageText,
473 ParseMode: "MarkdownV2",
474 },
475 }
476}
477
478// NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
479func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle {
480 return InlineQueryResultArticle{
481 Type: "article",
482 ID: id,
483 Title: title,
484 InputMessageContent: InputTextMessageContent{
485 Text: messageText,
486 ParseMode: "HTML",
487 },
488 }
489}
490
491// NewInlineQueryResultGIF creates a new inline query GIF.
492func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
493 return InlineQueryResultGIF{
494 Type: "gif",
495 ID: id,
496 URL: url,
497 }
498}
499
500// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
501func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
502 return InlineQueryResultCachedGIF{
503 Type: "gif",
504 ID: id,
505 GifID: gifID,
506 }
507}
508
509// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
510func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
511 return InlineQueryResultMPEG4GIF{
512 Type: "mpeg4_gif",
513 ID: id,
514 URL: url,
515 }
516}
517
518// NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached MPEG4 GIF.
519func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif {
520 return InlineQueryResultCachedMpeg4Gif{
521 Type: "mpeg4_gif",
522 ID: id,
523 MGifID: MPEG4GifID,
524 }
525}
526
527// NewInlineQueryResultPhoto creates a new inline query photo.
528func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
529 return InlineQueryResultPhoto{
530 Type: "photo",
531 ID: id,
532 URL: url,
533 }
534}
535
536// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
537func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
538 return InlineQueryResultPhoto{
539 Type: "photo",
540 ID: id,
541 URL: url,
542 ThumbURL: thumb,
543 }
544}
545
546// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
547func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
548 return InlineQueryResultCachedPhoto{
549 Type: "photo",
550 ID: id,
551 PhotoID: photoID,
552 }
553}
554
555// NewInlineQueryResultVideo creates a new inline query video.
556func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
557 return InlineQueryResultVideo{
558 Type: "video",
559 ID: id,
560 URL: url,
561 }
562}
563
564// NewInlineQueryResultCachedVideo create a new inline query with cached video.
565func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
566 return InlineQueryResultCachedVideo{
567 Type: "video",
568 ID: id,
569 VideoID: videoID,
570 Title: title,
571 }
572}
573
574// NewInlineQueryResultAudio creates a new inline query audio.
575func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
576 return InlineQueryResultAudio{
577 Type: "audio",
578 ID: id,
579 URL: url,
580 Title: title,
581 }
582}
583
584// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
585func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
586 return InlineQueryResultCachedAudio{
587 Type: "audio",
588 ID: id,
589 AudioID: audioID,
590 }
591}
592
593// NewInlineQueryResultVoice creates a new inline query voice.
594func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
595 return InlineQueryResultVoice{
596 Type: "voice",
597 ID: id,
598 URL: url,
599 Title: title,
600 }
601}
602
603// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
604func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
605 return InlineQueryResultCachedVoice{
606 Type: "voice",
607 ID: id,
608 VoiceID: voiceID,
609 Title: title,
610 }
611}
612
613// NewInlineQueryResultDocument creates a new inline query document.
614func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
615 return InlineQueryResultDocument{
616 Type: "document",
617 ID: id,
618 URL: url,
619 Title: title,
620 MimeType: mimeType,
621 }
622}
623
624// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
625func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
626 return InlineQueryResultCachedDocument{
627 Type: "document",
628 ID: id,
629 DocumentID: documentID,
630 Title: title,
631 }
632}
633
634// NewInlineQueryResultLocation creates a new inline query location.
635func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
636 return InlineQueryResultLocation{
637 Type: "location",
638 ID: id,
639 Title: title,
640 Latitude: latitude,
641 Longitude: longitude,
642 }
643}
644
645// NewInlineQueryResultVenue creates a new inline query venue.
646func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
647 return InlineQueryResultVenue{
648 Type: "venue",
649 ID: id,
650 Title: title,
651 Address: address,
652 Latitude: latitude,
653 Longitude: longitude,
654 }
655}
656
657// NewEditMessageText allows you to edit the text of a message.
658func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
659 return EditMessageTextConfig{
660 BaseEdit: BaseEdit{
661 ChatID: chatID,
662 MessageID: messageID,
663 },
664 Text: text,
665 }
666}
667
668// NewEditMessageCaption allows you to edit the caption of a message.
669func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
670 return EditMessageCaptionConfig{
671 BaseEdit: BaseEdit{
672 ChatID: chatID,
673 MessageID: messageID,
674 },
675 Caption: caption,
676 }
677}
678
679// NewEditMessageReplyMarkup allows you to edit the inline
680// keyboard markup.
681func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
682 return EditMessageReplyMarkupConfig{
683 BaseEdit: BaseEdit{
684 ChatID: chatID,
685 MessageID: messageID,
686 ReplyMarkup: &replyMarkup,
687 },
688 }
689}
690
691// NewHideKeyboard hides the keyboard, with the option for being selective
692// or hiding for everyone.
693func NewHideKeyboard(selective bool) ReplyKeyboardHide {
694 log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
695
696 return ReplyKeyboardHide{
697 HideKeyboard: true,
698 Selective: selective,
699 }
700}
701
702// NewRemoveKeyboard hides the keyboard, with the option for being selective
703// or hiding for everyone.
704func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
705 return ReplyKeyboardRemove{
706 RemoveKeyboard: true,
707 Selective: selective,
708 }
709}
710
711// NewKeyboardButton creates a regular keyboard button.
712func NewKeyboardButton(text string) KeyboardButton {
713 return KeyboardButton{
714 Text: text,
715 }
716}
717
718// NewKeyboardButtonContact creates a keyboard button that requests
719// user contact information upon click.
720func NewKeyboardButtonContact(text string) KeyboardButton {
721 return KeyboardButton{
722 Text: text,
723 RequestContact: true,
724 }
725}
726
727// NewKeyboardButtonLocation creates a keyboard button that requests
728// user location information upon click.
729func NewKeyboardButtonLocation(text string) KeyboardButton {
730 return KeyboardButton{
731 Text: text,
732 RequestLocation: true,
733 }
734}
735
736// NewKeyboardButtonRow creates a row of keyboard buttons.
737func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
738 var row []KeyboardButton
739
740 row = append(row, buttons...)
741
742 return row
743}
744
745// NewReplyKeyboard creates a new regular keyboard with sane defaults.
746func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
747 var keyboard [][]KeyboardButton
748
749 keyboard = append(keyboard, rows...)
750
751 return ReplyKeyboardMarkup{
752 ResizeKeyboard: true,
753 Keyboard: keyboard,
754 }
755}
756
757// NewInlineKeyboardButtonData creates an inline keyboard button with text
758// and data for a callback.
759func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
760 return InlineKeyboardButton{
761 Text: text,
762 CallbackData: &data,
763 }
764}
765
766// NewInlineKeyboardButtonURL creates an inline keyboard button with text
767// which goes to a URL.
768func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
769 return InlineKeyboardButton{
770 Text: text,
771 URL: &url,
772 }
773}
774
775// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
776// text which allows the user to switch to a chat or return to a chat.
777func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
778 return InlineKeyboardButton{
779 Text: text,
780 SwitchInlineQuery: &sw,
781 }
782}
783
784// NewInlineKeyboardRow creates an inline keyboard row with buttons.
785func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
786 var row []InlineKeyboardButton
787
788 row = append(row, buttons...)
789
790 return row
791}
792
793// NewInlineKeyboardMarkup creates a new inline keyboard.
794func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
795 var keyboard [][]InlineKeyboardButton
796
797 keyboard = append(keyboard, rows...)
798
799 return InlineKeyboardMarkup{
800 InlineKeyboard: keyboard,
801 }
802}
803
804// NewCallback creates a new callback message.
805func NewCallback(id, text string) CallbackConfig {
806 return CallbackConfig{
807 CallbackQueryID: id,
808 Text: text,
809 ShowAlert: false,
810 }
811}
812
813// NewCallbackWithAlert creates a new callback message that alerts
814// the user.
815func NewCallbackWithAlert(id, text string) CallbackConfig {
816 return CallbackConfig{
817 CallbackQueryID: id,
818 Text: text,
819 ShowAlert: true,
820 }
821}
822
823// NewInvoice creates a new Invoice request to the user.
824func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig {
825 return InvoiceConfig{
826 BaseChat: BaseChat{ChatID: chatID},
827 Title: title,
828 Description: description,
829 Payload: payload,
830 ProviderToken: providerToken,
831 StartParameter: startParameter,
832 Currency: currency,
833 Prices: prices}
834}
835
836// NewSetChatPhotoUpload creates a new chat photo uploader.
837//
838// chatID is where to send it, file is a string path to the file,
839// FileReader, or FileBytes.
840//
841// Note that you must send animated GIFs as a document.
842func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
843 return SetChatPhotoConfig{
844 BaseFile: BaseFile{
845 BaseChat: BaseChat{ChatID: chatID},
846 File: file,
847 UseExisting: false,
848 },
849 }
850}
851
852// NewSetChatPhotoShare shares an existing photo.
853// You may use this to reshare an existing photo without reuploading it.
854//
855// chatID is where to send it, fileID is the ID of the file
856// already uploaded.
857func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
858 return SetChatPhotoConfig{
859 BaseFile: BaseFile{
860 BaseChat: BaseChat{ChatID: chatID},
861 FileID: fileID,
862 UseExisting: true,
863 },
864 }
865}