all repos — telegram-bot-api @ 458a89724a5892eb5c41f7f1940c12072c617587

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		ChatID: chatID,
298		Media:  files,
299	}
300}
301
302// NewInputMediaPhoto creates a new InputMediaPhoto.
303func NewInputMediaPhoto(media string) InputMediaPhoto {
304	return InputMediaPhoto{
305		BaseInputMedia{
306			Type:  "photo",
307			Media: media,
308		},
309	}
310}
311
312// NewInputMediaVideo creates a new InputMediaVideo.
313func NewInputMediaVideo(media string) InputMediaVideo {
314	return InputMediaVideo{
315		BaseInputMedia: BaseInputMedia{
316			Type:  "video",
317			Media: media,
318		},
319	}
320}
321
322// NewInputMediaAnimation creates a new InputMediaAnimation.
323func NewInputMediaAnimation(media string) InputMediaAnimation {
324	return InputMediaAnimation{
325		BaseInputMedia: BaseInputMedia{
326			Type:  "animation",
327			Media: media,
328		},
329	}
330}
331
332// NewInputMediaAudio creates a new InputMediaAudio.
333func NewInputMediaAudio(media string) InputMediaAudio {
334	return InputMediaAudio{
335		BaseInputMedia: BaseInputMedia{
336			Type:  "audio",
337			Media: media,
338		},
339	}
340}
341
342// NewInputMediaDocument creates a new InputMediaDocument.
343func NewInputMediaDocument(media string) InputMediaDocument {
344	return InputMediaDocument{
345		BaseInputMedia: BaseInputMedia{
346			Type:  "document",
347			Media: media,
348		},
349	}
350}
351
352// NewContact allows you to send a shared contact.
353func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
354	return ContactConfig{
355		BaseChat: BaseChat{
356			ChatID: chatID,
357		},
358		PhoneNumber: phoneNumber,
359		FirstName:   firstName,
360	}
361}
362
363// NewLocation shares your location.
364//
365// chatID is where to send it, latitude and longitude are coordinates.
366func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
367	return LocationConfig{
368		BaseChat: BaseChat{
369			ChatID: chatID,
370		},
371		Latitude:  latitude,
372		Longitude: longitude,
373	}
374}
375
376// NewVenue allows you to send a venue and its location.
377func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
378	return VenueConfig{
379		BaseChat: BaseChat{
380			ChatID: chatID,
381		},
382		Title:     title,
383		Address:   address,
384		Latitude:  latitude,
385		Longitude: longitude,
386	}
387}
388
389// NewChatAction sets a chat action.
390// Actions last for 5 seconds, or until your next action.
391//
392// chatID is where to send it, action should be set via Chat constants.
393func NewChatAction(chatID int64, action string) ChatActionConfig {
394	return ChatActionConfig{
395		BaseChat: BaseChat{ChatID: chatID},
396		Action:   action,
397	}
398}
399
400// NewUserProfilePhotos gets user profile photos.
401//
402// userID is the ID of the user you wish to get profile photos from.
403func NewUserProfilePhotos(userID int) UserProfilePhotosConfig {
404	return UserProfilePhotosConfig{
405		UserID: userID,
406		Offset: 0,
407		Limit:  0,
408	}
409}
410
411// NewUpdate gets updates since the last Offset.
412//
413// offset is the last Update ID to include.
414// You likely want to set this to the last Update ID plus 1.
415func NewUpdate(offset int) UpdateConfig {
416	return UpdateConfig{
417		Offset:  offset,
418		Limit:   0,
419		Timeout: 0,
420	}
421}
422
423// NewWebhook creates a new webhook.
424//
425// link is the url parsable link you wish to get the updates.
426func NewWebhook(link string) WebhookConfig {
427	u, _ := url.Parse(link)
428
429	return WebhookConfig{
430		URL: u,
431	}
432}
433
434// NewWebhookWithCert creates a new webhook with a certificate.
435//
436// link is the url you wish to get webhooks,
437// file contains a string to a file, FileReader, or FileBytes.
438func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
439	u, _ := url.Parse(link)
440
441	return WebhookConfig{
442		URL:         u,
443		Certificate: file,
444	}
445}
446
447// NewInlineQueryResultArticle creates a new inline query article.
448func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
449	return InlineQueryResultArticle{
450		Type:  "article",
451		ID:    id,
452		Title: title,
453		InputMessageContent: InputTextMessageContent{
454			Text: messageText,
455		},
456	}
457}
458
459// NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
460func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle {
461	return InlineQueryResultArticle{
462		Type:  "article",
463		ID:    id,
464		Title: title,
465		InputMessageContent: InputTextMessageContent{
466			Text:      messageText,
467			ParseMode: "Markdown",
468		},
469	}
470}
471
472// NewInlineQueryResultArticleMarkdownV2 creates a new inline query article with MarkdownV2 parsing.
473func NewInlineQueryResultArticleMarkdownV2(id, title, messageText string) InlineQueryResultArticle {
474	return InlineQueryResultArticle{
475		Type:  "article",
476		ID:    id,
477		Title: title,
478		InputMessageContent: InputTextMessageContent{
479			Text:      messageText,
480			ParseMode: "MarkdownV2",
481		},
482	}
483}
484
485// NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
486func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle {
487	return InlineQueryResultArticle{
488		Type:  "article",
489		ID:    id,
490		Title: title,
491		InputMessageContent: InputTextMessageContent{
492			Text:      messageText,
493			ParseMode: "HTML",
494		},
495	}
496}
497
498// NewInlineQueryResultGIF creates a new inline query GIF.
499func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
500	return InlineQueryResultGIF{
501		Type: "gif",
502		ID:   id,
503		URL:  url,
504	}
505}
506
507// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
508func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
509	return InlineQueryResultCachedGIF{
510		Type:  "gif",
511		ID:    id,
512		GifID: gifID,
513	}
514}
515
516// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
517func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
518	return InlineQueryResultMPEG4GIF{
519		Type: "mpeg4_gif",
520		ID:   id,
521		URL:  url,
522	}
523}
524
525// NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached photo.
526func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif {
527	return InlineQueryResultCachedMpeg4Gif{
528		Type:   "mpeg4_gif",
529		ID:     id,
530		MGifID: MPEG4GifID,
531	}
532}
533
534// NewInlineQueryResultPhoto creates a new inline query photo.
535func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
536	return InlineQueryResultPhoto{
537		Type: "photo",
538		ID:   id,
539		URL:  url,
540	}
541}
542
543// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
544func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
545	return InlineQueryResultPhoto{
546		Type:     "photo",
547		ID:       id,
548		URL:      url,
549		ThumbURL: thumb,
550	}
551}
552
553// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
554func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
555	return InlineQueryResultCachedPhoto{
556		Type:    "photo",
557		ID:      id,
558		PhotoID: photoID,
559	}
560}
561
562// NewInlineQueryResultVideo creates a new inline query video.
563func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
564	return InlineQueryResultVideo{
565		Type: "video",
566		ID:   id,
567		URL:  url,
568	}
569}
570
571// NewInlineQueryResultCachedVideo create a new inline query with cached video.
572func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
573	return InlineQueryResultCachedVideo{
574		Type:    "video",
575		ID:      id,
576		VideoID: videoID,
577		Title:   title,
578	}
579}
580
581// NewInlineQueryResultCachedSticker create a new inline query with cached sticker.
582func NewInlineQueryResultCachedSticker(id, stickerID, title string) InlineQueryResultCachedSticker {
583	return InlineQueryResultCachedSticker{
584		Type:      "sticker",
585		ID:        id,
586		StickerID: stickerID,
587		Title:     title,
588	}
589}
590
591// NewInlineQueryResultAudio creates a new inline query audio.
592func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
593	return InlineQueryResultAudio{
594		Type:  "audio",
595		ID:    id,
596		URL:   url,
597		Title: title,
598	}
599}
600
601// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
602func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
603	return InlineQueryResultCachedAudio{
604		Type:    "audio",
605		ID:      id,
606		AudioID: audioID,
607	}
608}
609
610// NewInlineQueryResultVoice creates a new inline query voice.
611func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
612	return InlineQueryResultVoice{
613		Type:  "voice",
614		ID:    id,
615		URL:   url,
616		Title: title,
617	}
618}
619
620// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
621func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
622	return InlineQueryResultCachedVoice{
623		Type:    "voice",
624		ID:      id,
625		VoiceID: voiceID,
626		Title:   title,
627	}
628}
629
630// NewInlineQueryResultDocument creates a new inline query document.
631func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
632	return InlineQueryResultDocument{
633		Type:     "document",
634		ID:       id,
635		URL:      url,
636		Title:    title,
637		MimeType: mimeType,
638	}
639}
640
641// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
642func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
643	return InlineQueryResultCachedDocument{
644		Type:       "document",
645		ID:         id,
646		DocumentID: documentID,
647		Title:      title,
648	}
649}
650
651// NewInlineQueryResultLocation creates a new inline query location.
652func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
653	return InlineQueryResultLocation{
654		Type:      "location",
655		ID:        id,
656		Title:     title,
657		Latitude:  latitude,
658		Longitude: longitude,
659	}
660}
661
662// NewInlineQueryResultVenue creates a new inline query venue.
663func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
664	return InlineQueryResultVenue{
665		Type:      "venue",
666		ID:        id,
667		Title:     title,
668		Address:   address,
669		Latitude:  latitude,
670		Longitude: longitude,
671	}
672}
673
674// NewEditMessageText allows you to edit the text of a message.
675func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
676	return EditMessageTextConfig{
677		BaseEdit: BaseEdit{
678			ChatID:    chatID,
679			MessageID: messageID,
680		},
681		Text: text,
682	}
683}
684
685// NewEditMessageCaption allows you to edit the caption of a message.
686func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
687	return EditMessageCaptionConfig{
688		BaseEdit: BaseEdit{
689			ChatID:    chatID,
690			MessageID: messageID,
691		},
692		Caption: caption,
693	}
694}
695
696// NewEditMessageReplyMarkup allows you to edit the inline
697// keyboard markup.
698func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
699	return EditMessageReplyMarkupConfig{
700		BaseEdit: BaseEdit{
701			ChatID:      chatID,
702			MessageID:   messageID,
703			ReplyMarkup: &replyMarkup,
704		},
705	}
706}
707
708// NewHideKeyboard hides the keyboard, with the option for being selective
709// or hiding for everyone.
710func NewHideKeyboard(selective bool) ReplyKeyboardHide {
711	log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
712
713	return ReplyKeyboardHide{
714		HideKeyboard: true,
715		Selective:    selective,
716	}
717}
718
719// NewRemoveKeyboard hides the keyboard, with the option for being selective
720// or hiding for everyone.
721func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
722	return ReplyKeyboardRemove{
723		RemoveKeyboard: true,
724		Selective:      selective,
725	}
726}
727
728// NewKeyboardButton creates a regular keyboard button.
729func NewKeyboardButton(text string) KeyboardButton {
730	return KeyboardButton{
731		Text: text,
732	}
733}
734
735// NewKeyboardButtonContact creates a keyboard button that requests
736// user contact information upon click.
737func NewKeyboardButtonContact(text string) KeyboardButton {
738	return KeyboardButton{
739		Text:           text,
740		RequestContact: true,
741	}
742}
743
744// NewKeyboardButtonLocation creates a keyboard button that requests
745// user location information upon click.
746func NewKeyboardButtonLocation(text string) KeyboardButton {
747	return KeyboardButton{
748		Text:            text,
749		RequestLocation: true,
750	}
751}
752
753// NewKeyboardButtonRow creates a row of keyboard buttons.
754func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
755	var row []KeyboardButton
756
757	row = append(row, buttons...)
758
759	return row
760}
761
762// NewReplyKeyboard creates a new regular keyboard with sane defaults.
763func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
764	var keyboard [][]KeyboardButton
765
766	keyboard = append(keyboard, rows...)
767
768	return ReplyKeyboardMarkup{
769		ResizeKeyboard: true,
770		Keyboard:       keyboard,
771	}
772}
773
774// NewOneTimeReplyKeyboard creates a new one time keyboard.
775func NewOneTimeReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
776  markup := NewReplyKeyboard(rows...)
777  markup.OneTimeKeyboard = true
778  return markup
779}
780
781// NewInlineKeyboardButtonData creates an inline keyboard button with text
782// and data for a callback.
783func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
784	return InlineKeyboardButton{
785		Text:         text,
786		CallbackData: &data,
787	}
788}
789
790// NewInlineKeyboardButtonURL creates an inline keyboard button with text
791// which goes to a URL.
792func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
793	return InlineKeyboardButton{
794		Text: text,
795		URL:  &url,
796	}
797}
798
799// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
800// text which allows the user to switch to a chat or return to a chat.
801func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
802	return InlineKeyboardButton{
803		Text:              text,
804		SwitchInlineQuery: &sw,
805	}
806}
807
808// NewInlineKeyboardRow creates an inline keyboard row with buttons.
809func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
810	var row []InlineKeyboardButton
811
812	row = append(row, buttons...)
813
814	return row
815}
816
817// NewInlineKeyboardMarkup creates a new inline keyboard.
818func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
819	var keyboard [][]InlineKeyboardButton
820
821	keyboard = append(keyboard, rows...)
822
823	return InlineKeyboardMarkup{
824		InlineKeyboard: keyboard,
825	}
826}
827
828// NewCallback creates a new callback message.
829func NewCallback(id, text string) CallbackConfig {
830	return CallbackConfig{
831		CallbackQueryID: id,
832		Text:            text,
833		ShowAlert:       false,
834	}
835}
836
837// NewCallbackWithAlert creates a new callback message that alerts
838// the user.
839func NewCallbackWithAlert(id, text string) CallbackConfig {
840	return CallbackConfig{
841		CallbackQueryID: id,
842		Text:            text,
843		ShowAlert:       true,
844	}
845}
846
847// NewInvoice creates a new Invoice request to the user.
848func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig {
849	return InvoiceConfig{
850		BaseChat:       BaseChat{ChatID: chatID},
851		Title:          title,
852		Description:    description,
853		Payload:        payload,
854		ProviderToken:  providerToken,
855		StartParameter: startParameter,
856		Currency:       currency,
857		Prices:         prices}
858}
859
860// NewSetChatPhotoUpload creates a new chat photo uploader.
861//
862// chatID is where to send it, file is a string path to the file,
863// FileReader, or FileBytes.
864//
865// Note that you must send animated GIFs as a document.
866func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
867	return SetChatPhotoConfig{
868		BaseFile: BaseFile{
869			BaseChat:    BaseChat{ChatID: chatID},
870			File:        file,
871			UseExisting: false,
872		},
873	}
874}
875
876// NewSetChatPhotoShare shares an existing photo.
877// You may use this to reshare an existing photo without reuploading it.
878//
879// chatID is where to send it, fileID is the ID of the file
880// already uploaded.
881func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
882	return SetChatPhotoConfig{
883		BaseFile: BaseFile{
884			BaseChat:    BaseChat{ChatID: chatID},
885			FileID:      fileID,
886			UseExisting: true,
887		},
888	}
889}
890
891// NewChatTitle allows you to update the title of a chat.
892func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
893	return SetChatTitleConfig{
894		ChatID: chatID,
895		Title:  title,
896	}
897}
898
899// NewChatDescription allows you to update the description of a chat.
900func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig {
901	return SetChatDescriptionConfig{
902		ChatID:      chatID,
903		Description: description,
904	}
905}
906
907// NewChatPhoto allows you to update the photo for a chat.
908func NewChatPhoto(chatID int64, photo interface{}) SetChatPhotoConfig {
909	return SetChatPhotoConfig{
910		BaseFile: BaseFile{
911			BaseChat: BaseChat{
912				ChatID: chatID,
913			},
914			File: photo,
915		},
916	}
917}
918
919// NewDeleteChatPhoto allows you to delete the photo for a chat.
920func NewDeleteChatPhoto(chatID int64, photo interface{}) DeleteChatPhotoConfig {
921	return DeleteChatPhotoConfig{
922		ChatID: chatID,
923	}
924}
925
926// NewPoll allows you to create a new poll.
927func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
928	return SendPollConfig{
929		BaseChat: BaseChat{
930			ChatID: chatID,
931		},
932		Question:    question,
933		Options:     options,
934		IsAnonymous: true, // This is Telegram's default.
935	}
936}
937
938// NewStopPoll allows you to stop a poll.
939func NewStopPoll(chatID int64, messageID int) StopPollConfig {
940	return StopPollConfig{
941		BaseEdit{
942			ChatID:    chatID,
943			MessageID: messageID,
944		},
945	}
946}
947
948// NewSendDice allows you to send a random dice roll.
949//
950// Deprecated: Use NewDice instead.
951func NewSendDice(chatID int64) DiceConfig {
952	return NewDice(chatID)
953}
954
955// NewDice allows you to send a random dice roll.
956func NewDice(chatID int64) DiceConfig {
957	return DiceConfig{
958		BaseChat: BaseChat{
959			ChatID: chatID,
960		},
961	}
962}
963
964// NewDiceWithEmoji allows you to send a random roll of one of many types.
965//
966// Emoji may be 🎲 (1-6), 🎯 (1-6), or 🏀 (1-5).
967func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig {
968	return DiceConfig{
969		BaseChat: BaseChat{
970			ChatID: chatID,
971		},
972		Emoji: emoji,
973	}
974}
975
976// NewSetMyCommands allows you to set the registered commands.
977func NewSetMyCommands(commands ...BotCommand) SetMyCommandsConfig {
978	return SetMyCommandsConfig{commands: commands}
979}