all repos — telegram-bot-api @ 53dec076c194332f6f38a84064ea6a43b9e53b69

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// NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
473func NewInlineQueryResultArticleHTML(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: "HTML",
481		},
482	}
483}
484
485// NewInlineQueryResultGIF creates a new inline query GIF.
486func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
487	return InlineQueryResultGIF{
488		Type: "gif",
489		ID:   id,
490		URL:  url,
491	}
492}
493
494// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
495func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
496	return InlineQueryResultCachedGIF{
497		Type:  "gif",
498		ID:    id,
499		GifID: gifID,
500	}
501}
502
503// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
504func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
505	return InlineQueryResultMPEG4GIF{
506		Type: "mpeg4_gif",
507		ID:   id,
508		URL:  url,
509	}
510}
511
512// NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached photo.
513func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif {
514	return InlineQueryResultCachedMpeg4Gif{
515		Type:   "mpeg4_gif",
516		ID:     id,
517		MGifID: MPEG4GifID,
518	}
519}
520
521// NewInlineQueryResultPhoto creates a new inline query photo.
522func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
523	return InlineQueryResultPhoto{
524		Type: "photo",
525		ID:   id,
526		URL:  url,
527	}
528}
529
530// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
531func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
532	return InlineQueryResultPhoto{
533		Type:     "photo",
534		ID:       id,
535		URL:      url,
536		ThumbURL: thumb,
537	}
538}
539
540// NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
541func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
542	return InlineQueryResultCachedPhoto{
543		Type:    "photo",
544		ID:      id,
545		PhotoID: photoID,
546	}
547}
548
549// NewInlineQueryResultVideo creates a new inline query video.
550func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
551	return InlineQueryResultVideo{
552		Type: "video",
553		ID:   id,
554		URL:  url,
555	}
556}
557
558// NewInlineQueryResultCachedVideo create a new inline query with cached video.
559func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
560	return InlineQueryResultCachedVideo{
561		Type:    "video",
562		ID:      id,
563		VideoID: videoID,
564		Title:   title,
565	}
566}
567
568// NewInlineQueryResultAudio creates a new inline query audio.
569func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
570	return InlineQueryResultAudio{
571		Type:  "audio",
572		ID:    id,
573		URL:   url,
574		Title: title,
575	}
576}
577
578// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
579func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
580	return InlineQueryResultCachedAudio{
581		Type:    "audio",
582		ID:      id,
583		AudioID: audioID,
584	}
585}
586
587// NewInlineQueryResultVoice creates a new inline query voice.
588func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
589	return InlineQueryResultVoice{
590		Type:  "voice",
591		ID:    id,
592		URL:   url,
593		Title: title,
594	}
595}
596
597// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
598func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
599	return InlineQueryResultCachedVoice{
600		Type:    "voice",
601		ID:      id,
602		VoiceID: voiceID,
603		Title:   title,
604	}
605}
606
607// NewInlineQueryResultDocument creates a new inline query document.
608func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
609	return InlineQueryResultDocument{
610		Type:     "document",
611		ID:       id,
612		URL:      url,
613		Title:    title,
614		MimeType: mimeType,
615	}
616}
617
618// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
619func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
620	return InlineQueryResultCachedDocument{
621		Type:       "document",
622		ID:         id,
623		DocumentID: documentID,
624		Title:      title,
625	}
626}
627
628// NewInlineQueryResultLocation creates a new inline query location.
629func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
630	return InlineQueryResultLocation{
631		Type:      "location",
632		ID:        id,
633		Title:     title,
634		Latitude:  latitude,
635		Longitude: longitude,
636	}
637}
638
639// NewInlineQueryResultVenue creates a new inline query venue.
640func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
641	return InlineQueryResultVenue{
642		Type:      "venue",
643		ID:        id,
644		Title:     title,
645		Address:   address,
646		Latitude:  latitude,
647		Longitude: longitude,
648	}
649}
650
651// NewEditMessageText allows you to edit the text of a message.
652func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
653	return EditMessageTextConfig{
654		BaseEdit: BaseEdit{
655			ChatID:    chatID,
656			MessageID: messageID,
657		},
658		Text: text,
659	}
660}
661
662// NewEditMessageCaption allows you to edit the caption of a message.
663func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
664	return EditMessageCaptionConfig{
665		BaseEdit: BaseEdit{
666			ChatID:    chatID,
667			MessageID: messageID,
668		},
669		Caption: caption,
670	}
671}
672
673// NewEditMessageReplyMarkup allows you to edit the inline
674// keyboard markup.
675func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
676	return EditMessageReplyMarkupConfig{
677		BaseEdit: BaseEdit{
678			ChatID:      chatID,
679			MessageID:   messageID,
680			ReplyMarkup: &replyMarkup,
681		},
682	}
683}
684
685// NewHideKeyboard hides the keyboard, with the option for being selective
686// or hiding for everyone.
687func NewHideKeyboard(selective bool) ReplyKeyboardHide {
688	log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
689
690	return ReplyKeyboardHide{
691		HideKeyboard: true,
692		Selective:    selective,
693	}
694}
695
696// NewRemoveKeyboard hides the keyboard, with the option for being selective
697// or hiding for everyone.
698func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
699	return ReplyKeyboardRemove{
700		RemoveKeyboard: true,
701		Selective:      selective,
702	}
703}
704
705// NewKeyboardButton creates a regular keyboard button.
706func NewKeyboardButton(text string) KeyboardButton {
707	return KeyboardButton{
708		Text: text,
709	}
710}
711
712// NewKeyboardButtonContact creates a keyboard button that requests
713// user contact information upon click.
714func NewKeyboardButtonContact(text string) KeyboardButton {
715	return KeyboardButton{
716		Text:           text,
717		RequestContact: true,
718	}
719}
720
721// NewKeyboardButtonLocation creates a keyboard button that requests
722// user location information upon click.
723func NewKeyboardButtonLocation(text string) KeyboardButton {
724	return KeyboardButton{
725		Text:            text,
726		RequestLocation: true,
727	}
728}
729
730// NewKeyboardButtonRow creates a row of keyboard buttons.
731func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
732	var row []KeyboardButton
733
734	row = append(row, buttons...)
735
736	return row
737}
738
739// NewReplyKeyboard creates a new regular keyboard with sane defaults.
740func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
741	var keyboard [][]KeyboardButton
742
743	keyboard = append(keyboard, rows...)
744
745	return ReplyKeyboardMarkup{
746		ResizeKeyboard: true,
747		Keyboard:       keyboard,
748	}
749}
750
751// NewInlineKeyboardButtonData creates an inline keyboard button with text
752// and data for a callback.
753func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
754	return InlineKeyboardButton{
755		Text:         text,
756		CallbackData: &data,
757	}
758}
759
760// NewInlineKeyboardButtonURL creates an inline keyboard button with text
761// which goes to a URL.
762func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
763	return InlineKeyboardButton{
764		Text: text,
765		URL:  &url,
766	}
767}
768
769// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
770// text which allows the user to switch to a chat or return to a chat.
771func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
772	return InlineKeyboardButton{
773		Text:              text,
774		SwitchInlineQuery: &sw,
775	}
776}
777
778// NewInlineKeyboardRow creates an inline keyboard row with buttons.
779func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
780	var row []InlineKeyboardButton
781
782	row = append(row, buttons...)
783
784	return row
785}
786
787// NewInlineKeyboardMarkup creates a new inline keyboard.
788func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
789	var keyboard [][]InlineKeyboardButton
790
791	keyboard = append(keyboard, rows...)
792
793	return InlineKeyboardMarkup{
794		InlineKeyboard: keyboard,
795	}
796}
797
798// NewCallback creates a new callback message.
799func NewCallback(id, text string) CallbackConfig {
800	return CallbackConfig{
801		CallbackQueryID: id,
802		Text:            text,
803		ShowAlert:       false,
804	}
805}
806
807// NewCallbackWithAlert creates a new callback message that alerts
808// the user.
809func NewCallbackWithAlert(id, text string) CallbackConfig {
810	return CallbackConfig{
811		CallbackQueryID: id,
812		Text:            text,
813		ShowAlert:       true,
814	}
815}
816
817// NewInvoice creates a new Invoice request to the user.
818func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig {
819	return InvoiceConfig{
820		BaseChat:       BaseChat{ChatID: chatID},
821		Title:          title,
822		Description:    description,
823		Payload:        payload,
824		ProviderToken:  providerToken,
825		StartParameter: startParameter,
826		Currency:       currency,
827		Prices:         prices}
828}
829
830// NewSetChatPhotoUpload creates a new chat photo uploader.
831//
832// chatID is where to send it, file is a string path to the file,
833// FileReader, or FileBytes.
834//
835// Note that you must send animated GIFs as a document.
836func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig {
837	return SetChatPhotoConfig{
838		BaseFile: BaseFile{
839			BaseChat:    BaseChat{ChatID: chatID},
840			File:        file,
841			UseExisting: false,
842		},
843	}
844}
845
846// NewSetChatPhotoShare shares an existing photo.
847// You may use this to reshare an existing photo without reuploading it.
848//
849// chatID is where to send it, fileID is the ID of the file
850// already uploaded.
851func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig {
852	return SetChatPhotoConfig{
853		BaseFile: BaseFile{
854			BaseChat:    BaseChat{ChatID: chatID},
855			FileID:      fileID,
856			UseExisting: true,
857		},
858	}
859}
860
861// NewChatTitle allows you to update the title of a chat.
862func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
863	return SetChatTitleConfig{
864		ChatID: chatID,
865		Title:  title,
866	}
867}
868
869// NewChatDescription allows you to update the description of a chat.
870func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig {
871	return SetChatDescriptionConfig{
872		ChatID:      chatID,
873		Description: description,
874	}
875}
876
877// NewChatPhoto allows you to update the photo for a chat.
878func NewChatPhoto(chatID int64, photo interface{}) SetChatPhotoConfig {
879	return SetChatPhotoConfig{
880		BaseFile: BaseFile{
881			BaseChat: BaseChat{
882				ChatID: chatID,
883			},
884			File: photo,
885		},
886	}
887}
888
889// NewDeleteChatPhoto allows you to delete the photo for a chat.
890func NewDeleteChatPhoto(chatID int64, photo interface{}) DeleteChatPhotoConfig {
891	return DeleteChatPhotoConfig{
892		ChatID: chatID,
893	}
894}
895
896// NewPoll allows you to create a new poll.
897func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
898	return SendPollConfig{
899		BaseChat: BaseChat{
900			ChatID: chatID,
901		},
902		Question:    question,
903		Options:     options,
904		IsAnonymous: true, // This is Telegram's default.
905	}
906}
907
908// NewStopPoll allows you to stop a poll.
909func NewStopPoll(chatID int64, messageID int) StopPollConfig {
910	return StopPollConfig{
911		BaseEdit{
912			ChatID:    chatID,
913			MessageID: messageID,
914		},
915	}
916}
917
918// NewSendDice allows you to send a random dice roll.
919func NewSendDice(chatID int64) DiceConfig {
920	return DiceConfig{
921		BaseChat{
922			ChatID: chatID,
923		},
924	}
925}
926
927// NewSetMyCommands allows you to set the registered commands.
928func NewSetMyCommands(commands ...BotCommand) SetMyCommandsConfig {
929	return SetMyCommandsConfig{commands: commands}
930}