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