all repos — telegram-bot-api @ 81ccf0a8b27e950afc24fd6abe6dac13b725c741

Golang bindings for the Telegram Bot API

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