all repos — telegram-bot-api @ 00ae0202053389c6ad3932d730e3f9fcdcace649

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