all repos — telegram-bot-api @ 0a3a1c8716c4cd8d26a262af9f12dcbab7f3f28c

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