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// NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
442func NewInlineQueryResultArticleHTML(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: "HTML",
450 },
451 }
452}
453
454// NewInlineQueryResultGIF creates a new inline query GIF.
455func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
456 return InlineQueryResultGIF{
457 Type: "gif",
458 ID: id,
459 URL: url,
460 }
461}
462
463// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
464func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
465 return InlineQueryResultCachedGIF{
466 Type: "gif",
467 ID: id,
468 GifID: gifID,
469 }
470}
471
472// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
473func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
474 return InlineQueryResultMPEG4GIF{
475 Type: "mpeg4_gif",
476 ID: id,
477 URL: url,
478 }
479}
480
481// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
482func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif {
483 return InlineQueryResultCachedMpeg4Gif{
484 Type: "mpeg4_gif",
485 ID: id,
486 MGifID: MPEG4GifID,
487 }
488}
489
490// NewInlineQueryResultPhoto creates a new inline query photo.
491func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
492 return InlineQueryResultPhoto{
493 Type: "photo",
494 ID: id,
495 URL: url,
496 }
497}
498
499// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
500func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
501 return InlineQueryResultPhoto{
502 Type: "photo",
503 ID: id,
504 URL: url,
505 ThumbURL: thumb,
506 }
507}
508
509// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
510func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
511 return InlineQueryResultCachedPhoto{
512 Type: "photo",
513 ID: id,
514 PhotoID: photoID,
515 }
516}
517
518// NewInlineQueryResultVideo creates a new inline query video.
519func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
520 return InlineQueryResultVideo{
521 Type: "video",
522 ID: id,
523 URL: url,
524 }
525}
526
527// NewInlineQueryResultCachedVideo create a new inline query with cached video.
528func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
529 return InlineQueryResultCachedVideo{
530 Type: "video",
531 ID: id,
532 VideoID: videoID,
533 Title: title,
534 }
535}
536
537// NewInlineQueryResultAudio creates a new inline query audio.
538func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
539 return InlineQueryResultAudio{
540 Type: "audio",
541 ID: id,
542 URL: url,
543 Title: title,
544 }
545}
546
547// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
548func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
549 return InlineQueryResultCachedAudio{
550 Type: "audio",
551 ID: id,
552 AudioID: audioID,
553 }
554}
555
556// NewInlineQueryResultVoice creates a new inline query voice.
557func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
558 return InlineQueryResultVoice{
559 Type: "voice",
560 ID: id,
561 URL: url,
562 Title: title,
563 }
564}
565
566// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
567func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
568 return InlineQueryResultCachedVoice{
569 Type: "voice",
570 ID: id,
571 VoiceID: voiceID,
572 Title: title,
573 }
574}
575
576// NewInlineQueryResultDocument creates a new inline query document.
577func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
578 return InlineQueryResultDocument{
579 Type: "document",
580 ID: id,
581 URL: url,
582 Title: title,
583 MimeType: mimeType,
584 }
585}
586
587// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
588func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
589 return InlineQueryResultCachedDocument{
590 Type: "document",
591 ID: id,
592 DocumentID: documentID,
593 Title: title,
594 }
595}
596
597// NewInlineQueryResultLocation creates a new inline query location.
598func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
599 return InlineQueryResultLocation{
600 Type: "location",
601 ID: id,
602 Title: title,
603 Latitude: latitude,
604 Longitude: longitude,
605 }
606}
607
608// NewInlineQueryResultVenue creates a new inline query venue.
609func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
610 return InlineQueryResultVenue{
611 Type: "venue",
612 ID: id,
613 Title: title,
614 Address: address,
615 Latitude: latitude,
616 Longitude: longitude,
617 }
618}
619
620// NewEditMessageText allows you to edit the text of a message.
621func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
622 return EditMessageTextConfig{
623 BaseEdit: BaseEdit{
624 ChatID: chatID,
625 MessageID: messageID,
626 },
627 Text: text,
628 }
629}
630
631// NewEditMessageCaption allows you to edit the caption of a message.
632func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
633 return EditMessageCaptionConfig{
634 BaseEdit: BaseEdit{
635 ChatID: chatID,
636 MessageID: messageID,
637 },
638 Caption: caption,
639 }
640}
641
642// NewEditMessageReplyMarkup allows you to edit the inline
643// keyboard markup.
644func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
645 return EditMessageReplyMarkupConfig{
646 BaseEdit: BaseEdit{
647 ChatID: chatID,
648 MessageID: messageID,
649 ReplyMarkup: &replyMarkup,
650 },
651 }
652}
653
654// NewHideKeyboard hides the keyboard, with the option for being selective
655// or hiding for everyone.
656func NewHideKeyboard(selective bool) ReplyKeyboardHide {
657 log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
658
659 return ReplyKeyboardHide{
660 HideKeyboard: true,
661 Selective: selective,
662 }
663}
664
665// NewRemoveKeyboard hides the keyboard, with the option for being selective
666// or hiding for everyone.
667func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
668 return ReplyKeyboardRemove{
669 RemoveKeyboard: true,
670 Selective: selective,
671 }
672}
673
674// NewKeyboardButton creates a regular keyboard button.
675func NewKeyboardButton(text string) KeyboardButton {
676 return KeyboardButton{
677 Text: text,
678 }
679}
680
681// NewKeyboardButtonContact creates a keyboard button that requests
682// user contact information upon click.
683func NewKeyboardButtonContact(text string) KeyboardButton {
684 return KeyboardButton{
685 Text: text,
686 RequestContact: true,
687 }
688}
689
690// NewKeyboardButtonLocation creates a keyboard button that requests
691// user location information upon click.
692func NewKeyboardButtonLocation(text string) KeyboardButton {
693 return KeyboardButton{
694 Text: text,
695 RequestLocation: true,
696 }
697}
698
699// NewKeyboardButtonRow creates a row of keyboard buttons.
700func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
701 var row []KeyboardButton
702
703 row = append(row, buttons...)
704
705 return row
706}
707
708// NewReplyKeyboard creates a new regular keyboard with sane defaults.
709func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
710 var keyboard [][]KeyboardButton
711
712 keyboard = append(keyboard, rows...)
713
714 return ReplyKeyboardMarkup{
715 ResizeKeyboard: true,
716 Keyboard: keyboard,
717 }
718}
719
720// NewInlineKeyboardButtonData creates an inline keyboard button with text
721// and data for a callback.
722func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
723 return InlineKeyboardButton{
724 Text: text,
725 CallbackData: &data,
726 }
727}
728
729// NewInlineKeyboardButtonURL creates an inline keyboard button with text
730// which goes to a URL.
731func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
732 return InlineKeyboardButton{
733 Text: text,
734 URL: &url,
735 }
736}
737
738// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
739// text which allows the user to switch to a chat or return to a chat.
740func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
741 return InlineKeyboardButton{
742 Text: text,
743 SwitchInlineQuery: &sw,
744 }
745}
746
747// NewInlineKeyboardRow creates an inline keyboard row with buttons.
748func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
749 var row []InlineKeyboardButton
750
751 row = append(row, buttons...)
752
753 return row
754}
755
756// NewInlineKeyboardMarkup creates a new inline keyboard.
757func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
758 var keyboard [][]InlineKeyboardButton
759
760 keyboard = append(keyboard, rows...)
761
762 return InlineKeyboardMarkup{
763 InlineKeyboard: keyboard,
764 }
765}
766
767// NewCallback creates a new callback message.
768func NewCallback(id, text string) CallbackConfig {
769 return CallbackConfig{
770 CallbackQueryID: id,
771 Text: text,
772 ShowAlert: false,
773 }
774}
775
776// NewCallbackWithAlert creates a new callback message that alerts
777// the user.
778func NewCallbackWithAlert(id, text string) CallbackConfig {
779 return CallbackConfig{
780 CallbackQueryID: id,
781 Text: text,
782 ShowAlert: true,
783 }
784}
785
786// NewInvoice creates a new Invoice request to the user.
787func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig {
788 return InvoiceConfig{
789 BaseChat: BaseChat{ChatID: chatID},
790 Title: title,
791 Description: description,
792 Payload: payload,
793 ProviderToken: providerToken,
794 StartParameter: startParameter,
795 Currency: currency,
796 Prices: prices}
797}
798
799// NewSetChatPhotoUpload creates a new chat photo uploader.
800//
801// chatID is where to send it, file is a string path to the file,
802// FileReader, or FileBytes.
803//
804// Note that you must send animated GIFs as a document.
805func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
806 return SetChatPhotoConfig{
807 BaseFile: BaseFile{
808 BaseChat: BaseChat{ChatID: chatID},
809 File: file,
810 UseExisting: false,
811 },
812 }
813}
814
815// NewSetChatPhotoShare shares an existing photo.
816// You may use this to reshare an existing photo without reuploading it.
817//
818// chatID is where to send it, fileID is the ID of the file
819// already uploaded.
820func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
821 return SetChatPhotoConfig{
822 BaseFile: BaseFile{
823 BaseChat: BaseChat{ChatID: chatID},
824 FileID: fileID,
825 UseExisting: true,
826 },
827 }
828}