all repos — telegram-bot-api @ 2428a33ac6cdff18cb117d03e08c6af2ab0e0777

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,
 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// NewEditMessageTextAndMarkup allows you to edit the text and replymarkup of a message.
645func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig {
646	return EditMessageTextConfig{
647		BaseEdit: BaseEdit{
648			ChatID:      chatID,
649			MessageID:   messageID,
650			ReplyMarkup: &replyMarkup,
651		},
652		Text: text,
653	}
654}
655
656// NewEditMessageCaption allows you to edit the caption of a message.
657func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
658	return EditMessageCaptionConfig{
659		BaseEdit: BaseEdit{
660			ChatID:    chatID,
661			MessageID: messageID,
662		},
663		Caption: caption,
664	}
665}
666
667// NewEditMessageReplyMarkup allows you to edit the inline
668// keyboard markup.
669func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
670	return EditMessageReplyMarkupConfig{
671		BaseEdit: BaseEdit{
672			ChatID:      chatID,
673			MessageID:   messageID,
674			ReplyMarkup: &replyMarkup,
675		},
676	}
677}
678
679// NewHideKeyboard hides the keyboard, with the option for being selective
680// or hiding for everyone.
681func NewHideKeyboard(selective bool) ReplyKeyboardHide {
682	log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
683
684	return ReplyKeyboardHide{
685		HideKeyboard: true,
686		Selective:    selective,
687	}
688}
689
690// NewRemoveKeyboard hides the keyboard, with the option for being selective
691// or hiding for everyone.
692func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
693	return ReplyKeyboardRemove{
694		RemoveKeyboard: true,
695		Selective:      selective,
696	}
697}
698
699// NewKeyboardButton creates a regular keyboard button.
700func NewKeyboardButton(text string) KeyboardButton {
701	return KeyboardButton{
702		Text: text,
703	}
704}
705
706// NewKeyboardButtonContact creates a keyboard button that requests
707// user contact information upon click.
708func NewKeyboardButtonContact(text string) KeyboardButton {
709	return KeyboardButton{
710		Text:           text,
711		RequestContact: true,
712	}
713}
714
715// NewKeyboardButtonLocation creates a keyboard button that requests
716// user location information upon click.
717func NewKeyboardButtonLocation(text string) KeyboardButton {
718	return KeyboardButton{
719		Text:            text,
720		RequestLocation: true,
721	}
722}
723
724// NewKeyboardButtonRow creates a row of keyboard buttons.
725func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
726	var row []KeyboardButton
727
728	row = append(row, buttons...)
729
730	return row
731}
732
733// NewReplyKeyboard creates a new regular keyboard with sane defaults.
734func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
735	var keyboard [][]KeyboardButton
736
737	keyboard = append(keyboard, rows...)
738
739	return ReplyKeyboardMarkup{
740		ResizeKeyboard: true,
741		Keyboard:       keyboard,
742	}
743}
744
745// NewInlineKeyboardButtonData creates an inline keyboard button with text
746// and data for a callback.
747func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
748	return InlineKeyboardButton{
749		Text:         text,
750		CallbackData: &data,
751	}
752}
753
754// NewInlineKeyboardButtonURL creates an inline keyboard button with text
755// which goes to a URL.
756func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
757	return InlineKeyboardButton{
758		Text: text,
759		URL:  &url,
760	}
761}
762
763// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
764// text which allows the user to switch to a chat or return to a chat.
765func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
766	return InlineKeyboardButton{
767		Text:              text,
768		SwitchInlineQuery: &sw,
769	}
770}
771
772// NewInlineKeyboardRow creates an inline keyboard row with buttons.
773func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
774	var row []InlineKeyboardButton
775
776	row = append(row, buttons...)
777
778	return row
779}
780
781// NewInlineKeyboardMarkup creates a new inline keyboard.
782func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
783	var keyboard [][]InlineKeyboardButton
784
785	keyboard = append(keyboard, rows...)
786
787	return InlineKeyboardMarkup{
788		InlineKeyboard: keyboard,
789	}
790}
791
792// NewCallback creates a new callback message.
793func NewCallback(id, text string) CallbackConfig {
794	return CallbackConfig{
795		CallbackQueryID: id,
796		Text:            text,
797		ShowAlert:       false,
798	}
799}
800
801// NewCallbackWithAlert creates a new callback message that alerts
802// the user.
803func NewCallbackWithAlert(id, text string) CallbackConfig {
804	return CallbackConfig{
805		CallbackQueryID: id,
806		Text:            text,
807		ShowAlert:       true,
808	}
809}
810
811// NewInvoice creates a new Invoice request to the user.
812func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig {
813	return InvoiceConfig{
814		BaseChat:       BaseChat{ChatID: chatID},
815		Title:          title,
816		Description:    description,
817		Payload:        payload,
818		ProviderToken:  providerToken,
819		StartParameter: startParameter,
820		Currency:       currency,
821		Prices:         prices}
822}
823
824// NewSetChatPhotoUpload creates a new chat photo uploader.
825//
826// chatID is where to send it, file is a string path to the file,
827// FileReader, or FileBytes.
828//
829// Note that you must send animated GIFs as a document.
830func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
831	return SetChatPhotoConfig{
832		BaseFile: BaseFile{
833			BaseChat:    BaseChat{ChatID: chatID},
834			File:        file,
835			UseExisting: false,
836		},
837	}
838}
839
840// NewSetChatPhotoShare shares an existing photo.
841// You may use this to reshare an existing photo without reuploading it.
842//
843// chatID is where to send it, fileID is the ID of the file
844// already uploaded.
845func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
846	return SetChatPhotoConfig{
847		BaseFile: BaseFile{
848			BaseChat:    BaseChat{ChatID: chatID},
849			FileID:      fileID,
850			UseExisting: true,
851		},
852	}
853}