all repos — telegram-bot-api @ a36ca539258ee740dc581ead09abafb622517621

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