all repos — telegram-bot-api @ 69a82708c4a94bebe8155f62512f47504b4f650e

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