all repos — telegram-bot-api @ dd5b918046a9f6b61e5351a553350d102b12abe3

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// NewInlineQueryResultAudio creates a new inline query audio.
575func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
576	return InlineQueryResultAudio{
577		Type:  "audio",
578		ID:    id,
579		URL:   url,
580		Title: title,
581	}
582}
583
584// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
585func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
586	return InlineQueryResultCachedAudio{
587		Type:    "audio",
588		ID:      id,
589		AudioID: audioID,
590	}
591}
592
593// NewInlineQueryResultVoice creates a new inline query voice.
594func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
595	return InlineQueryResultVoice{
596		Type:  "voice",
597		ID:    id,
598		URL:   url,
599		Title: title,
600	}
601}
602
603// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
604func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
605	return InlineQueryResultCachedVoice{
606		Type:    "voice",
607		ID:      id,
608		VoiceID: voiceID,
609		Title:   title,
610	}
611}
612
613// NewInlineQueryResultDocument creates a new inline query document.
614func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
615	return InlineQueryResultDocument{
616		Type:     "document",
617		ID:       id,
618		URL:      url,
619		Title:    title,
620		MimeType: mimeType,
621	}
622}
623
624// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
625func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
626	return InlineQueryResultCachedDocument{
627		Type:       "document",
628		ID:         id,
629		DocumentID: documentID,
630		Title:      title,
631	}
632}
633
634// NewInlineQueryResultLocation creates a new inline query location.
635func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
636	return InlineQueryResultLocation{
637		Type:      "location",
638		ID:        id,
639		Title:     title,
640		Latitude:  latitude,
641		Longitude: longitude,
642	}
643}
644
645// NewInlineQueryResultVenue creates a new inline query venue.
646func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
647	return InlineQueryResultVenue{
648		Type:      "venue",
649		ID:        id,
650		Title:     title,
651		Address:   address,
652		Latitude:  latitude,
653		Longitude: longitude,
654	}
655}
656
657// NewEditMessageText allows you to edit the text of a message.
658func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
659	return EditMessageTextConfig{
660		BaseEdit: BaseEdit{
661			ChatID:    chatID,
662			MessageID: messageID,
663		},
664		Text: text,
665	}
666}
667
668// NewEditMessageTextAndMarkup allows you to edit the text and replymarkup of a message.
669func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig {
670	return EditMessageTextConfig{
671		BaseEdit: BaseEdit{
672			ChatID:      chatID,
673			MessageID:   messageID,
674			ReplyMarkup: &replyMarkup,
675		},
676		Text: text,
677	}
678}
679
680// NewEditMessageCaption allows you to edit the caption of a message.
681func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
682	return EditMessageCaptionConfig{
683		BaseEdit: BaseEdit{
684			ChatID:    chatID,
685			MessageID: messageID,
686		},
687		Caption: caption,
688	}
689}
690
691// NewEditMessageReplyMarkup allows you to edit the inline
692// keyboard markup.
693func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
694	return EditMessageReplyMarkupConfig{
695		BaseEdit: BaseEdit{
696			ChatID:      chatID,
697			MessageID:   messageID,
698			ReplyMarkup: &replyMarkup,
699		},
700	}
701}
702
703// NewHideKeyboard hides the keyboard, with the option for being selective
704// or hiding for everyone.
705func NewHideKeyboard(selective bool) ReplyKeyboardHide {
706	log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
707
708	return ReplyKeyboardHide{
709		HideKeyboard: true,
710		Selective:    selective,
711	}
712}
713
714// NewRemoveKeyboard hides the keyboard, with the option for being selective
715// or hiding for everyone.
716func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
717	return ReplyKeyboardRemove{
718		RemoveKeyboard: true,
719		Selective:      selective,
720	}
721}
722
723// NewKeyboardButton creates a regular keyboard button.
724func NewKeyboardButton(text string) KeyboardButton {
725	return KeyboardButton{
726		Text: text,
727	}
728}
729
730// NewKeyboardButtonContact creates a keyboard button that requests
731// user contact information upon click.
732func NewKeyboardButtonContact(text string) KeyboardButton {
733	return KeyboardButton{
734		Text:           text,
735		RequestContact: true,
736	}
737}
738
739// NewKeyboardButtonLocation creates a keyboard button that requests
740// user location information upon click.
741func NewKeyboardButtonLocation(text string) KeyboardButton {
742	return KeyboardButton{
743		Text:            text,
744		RequestLocation: true,
745	}
746}
747
748// NewKeyboardButtonRow creates a row of keyboard buttons.
749func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
750	var row []KeyboardButton
751
752	row = append(row, buttons...)
753
754	return row
755}
756
757// NewReplyKeyboard creates a new regular keyboard with sane defaults.
758func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
759	var keyboard [][]KeyboardButton
760
761	keyboard = append(keyboard, rows...)
762
763	return ReplyKeyboardMarkup{
764		ResizeKeyboard: true,
765		Keyboard:       keyboard,
766	}
767}
768
769// NewInlineKeyboardButtonData creates an inline keyboard button with text
770// and data for a callback.
771func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
772	return InlineKeyboardButton{
773		Text:         text,
774		CallbackData: &data,
775	}
776}
777
778// NewInlineKeyboardButtonURL creates an inline keyboard button with text
779// which goes to a URL.
780func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
781	return InlineKeyboardButton{
782		Text: text,
783		URL:  &url,
784	}
785}
786
787// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
788// text which allows the user to switch to a chat or return to a chat.
789func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
790	return InlineKeyboardButton{
791		Text:              text,
792		SwitchInlineQuery: &sw,
793	}
794}
795
796// NewInlineKeyboardRow creates an inline keyboard row with buttons.
797func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
798	var row []InlineKeyboardButton
799
800	row = append(row, buttons...)
801
802	return row
803}
804
805// NewInlineKeyboardMarkup creates a new inline keyboard.
806func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
807	var keyboard [][]InlineKeyboardButton
808
809	keyboard = append(keyboard, rows...)
810
811	return InlineKeyboardMarkup{
812		InlineKeyboard: keyboard,
813	}
814}
815
816// NewCallback creates a new callback message.
817func NewCallback(id, text string) CallbackConfig {
818	return CallbackConfig{
819		CallbackQueryID: id,
820		Text:            text,
821		ShowAlert:       false,
822	}
823}
824
825// NewCallbackWithAlert creates a new callback message that alerts
826// the user.
827func NewCallbackWithAlert(id, text string) CallbackConfig {
828	return CallbackConfig{
829		CallbackQueryID: id,
830		Text:            text,
831		ShowAlert:       true,
832	}
833}
834
835// NewInvoice creates a new Invoice request to the user.
836func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig {
837	return InvoiceConfig{
838		BaseChat:       BaseChat{ChatID: chatID},
839		Title:          title,
840		Description:    description,
841		Payload:        payload,
842		ProviderToken:  providerToken,
843		StartParameter: startParameter,
844		Currency:       currency,
845		Prices:         prices}
846}
847
848// NewSetChatPhotoUpload creates a new chat photo uploader.
849//
850// chatID is where to send it, file is a string path to the file,
851// FileReader, or FileBytes.
852//
853// Note that you must send animated GIFs as a document.
854func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
855	return SetChatPhotoConfig{
856		BaseFile: BaseFile{
857			BaseChat:    BaseChat{ChatID: chatID},
858			File:        file,
859			UseExisting: false,
860		},
861	}
862}
863
864// NewSetChatPhotoShare shares an existing photo.
865// You may use this to reshare an existing photo without reuploading it.
866//
867// chatID is where to send it, fileID is the ID of the file
868// already uploaded.
869func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
870	return SetChatPhotoConfig{
871		BaseFile: BaseFile{
872			BaseChat:    BaseChat{ChatID: chatID},
873			FileID:      fileID,
874			UseExisting: true,
875		},
876	}
877}