all repos — telegram-bot-api @ c33a1d7c567142ea1770c270da0f4410e0dc0eaf

Golang bindings for the Telegram Bot API

configs.go (view raw)

   1package tgbotapi
   2
   3import (
   4	"bytes"
   5	"fmt"
   6	"io"
   7	"net/url"
   8	"os"
   9	"strconv"
  10)
  11
  12// Telegram constants
  13const (
  14	// APIEndpoint is the endpoint for all API methods,
  15	// with formatting for Sprintf.
  16	APIEndpoint = "https://api.telegram.org/bot%s/%s"
  17	// FileEndpoint is the endpoint for downloading a file from Telegram.
  18	FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
  19)
  20
  21// Constant values for ChatActions
  22const (
  23	ChatTyping          = "typing"
  24	ChatUploadPhoto     = "upload_photo"
  25	ChatRecordVideo     = "record_video"
  26	ChatUploadVideo     = "upload_video"
  27	ChatRecordVoice     = "record_voice"
  28	ChatUploadVoice     = "upload_voice"
  29	ChatUploadDocument  = "upload_document"
  30	ChatChooseSticker   = "choose_sticker"
  31	ChatFindLocation    = "find_location"
  32	ChatRecordVideoNote = "record_video_note"
  33	ChatUploadVideoNote = "upload_video_note"
  34)
  35
  36// API errors
  37const (
  38	// ErrAPIForbidden happens when a token is bad
  39	ErrAPIForbidden = "forbidden"
  40)
  41
  42// Constant values for ParseMode in MessageConfig
  43const (
  44	ModeMarkdown   = "Markdown"
  45	ModeMarkdownV2 = "MarkdownV2"
  46	ModeHTML       = "HTML"
  47)
  48
  49// Constant values for update types
  50const (
  51	// UpdateTypeMessage is new incoming message of any kind — text, photo, sticker, etc.
  52	UpdateTypeMessage = "message"
  53
  54	// UpdateTypeEditedMessage is new version of a message that is known to the bot and was edited
  55	UpdateTypeEditedMessage = "edited_message"
  56
  57	// UpdateTypeChannelPost is new incoming channel post of any kind — text, photo, sticker, etc.
  58	UpdateTypeChannelPost = "channel_post"
  59
  60	// UpdateTypeEditedChannelPost is new version of a channel post that is known to the bot and was edited
  61	UpdateTypeEditedChannelPost = "edited_channel_post"
  62
  63	// UpdateTypeInlineQuery is new incoming inline query
  64	UpdateTypeInlineQuery = "inline_query"
  65
  66	// UpdateTypeChosenInlineResult i the result of an inline query that was chosen by a user and sent to their
  67	// chat partner. Please see the documentation on the feedback collecting for
  68	// details on how to enable these updates for your bot.
  69	UpdateTypeChosenInlineResult = "chosen_inline_result"
  70
  71	// UpdateTypeCallbackQuery is new incoming callback query
  72	UpdateTypeCallbackQuery = "callback_query"
  73
  74	// UpdateTypeShippingQuery is new incoming shipping query. Only for invoices with flexible price
  75	UpdateTypeShippingQuery = "shipping_query"
  76
  77	// UpdateTypePreCheckoutQuery is new incoming pre-checkout query. Contains full information about checkout
  78	UpdateTypePreCheckoutQuery = "pre_checkout_query"
  79
  80	// UpdateTypePoll is new poll state. Bots receive only updates about stopped polls and polls
  81	// which are sent by the bot
  82	UpdateTypePoll = "poll"
  83
  84	// UpdateTypePollAnswer is when user changed their answer in a non-anonymous poll. Bots receive new votes
  85	// only in polls that were sent by the bot itself.
  86	UpdateTypePollAnswer = "poll_answer"
  87
  88	// UpdateTypeMyChatMember is when the bot's chat member status was updated in a chat. For private chats, this
  89	// update is received only when the bot is blocked or unblocked by the user.
  90	UpdateTypeMyChatMember = "my_chat_member"
  91
  92	// UpdateTypeChatMember is when the bot must be an administrator in the chat and must explicitly specify
  93	// this update in the list of allowed_updates to receive these updates.
  94	UpdateTypeChatMember = "chat_member"
  95)
  96
  97// Library errors
  98const (
  99	ErrBadURL = "bad or empty url"
 100)
 101
 102// Chattable is any config type that can be sent.
 103type Chattable interface {
 104	params() (Params, error)
 105	method() string
 106}
 107
 108// Fileable is any config type that can be sent that includes a file.
 109type Fileable interface {
 110	Chattable
 111	files() []RequestFile
 112}
 113
 114// RequestFile represents a file associated with a field name.
 115type RequestFile struct {
 116	// The file field name.
 117	Name string
 118	// The file data to include.
 119	Data RequestFileData
 120}
 121
 122// RequestFileData represents the data to be used for a file.
 123type RequestFileData interface {
 124	// NeedsUpload shows if the file needs to be uploaded.
 125	NeedsUpload() bool
 126
 127	// UploadData gets the file name and an `io.Reader` for the file to be uploaded. This
 128	// must only be called when the file needs to be uploaded.
 129	UploadData() (string, io.Reader, error)
 130	// SendData gets the file data to send when a file does not need to be uploaded. This
 131	// must only be called when the file does not need to be uploaded.
 132	SendData() string
 133}
 134
 135// FileBytes contains information about a set of bytes to upload
 136// as a File.
 137type FileBytes struct {
 138	Name  string
 139	Bytes []byte
 140}
 141
 142func (fb FileBytes) NeedsUpload() bool {
 143	return true
 144}
 145
 146func (fb FileBytes) UploadData() (string, io.Reader, error) {
 147	return fb.Name, bytes.NewReader(fb.Bytes), nil
 148}
 149
 150func (fb FileBytes) SendData() string {
 151	panic("FileBytes must be uploaded")
 152}
 153
 154// FileReader contains information about a reader to upload as a File.
 155type FileReader struct {
 156	Name   string
 157	Reader io.Reader
 158}
 159
 160func (fr FileReader) NeedsUpload() bool {
 161	return true
 162}
 163
 164func (fr FileReader) UploadData() (string, io.Reader, error) {
 165	return fr.Name, fr.Reader, nil
 166}
 167
 168func (fr FileReader) SendData() string {
 169	panic("FileReader must be uploaded")
 170}
 171
 172// FilePath is a path to a local file.
 173type FilePath string
 174
 175func (fp FilePath) NeedsUpload() bool {
 176	return true
 177}
 178
 179func (fp FilePath) UploadData() (string, io.Reader, error) {
 180	fileHandle, err := os.Open(string(fp))
 181	if err != nil {
 182		return "", nil, err
 183	}
 184
 185	name := fileHandle.Name()
 186	return name, fileHandle, err
 187}
 188
 189func (fp FilePath) SendData() string {
 190	panic("FilePath must be uploaded")
 191}
 192
 193// FileURL is a URL to use as a file for a request.
 194type FileURL string
 195
 196func (fu FileURL) NeedsUpload() bool {
 197	return false
 198}
 199
 200func (fu FileURL) UploadData() (string, io.Reader, error) {
 201	panic("FileURL cannot be uploaded")
 202}
 203
 204func (fu FileURL) SendData() string {
 205	return string(fu)
 206}
 207
 208// FileID is an ID of a file already uploaded to Telegram.
 209type FileID string
 210
 211func (fi FileID) NeedsUpload() bool {
 212	return false
 213}
 214
 215func (fi FileID) UploadData() (string, io.Reader, error) {
 216	panic("FileID cannot be uploaded")
 217}
 218
 219func (fi FileID) SendData() string {
 220	return string(fi)
 221}
 222
 223// fileAttach is an internal file type used for processed media groups.
 224type fileAttach string
 225
 226func (fa fileAttach) NeedsUpload() bool {
 227	return false
 228}
 229
 230func (fa fileAttach) UploadData() (string, io.Reader, error) {
 231	panic("fileAttach cannot be uploaded")
 232}
 233
 234func (fa fileAttach) SendData() string {
 235	return string(fa)
 236}
 237
 238// LogOutConfig is a request to log out of the cloud Bot API server.
 239//
 240// Note that you may not log back in for at least 10 minutes.
 241type LogOutConfig struct{}
 242
 243func (LogOutConfig) method() string {
 244	return "logOut"
 245}
 246
 247func (LogOutConfig) params() (Params, error) {
 248	return nil, nil
 249}
 250
 251// CloseConfig is a request to close the bot instance on a local server.
 252//
 253// Note that you may not close an instance for the first 10 minutes after the
 254// bot has started.
 255type CloseConfig struct{}
 256
 257func (CloseConfig) method() string {
 258	return "close"
 259}
 260
 261func (CloseConfig) params() (Params, error) {
 262	return nil, nil
 263}
 264
 265// BaseChat is base type for all chat config types.
 266type BaseChat struct {
 267	ChatID                   int64 // required
 268	MessageThreadID          int
 269	ChannelUsername          string
 270	ProtectContent           bool
 271	ReplyToMessageID         int
 272	ReplyMarkup              interface{}
 273	DisableNotification      bool
 274	AllowSendingWithoutReply bool
 275}
 276
 277func (chat *BaseChat) params() (Params, error) {
 278	params := make(Params)
 279
 280	params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
 281	params.AddNonZero("message_thread_id", chat.MessageThreadID)
 282	params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
 283	params.AddBool("disable_notification", chat.DisableNotification)
 284	params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
 285	params.AddBool("protect_content", chat.ProtectContent)
 286
 287	err := params.AddInterface("reply_markup", chat.ReplyMarkup)
 288
 289	return params, err
 290}
 291
 292// BaseFile is a base type for all file config types.
 293type BaseFile struct {
 294	BaseChat
 295	File RequestFileData
 296}
 297
 298func (file BaseFile) params() (Params, error) {
 299	return file.BaseChat.params()
 300}
 301
 302// BaseEdit is base type of all chat edits.
 303type BaseEdit struct {
 304	ChatID          int64
 305	ChannelUsername string
 306	MessageID       int
 307	InlineMessageID string
 308	ReplyMarkup     *InlineKeyboardMarkup
 309}
 310
 311func (edit BaseEdit) params() (Params, error) {
 312	params := make(Params)
 313
 314	if edit.InlineMessageID != "" {
 315		params["inline_message_id"] = edit.InlineMessageID
 316	} else {
 317		params.AddFirstValid("chat_id", edit.ChatID, edit.ChannelUsername)
 318		params.AddNonZero("message_id", edit.MessageID)
 319	}
 320
 321	err := params.AddInterface("reply_markup", edit.ReplyMarkup)
 322
 323	return params, err
 324}
 325
 326// BaseSpoiler is base type of structures with spoilers.
 327type BaseSpoiler struct {
 328	HasSpoiler bool
 329}
 330
 331func (spoiler BaseSpoiler) params() (Params, error) {
 332	params := make(Params)
 333
 334	if spoiler.HasSpoiler {
 335		params.AddBool("has_spoiler", true)
 336	}
 337
 338	return params, nil
 339}
 340
 341// MessageConfig contains information about a SendMessage request.
 342type MessageConfig struct {
 343	BaseChat
 344	Text                  string
 345	ParseMode             string
 346	Entities              []MessageEntity
 347	DisableWebPagePreview bool
 348}
 349
 350func (config MessageConfig) params() (Params, error) {
 351	params, err := config.BaseChat.params()
 352	if err != nil {
 353		return params, err
 354	}
 355
 356	params.AddNonEmpty("text", config.Text)
 357	params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
 358	params.AddNonEmpty("parse_mode", config.ParseMode)
 359	err = params.AddInterface("entities", config.Entities)
 360
 361	return params, err
 362}
 363
 364func (config MessageConfig) method() string {
 365	return "sendMessage"
 366}
 367
 368// ForwardConfig contains information about a ForwardMessage request.
 369type ForwardConfig struct {
 370	BaseChat
 371	FromChatID          int64 // required
 372	FromChannelUsername string
 373	MessageID           int // required
 374}
 375
 376func (config ForwardConfig) params() (Params, error) {
 377	params, err := config.BaseChat.params()
 378	if err != nil {
 379		return params, err
 380	}
 381
 382	params.AddNonZero64("from_chat_id", config.FromChatID)
 383	params.AddNonZero("message_id", config.MessageID)
 384
 385	return params, nil
 386}
 387
 388func (config ForwardConfig) method() string {
 389	return "forwardMessage"
 390}
 391
 392// CopyMessageConfig contains information about a copyMessage request.
 393type CopyMessageConfig struct {
 394	BaseChat
 395	FromChatID          int64
 396	FromChannelUsername string
 397	MessageID           int
 398	Caption             string
 399	ParseMode           string
 400	CaptionEntities     []MessageEntity
 401}
 402
 403func (config CopyMessageConfig) params() (Params, error) {
 404	params, err := config.BaseChat.params()
 405	if err != nil {
 406		return params, err
 407	}
 408
 409	params.AddFirstValid("from_chat_id", config.FromChatID, config.FromChannelUsername)
 410	params.AddNonZero("message_id", config.MessageID)
 411	params.AddNonEmpty("caption", config.Caption)
 412	params.AddNonEmpty("parse_mode", config.ParseMode)
 413	err = params.AddInterface("caption_entities", config.CaptionEntities)
 414
 415	return params, err
 416}
 417
 418func (config CopyMessageConfig) method() string {
 419	return "copyMessage"
 420}
 421
 422// PhotoConfig contains information about a SendPhoto request.
 423type PhotoConfig struct {
 424	BaseFile
 425	BaseSpoiler
 426	Thumb           RequestFileData
 427	Caption         string
 428	ParseMode       string
 429	CaptionEntities []MessageEntity
 430}
 431
 432func (config PhotoConfig) params() (Params, error) {
 433	params, err := config.BaseFile.params()
 434	if err != nil {
 435		return params, err
 436	}
 437
 438	params.AddNonEmpty("caption", config.Caption)
 439	params.AddNonEmpty("parse_mode", config.ParseMode)
 440	err = params.AddInterface("caption_entities", config.CaptionEntities)
 441	if err != nil {
 442		return params, err
 443	}
 444
 445	p1, err := config.BaseSpoiler.params()
 446	if err != nil {
 447		return params, err
 448	}
 449	params.Merge(p1)
 450
 451	return params, err
 452}
 453
 454func (config PhotoConfig) method() string {
 455	return "sendPhoto"
 456}
 457
 458func (config PhotoConfig) files() []RequestFile {
 459	files := []RequestFile{{
 460		Name: "photo",
 461		Data: config.File,
 462	}}
 463
 464	if config.Thumb != nil {
 465		files = append(files, RequestFile{
 466			Name: "thumbnail",
 467			Data: config.Thumb,
 468		})
 469	}
 470
 471	return files
 472}
 473
 474// AudioConfig contains information about a SendAudio request.
 475type AudioConfig struct {
 476	BaseFile
 477	Thumb           RequestFileData
 478	Caption         string
 479	ParseMode       string
 480	CaptionEntities []MessageEntity
 481	Duration        int
 482	Performer       string
 483	Title           string
 484}
 485
 486func (config AudioConfig) params() (Params, error) {
 487	params, err := config.BaseChat.params()
 488	if err != nil {
 489		return params, err
 490	}
 491
 492	params.AddNonZero("duration", config.Duration)
 493	params.AddNonEmpty("performer", config.Performer)
 494	params.AddNonEmpty("title", config.Title)
 495	params.AddNonEmpty("caption", config.Caption)
 496	params.AddNonEmpty("parse_mode", config.ParseMode)
 497	err = params.AddInterface("caption_entities", config.CaptionEntities)
 498
 499	return params, err
 500}
 501
 502func (config AudioConfig) method() string {
 503	return "sendAudio"
 504}
 505
 506func (config AudioConfig) files() []RequestFile {
 507	files := []RequestFile{{
 508		Name: "audio",
 509		Data: config.File,
 510	}}
 511
 512	if config.Thumb != nil {
 513		files = append(files, RequestFile{
 514			Name: "thumbnail",
 515			Data: config.Thumb,
 516		})
 517	}
 518
 519	return files
 520}
 521
 522// DocumentConfig contains information about a SendDocument request.
 523type DocumentConfig struct {
 524	BaseFile
 525	Thumb                       RequestFileData
 526	Caption                     string
 527	ParseMode                   string
 528	CaptionEntities             []MessageEntity
 529	DisableContentTypeDetection bool
 530}
 531
 532func (config DocumentConfig) params() (Params, error) {
 533	params, err := config.BaseFile.params()
 534
 535	params.AddNonEmpty("caption", config.Caption)
 536	params.AddNonEmpty("parse_mode", config.ParseMode)
 537	params.AddBool("disable_content_type_detection", config.DisableContentTypeDetection)
 538
 539	return params, err
 540}
 541
 542func (config DocumentConfig) method() string {
 543	return "sendDocument"
 544}
 545
 546func (config DocumentConfig) files() []RequestFile {
 547	files := []RequestFile{{
 548		Name: "document",
 549		Data: config.File,
 550	}}
 551
 552	if config.Thumb != nil {
 553		files = append(files, RequestFile{
 554			Name: "thumbnail",
 555			Data: config.Thumb,
 556		})
 557	}
 558
 559	return files
 560}
 561
 562// StickerConfig contains information about a SendSticker request.
 563type StickerConfig struct {
 564	//Emoji associated with the sticker; only for just uploaded stickers
 565	Emoji string
 566	BaseFile
 567}
 568
 569func (config StickerConfig) params() (Params, error) {
 570	params, err := config.BaseChat.params()
 571	if err != nil {
 572		return params, err
 573	}
 574	params.AddNonEmpty("emoji", config.Emoji)
 575	return params, err
 576}
 577
 578func (config StickerConfig) method() string {
 579	return "sendSticker"
 580}
 581
 582func (config StickerConfig) files() []RequestFile {
 583	return []RequestFile{{
 584		Name: "sticker",
 585		Data: config.File,
 586	}}
 587}
 588
 589// VideoConfig contains information about a SendVideo request.
 590type VideoConfig struct {
 591	BaseFile
 592	BaseSpoiler
 593	Thumb             RequestFileData
 594	Duration          int
 595	Caption           string
 596	ParseMode         string
 597	CaptionEntities   []MessageEntity
 598	SupportsStreaming bool
 599}
 600
 601func (config VideoConfig) params() (Params, error) {
 602	params, err := config.BaseChat.params()
 603	if err != nil {
 604		return params, err
 605	}
 606
 607	params.AddNonZero("duration", config.Duration)
 608	params.AddNonEmpty("caption", config.Caption)
 609	params.AddNonEmpty("parse_mode", config.ParseMode)
 610	params.AddBool("supports_streaming", config.SupportsStreaming)
 611	err = params.AddInterface("caption_entities", config.CaptionEntities)
 612	if err != nil {
 613		return params, err
 614	}
 615
 616	p1, err := config.BaseSpoiler.params()
 617	if err != nil {
 618		return params, err
 619	}
 620	params.Merge(p1)
 621
 622	return params, err
 623}
 624
 625func (config VideoConfig) method() string {
 626	return "sendVideo"
 627}
 628
 629func (config VideoConfig) files() []RequestFile {
 630	files := []RequestFile{{
 631		Name: "video",
 632		Data: config.File,
 633	}}
 634
 635	if config.Thumb != nil {
 636		files = append(files, RequestFile{
 637			Name: "thumbnail",
 638			Data: config.Thumb,
 639		})
 640	}
 641
 642	return files
 643}
 644
 645// AnimationConfig contains information about a SendAnimation request.
 646type AnimationConfig struct {
 647	BaseFile
 648	BaseSpoiler
 649	Duration        int
 650	Thumb           RequestFileData
 651	Caption         string
 652	ParseMode       string
 653	CaptionEntities []MessageEntity
 654}
 655
 656func (config AnimationConfig) params() (Params, error) {
 657	params, err := config.BaseChat.params()
 658	if err != nil {
 659		return params, err
 660	}
 661
 662	params.AddNonZero("duration", config.Duration)
 663	params.AddNonEmpty("caption", config.Caption)
 664	params.AddNonEmpty("parse_mode", config.ParseMode)
 665	err = params.AddInterface("caption_entities", config.CaptionEntities)
 666	if err != nil {
 667		return params, err
 668	}
 669
 670	p1, err := config.BaseSpoiler.params()
 671	if err != nil {
 672		return params, err
 673	}
 674	params.Merge(p1)
 675
 676	return params, err
 677}
 678
 679func (config AnimationConfig) method() string {
 680	return "sendAnimation"
 681}
 682
 683func (config AnimationConfig) files() []RequestFile {
 684	files := []RequestFile{{
 685		Name: "animation",
 686		Data: config.File,
 687	}}
 688
 689	if config.Thumb != nil {
 690		files = append(files, RequestFile{
 691			Name: "thumbnail",
 692			Data: config.Thumb,
 693		})
 694	}
 695
 696	return files
 697}
 698
 699// VideoNoteConfig contains information about a SendVideoNote request.
 700type VideoNoteConfig struct {
 701	BaseFile
 702	Thumb    RequestFileData
 703	Duration int
 704	Length   int
 705}
 706
 707func (config VideoNoteConfig) params() (Params, error) {
 708	params, err := config.BaseChat.params()
 709
 710	params.AddNonZero("duration", config.Duration)
 711	params.AddNonZero("length", config.Length)
 712
 713	return params, err
 714}
 715
 716func (config VideoNoteConfig) method() string {
 717	return "sendVideoNote"
 718}
 719
 720func (config VideoNoteConfig) files() []RequestFile {
 721	files := []RequestFile{{
 722		Name: "video_note",
 723		Data: config.File,
 724	}}
 725
 726	if config.Thumb != nil {
 727		files = append(files, RequestFile{
 728			Name: "thumbnail",
 729			Data: config.Thumb,
 730		})
 731	}
 732
 733	return files
 734}
 735
 736// VoiceConfig contains information about a SendVoice request.
 737type VoiceConfig struct {
 738	BaseFile
 739	Thumb           RequestFileData
 740	Caption         string
 741	ParseMode       string
 742	CaptionEntities []MessageEntity
 743	Duration        int
 744}
 745
 746func (config VoiceConfig) params() (Params, error) {
 747	params, err := config.BaseChat.params()
 748	if err != nil {
 749		return params, err
 750	}
 751
 752	params.AddNonZero("duration", config.Duration)
 753	params.AddNonEmpty("caption", config.Caption)
 754	params.AddNonEmpty("parse_mode", config.ParseMode)
 755	err = params.AddInterface("caption_entities", config.CaptionEntities)
 756
 757	return params, err
 758}
 759
 760func (config VoiceConfig) method() string {
 761	return "sendVoice"
 762}
 763
 764func (config VoiceConfig) files() []RequestFile {
 765	files := []RequestFile{{
 766		Name: "voice",
 767		Data: config.File,
 768	}}
 769
 770	if config.Thumb != nil {
 771		files = append(files, RequestFile{
 772			Name: "thumbnail",
 773			Data: config.Thumb,
 774		})
 775	}
 776
 777	return files
 778}
 779
 780// LocationConfig contains information about a SendLocation request.
 781type LocationConfig struct {
 782	BaseChat
 783	Latitude             float64 // required
 784	Longitude            float64 // required
 785	HorizontalAccuracy   float64 // optional
 786	LivePeriod           int     // optional
 787	Heading              int     // optional
 788	ProximityAlertRadius int     // optional
 789}
 790
 791func (config LocationConfig) params() (Params, error) {
 792	params, err := config.BaseChat.params()
 793
 794	params.AddNonZeroFloat("latitude", config.Latitude)
 795	params.AddNonZeroFloat("longitude", config.Longitude)
 796	params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
 797	params.AddNonZero("live_period", config.LivePeriod)
 798	params.AddNonZero("heading", config.Heading)
 799	params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
 800
 801	return params, err
 802}
 803
 804func (config LocationConfig) method() string {
 805	return "sendLocation"
 806}
 807
 808// EditMessageLiveLocationConfig allows you to update a live location.
 809type EditMessageLiveLocationConfig struct {
 810	BaseEdit
 811	Latitude             float64 // required
 812	Longitude            float64 // required
 813	HorizontalAccuracy   float64 // optional
 814	Heading              int     // optional
 815	ProximityAlertRadius int     // optional
 816}
 817
 818func (config EditMessageLiveLocationConfig) params() (Params, error) {
 819	params, err := config.BaseEdit.params()
 820
 821	params.AddNonZeroFloat("latitude", config.Latitude)
 822	params.AddNonZeroFloat("longitude", config.Longitude)
 823	params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
 824	params.AddNonZero("heading", config.Heading)
 825	params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
 826
 827	return params, err
 828}
 829
 830func (config EditMessageLiveLocationConfig) method() string {
 831	return "editMessageLiveLocation"
 832}
 833
 834// StopMessageLiveLocationConfig stops updating a live location.
 835type StopMessageLiveLocationConfig struct {
 836	BaseEdit
 837}
 838
 839func (config StopMessageLiveLocationConfig) params() (Params, error) {
 840	return config.BaseEdit.params()
 841}
 842
 843func (config StopMessageLiveLocationConfig) method() string {
 844	return "stopMessageLiveLocation"
 845}
 846
 847// VenueConfig contains information about a SendVenue request.
 848type VenueConfig struct {
 849	BaseChat
 850	Latitude        float64 // required
 851	Longitude       float64 // required
 852	Title           string  // required
 853	Address         string  // required
 854	FoursquareID    string
 855	FoursquareType  string
 856	GooglePlaceID   string
 857	GooglePlaceType string
 858}
 859
 860func (config VenueConfig) params() (Params, error) {
 861	params, err := config.BaseChat.params()
 862
 863	params.AddNonZeroFloat("latitude", config.Latitude)
 864	params.AddNonZeroFloat("longitude", config.Longitude)
 865	params["title"] = config.Title
 866	params["address"] = config.Address
 867	params.AddNonEmpty("foursquare_id", config.FoursquareID)
 868	params.AddNonEmpty("foursquare_type", config.FoursquareType)
 869	params.AddNonEmpty("google_place_id", config.GooglePlaceID)
 870	params.AddNonEmpty("google_place_type", config.GooglePlaceType)
 871
 872	return params, err
 873}
 874
 875func (config VenueConfig) method() string {
 876	return "sendVenue"
 877}
 878
 879// ContactConfig allows you to send a contact.
 880type ContactConfig struct {
 881	BaseChat
 882	PhoneNumber string
 883	FirstName   string
 884	LastName    string
 885	VCard       string
 886}
 887
 888func (config ContactConfig) params() (Params, error) {
 889	params, err := config.BaseChat.params()
 890
 891	params["phone_number"] = config.PhoneNumber
 892	params["first_name"] = config.FirstName
 893
 894	params.AddNonEmpty("last_name", config.LastName)
 895	params.AddNonEmpty("vcard", config.VCard)
 896
 897	return params, err
 898}
 899
 900func (config ContactConfig) method() string {
 901	return "sendContact"
 902}
 903
 904// SendPollConfig allows you to send a poll.
 905type SendPollConfig struct {
 906	BaseChat
 907	Question              string
 908	Options               []string
 909	IsAnonymous           bool
 910	Type                  string
 911	AllowsMultipleAnswers bool
 912	CorrectOptionID       int64
 913	Explanation           string
 914	ExplanationParseMode  string
 915	ExplanationEntities   []MessageEntity
 916	OpenPeriod            int
 917	CloseDate             int
 918	IsClosed              bool
 919}
 920
 921func (config SendPollConfig) params() (Params, error) {
 922	params, err := config.BaseChat.params()
 923	if err != nil {
 924		return params, err
 925	}
 926
 927	params["question"] = config.Question
 928	if err = params.AddInterface("options", config.Options); err != nil {
 929		return params, err
 930	}
 931	params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous)
 932	params.AddNonEmpty("type", config.Type)
 933	params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
 934	params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10)
 935	params.AddBool("is_closed", config.IsClosed)
 936	params.AddNonEmpty("explanation", config.Explanation)
 937	params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode)
 938	params.AddNonZero("open_period", config.OpenPeriod)
 939	params.AddNonZero("close_date", config.CloseDate)
 940	err = params.AddInterface("explanation_entities", config.ExplanationEntities)
 941
 942	return params, err
 943}
 944
 945func (SendPollConfig) method() string {
 946	return "sendPoll"
 947}
 948
 949// GameConfig allows you to send a game.
 950type GameConfig struct {
 951	BaseChat
 952	GameShortName string
 953}
 954
 955func (config GameConfig) params() (Params, error) {
 956	params, err := config.BaseChat.params()
 957
 958	params["game_short_name"] = config.GameShortName
 959
 960	return params, err
 961}
 962
 963func (config GameConfig) method() string {
 964	return "sendGame"
 965}
 966
 967// SetGameScoreConfig allows you to update the game score in a chat.
 968type SetGameScoreConfig struct {
 969	UserID             int64
 970	Score              int
 971	Force              bool
 972	DisableEditMessage bool
 973	ChatID             int64
 974	ChannelUsername    string
 975	MessageID          int
 976	InlineMessageID    string
 977}
 978
 979func (config SetGameScoreConfig) params() (Params, error) {
 980	params := make(Params)
 981
 982	params.AddNonZero64("user_id", config.UserID)
 983	params.AddNonZero("scrore", config.Score)
 984	params.AddBool("disable_edit_message", config.DisableEditMessage)
 985
 986	if config.InlineMessageID != "" {
 987		params["inline_message_id"] = config.InlineMessageID
 988	} else {
 989		params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
 990		params.AddNonZero("message_id", config.MessageID)
 991	}
 992
 993	return params, nil
 994}
 995
 996func (config SetGameScoreConfig) method() string {
 997	return "setGameScore"
 998}
 999
1000// GetGameHighScoresConfig allows you to fetch the high scores for a game.
1001type GetGameHighScoresConfig struct {
1002	UserID          int64
1003	ChatID          int64
1004	ChannelUsername string
1005	MessageID       int
1006	InlineMessageID string
1007}
1008
1009func (config GetGameHighScoresConfig) params() (Params, error) {
1010	params := make(Params)
1011
1012	params.AddNonZero64("user_id", config.UserID)
1013
1014	if config.InlineMessageID != "" {
1015		params["inline_message_id"] = config.InlineMessageID
1016	} else {
1017		params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1018		params.AddNonZero("message_id", config.MessageID)
1019	}
1020
1021	return params, nil
1022}
1023
1024func (config GetGameHighScoresConfig) method() string {
1025	return "getGameHighScores"
1026}
1027
1028// ChatActionConfig contains information about a SendChatAction request.
1029type ChatActionConfig struct {
1030	BaseChat
1031	MessageThreadID int
1032	Action          string // required
1033}
1034
1035func (config ChatActionConfig) params() (Params, error) {
1036	params, err := config.BaseChat.params()
1037
1038	params["action"] = config.Action
1039	params.AddNonZero("message_thread_id", config.MessageThreadID)
1040
1041	return params, err
1042}
1043
1044func (config ChatActionConfig) method() string {
1045	return "sendChatAction"
1046}
1047
1048// EditMessageTextConfig allows you to modify the text in a message.
1049type EditMessageTextConfig struct {
1050	BaseEdit
1051	Text                  string
1052	ParseMode             string
1053	Entities              []MessageEntity
1054	DisableWebPagePreview bool
1055}
1056
1057func (config EditMessageTextConfig) params() (Params, error) {
1058	params, err := config.BaseEdit.params()
1059	if err != nil {
1060		return params, err
1061	}
1062
1063	params["text"] = config.Text
1064	params.AddNonEmpty("parse_mode", config.ParseMode)
1065	params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
1066	err = params.AddInterface("entities", config.Entities)
1067
1068	return params, err
1069}
1070
1071func (config EditMessageTextConfig) method() string {
1072	return "editMessageText"
1073}
1074
1075// EditMessageCaptionConfig allows you to modify the caption of a message.
1076type EditMessageCaptionConfig struct {
1077	BaseEdit
1078	Caption         string
1079	ParseMode       string
1080	CaptionEntities []MessageEntity
1081}
1082
1083func (config EditMessageCaptionConfig) params() (Params, error) {
1084	params, err := config.BaseEdit.params()
1085	if err != nil {
1086		return params, err
1087	}
1088
1089	params["caption"] = config.Caption
1090	params.AddNonEmpty("parse_mode", config.ParseMode)
1091	err = params.AddInterface("caption_entities", config.CaptionEntities)
1092
1093	return params, err
1094}
1095
1096func (config EditMessageCaptionConfig) method() string {
1097	return "editMessageCaption"
1098}
1099
1100// EditMessageMediaConfig allows you to make an editMessageMedia request.
1101type EditMessageMediaConfig struct {
1102	BaseEdit
1103
1104	Media interface{}
1105}
1106
1107func (EditMessageMediaConfig) method() string {
1108	return "editMessageMedia"
1109}
1110
1111func (config EditMessageMediaConfig) params() (Params, error) {
1112	params, err := config.BaseEdit.params()
1113	if err != nil {
1114		return params, err
1115	}
1116
1117	err = params.AddInterface("media", prepareInputMediaParam(config.Media, 0))
1118
1119	return params, err
1120}
1121
1122func (config EditMessageMediaConfig) files() []RequestFile {
1123	return prepareInputMediaFile(config.Media, 0)
1124}
1125
1126// EditMessageReplyMarkupConfig allows you to modify the reply markup
1127// of a message.
1128type EditMessageReplyMarkupConfig struct {
1129	BaseEdit
1130}
1131
1132func (config EditMessageReplyMarkupConfig) params() (Params, error) {
1133	return config.BaseEdit.params()
1134}
1135
1136func (config EditMessageReplyMarkupConfig) method() string {
1137	return "editMessageReplyMarkup"
1138}
1139
1140// StopPollConfig allows you to stop a poll sent by the bot.
1141type StopPollConfig struct {
1142	BaseEdit
1143}
1144
1145func (config StopPollConfig) params() (Params, error) {
1146	return config.BaseEdit.params()
1147}
1148
1149func (StopPollConfig) method() string {
1150	return "stopPoll"
1151}
1152
1153// UserProfilePhotosConfig contains information about a
1154// GetUserProfilePhotos request.
1155type UserProfilePhotosConfig struct {
1156	UserID int64
1157	Offset int
1158	Limit  int
1159}
1160
1161func (UserProfilePhotosConfig) method() string {
1162	return "getUserProfilePhotos"
1163}
1164
1165func (config UserProfilePhotosConfig) params() (Params, error) {
1166	params := make(Params)
1167
1168	params.AddNonZero64("user_id", config.UserID)
1169	params.AddNonZero("offset", config.Offset)
1170	params.AddNonZero("limit", config.Limit)
1171
1172	return params, nil
1173}
1174
1175// FileConfig has information about a file hosted on Telegram.
1176type FileConfig struct {
1177	FileID string
1178}
1179
1180func (FileConfig) method() string {
1181	return "getFile"
1182}
1183
1184func (config FileConfig) params() (Params, error) {
1185	params := make(Params)
1186
1187	params["file_id"] = config.FileID
1188
1189	return params, nil
1190}
1191
1192// UpdateConfig contains information about a GetUpdates request.
1193type UpdateConfig struct {
1194	Offset         int
1195	Limit          int
1196	Timeout        int
1197	AllowedUpdates []string
1198}
1199
1200func (UpdateConfig) method() string {
1201	return "getUpdates"
1202}
1203
1204func (config UpdateConfig) params() (Params, error) {
1205	params := make(Params)
1206
1207	params.AddNonZero("offset", config.Offset)
1208	params.AddNonZero("limit", config.Limit)
1209	params.AddNonZero("timeout", config.Timeout)
1210	params.AddInterface("allowed_updates", config.AllowedUpdates)
1211
1212	return params, nil
1213}
1214
1215// WebhookConfig contains information about a SetWebhook request.
1216type WebhookConfig struct {
1217	URL                *url.URL
1218	Certificate        RequestFileData
1219	IPAddress          string
1220	MaxConnections     int
1221	AllowedUpdates     []string
1222	DropPendingUpdates bool
1223	SecretToken        string
1224}
1225
1226func (config WebhookConfig) method() string {
1227	return "setWebhook"
1228}
1229
1230func (config WebhookConfig) params() (Params, error) {
1231	params := make(Params)
1232
1233	if config.URL != nil {
1234		params["url"] = config.URL.String()
1235	}
1236
1237	params.AddNonEmpty("ip_address", config.IPAddress)
1238	params.AddNonZero("max_connections", config.MaxConnections)
1239	err := params.AddInterface("allowed_updates", config.AllowedUpdates)
1240	params.AddBool("drop_pending_updates", config.DropPendingUpdates)
1241	params.AddNonEmpty("secret_token", config.SecretToken)
1242
1243	return params, err
1244}
1245
1246func (config WebhookConfig) files() []RequestFile {
1247	if config.Certificate != nil {
1248		return []RequestFile{{
1249			Name: "certificate",
1250			Data: config.Certificate,
1251		}}
1252	}
1253
1254	return nil
1255}
1256
1257// DeleteWebhookConfig is a helper to delete a webhook.
1258type DeleteWebhookConfig struct {
1259	DropPendingUpdates bool
1260}
1261
1262func (config DeleteWebhookConfig) method() string {
1263	return "deleteWebhook"
1264}
1265
1266func (config DeleteWebhookConfig) params() (Params, error) {
1267	params := make(Params)
1268
1269	params.AddBool("drop_pending_updates", config.DropPendingUpdates)
1270
1271	return params, nil
1272}
1273
1274// InlineConfig contains information on making an InlineQuery response.
1275type InlineConfig struct {
1276	InlineQueryID     string        `json:"inline_query_id"`
1277	Results           []interface{} `json:"results"`
1278	CacheTime         int           `json:"cache_time"`
1279	IsPersonal        bool          `json:"is_personal"`
1280	NextOffset        string        `json:"next_offset"`
1281	SwitchPMText      string        `json:"switch_pm_text"`
1282	SwitchPMParameter string        `json:"switch_pm_parameter"`
1283}
1284
1285func (config InlineConfig) method() string {
1286	return "answerInlineQuery"
1287}
1288
1289func (config InlineConfig) params() (Params, error) {
1290	params := make(Params)
1291
1292	params["inline_query_id"] = config.InlineQueryID
1293	params.AddNonZero("cache_time", config.CacheTime)
1294	params.AddBool("is_personal", config.IsPersonal)
1295	params.AddNonEmpty("next_offset", config.NextOffset)
1296	params.AddNonEmpty("switch_pm_text", config.SwitchPMText)
1297	params.AddNonEmpty("switch_pm_parameter", config.SwitchPMParameter)
1298	err := params.AddInterface("results", config.Results)
1299
1300	return params, err
1301}
1302
1303// AnswerWebAppQueryConfig is used to set the result of an interaction with a
1304// Web App and send a corresponding message on behalf of the user to the chat
1305// from which the query originated.
1306type AnswerWebAppQueryConfig struct {
1307	// WebAppQueryID is the unique identifier for the query to be answered.
1308	WebAppQueryID string `json:"web_app_query_id"`
1309	// Result is an InlineQueryResult object describing the message to be sent.
1310	Result interface{} `json:"result"`
1311}
1312
1313func (config AnswerWebAppQueryConfig) method() string {
1314	return "answerWebAppQuery"
1315}
1316
1317func (config AnswerWebAppQueryConfig) params() (Params, error) {
1318	params := make(Params)
1319
1320	params["web_app_query_id"] = config.WebAppQueryID
1321	err := params.AddInterface("result", config.Result)
1322
1323	return params, err
1324}
1325
1326// CallbackConfig contains information on making a CallbackQuery response.
1327type CallbackConfig struct {
1328	CallbackQueryID string `json:"callback_query_id"`
1329	Text            string `json:"text"`
1330	ShowAlert       bool   `json:"show_alert"`
1331	URL             string `json:"url"`
1332	CacheTime       int    `json:"cache_time"`
1333}
1334
1335func (config CallbackConfig) method() string {
1336	return "answerCallbackQuery"
1337}
1338
1339func (config CallbackConfig) params() (Params, error) {
1340	params := make(Params)
1341
1342	params["callback_query_id"] = config.CallbackQueryID
1343	params.AddNonEmpty("text", config.Text)
1344	params.AddBool("show_alert", config.ShowAlert)
1345	params.AddNonEmpty("url", config.URL)
1346	params.AddNonZero("cache_time", config.CacheTime)
1347
1348	return params, nil
1349}
1350
1351// ChatMemberConfig contains information about a user in a chat for use
1352// with administrative functions such as kicking or unbanning a user.
1353type ChatMemberConfig struct {
1354	ChatID             int64
1355	SuperGroupUsername string
1356	ChannelUsername    string
1357	UserID             int64
1358}
1359
1360// UnbanChatMemberConfig allows you to unban a user.
1361type UnbanChatMemberConfig struct {
1362	ChatMemberConfig
1363	OnlyIfBanned bool
1364}
1365
1366func (config UnbanChatMemberConfig) method() string {
1367	return "unbanChatMember"
1368}
1369
1370func (config UnbanChatMemberConfig) params() (Params, error) {
1371	params := make(Params)
1372
1373	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1374	params.AddNonZero64("user_id", config.UserID)
1375	params.AddBool("only_if_banned", config.OnlyIfBanned)
1376
1377	return params, nil
1378}
1379
1380// BanChatMemberConfig contains extra fields to kick user.
1381type BanChatMemberConfig struct {
1382	ChatMemberConfig
1383	UntilDate      int64
1384	RevokeMessages bool
1385}
1386
1387func (config BanChatMemberConfig) method() string {
1388	return "banChatMember"
1389}
1390
1391func (config BanChatMemberConfig) params() (Params, error) {
1392	params := make(Params)
1393
1394	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1395	params.AddNonZero64("user_id", config.UserID)
1396	params.AddNonZero64("until_date", config.UntilDate)
1397	params.AddBool("revoke_messages", config.RevokeMessages)
1398
1399	return params, nil
1400}
1401
1402// KickChatMemberConfig contains extra fields to ban user.
1403//
1404// This was renamed to BanChatMember in later versions of the Telegram Bot API.
1405type KickChatMemberConfig = BanChatMemberConfig
1406
1407// RestrictChatMemberConfig contains fields to restrict members of chat
1408type RestrictChatMemberConfig struct {
1409	ChatMemberConfig
1410	UntilDate                     int64
1411	UseIndependentChatPermissions bool
1412	Permissions                   *ChatPermissions
1413}
1414
1415func (config RestrictChatMemberConfig) method() string {
1416	return "restrictChatMember"
1417}
1418
1419func (config RestrictChatMemberConfig) params() (Params, error) {
1420	params := make(Params)
1421
1422	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1423	params.AddNonZero64("user_id", config.UserID)
1424	params.AddBool("use_independent_chat_permissions", config.UseIndependentChatPermissions)
1425
1426	err := params.AddInterface("permissions", config.Permissions)
1427	params.AddNonZero64("until_date", config.UntilDate)
1428
1429	return params, err
1430}
1431
1432// PromoteChatMemberConfig contains fields to promote members of chat
1433type PromoteChatMemberConfig struct {
1434	ChatMemberConfig
1435	IsAnonymous         bool
1436	CanManageChat       bool
1437	CanChangeInfo       bool
1438	CanPostMessages     bool
1439	CanEditMessages     bool
1440	CanDeleteMessages   bool
1441	CanManageVideoChats bool
1442	CanInviteUsers      bool
1443	CanRestrictMembers  bool
1444	CanPinMessages      bool
1445	CanPromoteMembers   bool
1446	CanManageTopics     bool
1447}
1448
1449func (config PromoteChatMemberConfig) method() string {
1450	return "promoteChatMember"
1451}
1452
1453func (config PromoteChatMemberConfig) params() (Params, error) {
1454	params := make(Params)
1455
1456	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1457	params.AddNonZero64("user_id", config.UserID)
1458
1459	params.AddBool("is_anonymous", config.IsAnonymous)
1460	params.AddBool("can_manage_chat", config.CanManageChat)
1461	params.AddBool("can_change_info", config.CanChangeInfo)
1462	params.AddBool("can_post_messages", config.CanPostMessages)
1463	params.AddBool("can_edit_messages", config.CanEditMessages)
1464	params.AddBool("can_delete_messages", config.CanDeleteMessages)
1465	params.AddBool("can_manage_video_chats", config.CanManageVideoChats)
1466	params.AddBool("can_invite_users", config.CanInviteUsers)
1467	params.AddBool("can_restrict_members", config.CanRestrictMembers)
1468	params.AddBool("can_pin_messages", config.CanPinMessages)
1469	params.AddBool("can_promote_members", config.CanPromoteMembers)
1470	params.AddBool("can_manage_topics", config.CanManageTopics)
1471
1472	return params, nil
1473}
1474
1475// SetChatAdministratorCustomTitle sets the title of an administrative user
1476// promoted by the bot for a chat.
1477type SetChatAdministratorCustomTitle struct {
1478	ChatMemberConfig
1479	CustomTitle string
1480}
1481
1482func (SetChatAdministratorCustomTitle) method() string {
1483	return "setChatAdministratorCustomTitle"
1484}
1485
1486func (config SetChatAdministratorCustomTitle) params() (Params, error) {
1487	params := make(Params)
1488
1489	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1490	params.AddNonZero64("user_id", config.UserID)
1491	params.AddNonEmpty("custom_title", config.CustomTitle)
1492
1493	return params, nil
1494}
1495
1496// BanChatSenderChatConfig bans a channel chat in a supergroup or a channel. The
1497// owner of the chat will not be able to send messages and join live streams on
1498// behalf of the chat, unless it is unbanned first. The bot must be an
1499// administrator in the supergroup or channel for this to work and must have the
1500// appropriate administrator rights.
1501type BanChatSenderChatConfig struct {
1502	ChatID          int64
1503	ChannelUsername string
1504	SenderChatID    int64
1505	UntilDate       int
1506}
1507
1508func (config BanChatSenderChatConfig) method() string {
1509	return "banChatSenderChat"
1510}
1511
1512func (config BanChatSenderChatConfig) params() (Params, error) {
1513	params := make(Params)
1514
1515	_ = params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1516	params.AddNonZero64("sender_chat_id", config.SenderChatID)
1517	params.AddNonZero("until_date", config.UntilDate)
1518
1519	return params, nil
1520}
1521
1522// UnbanChatSenderChatConfig unbans a previously banned channel chat in a
1523// supergroup or channel. The bot must be an administrator for this to work and
1524// must have the appropriate administrator rights.
1525type UnbanChatSenderChatConfig struct {
1526	ChatID          int64
1527	ChannelUsername string
1528	SenderChatID    int64
1529}
1530
1531func (config UnbanChatSenderChatConfig) method() string {
1532	return "unbanChatSenderChat"
1533}
1534
1535func (config UnbanChatSenderChatConfig) params() (Params, error) {
1536	params := make(Params)
1537
1538	_ = params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1539	params.AddNonZero64("sender_chat_id", config.SenderChatID)
1540
1541	return params, nil
1542}
1543
1544// ChatConfig contains information about getting information on a chat.
1545type ChatConfig struct {
1546	ChatID             int64
1547	SuperGroupUsername string
1548}
1549
1550func (config ChatConfig) params() (Params, error) {
1551	params := make(Params)
1552
1553	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1554
1555	return params, nil
1556}
1557
1558// ChatInfoConfig contains information about getting chat information.
1559type ChatInfoConfig struct {
1560	ChatConfig
1561}
1562
1563func (ChatInfoConfig) method() string {
1564	return "getChat"
1565}
1566
1567// ChatMemberCountConfig contains information about getting the number of users in a chat.
1568type ChatMemberCountConfig struct {
1569	ChatConfig
1570}
1571
1572func (ChatMemberCountConfig) method() string {
1573	return "getChatMembersCount"
1574}
1575
1576// ChatAdministratorsConfig contains information about getting chat administrators.
1577type ChatAdministratorsConfig struct {
1578	ChatConfig
1579}
1580
1581func (ChatAdministratorsConfig) method() string {
1582	return "getChatAdministrators"
1583}
1584
1585// SetChatPermissionsConfig allows you to set default permissions for the
1586// members in a group. The bot must be an administrator and have rights to
1587// restrict members.
1588type SetChatPermissionsConfig struct {
1589	ChatConfig
1590	UseIndependentChatPermissions bool
1591	Permissions                   *ChatPermissions
1592}
1593
1594func (SetChatPermissionsConfig) method() string {
1595	return "setChatPermissions"
1596}
1597
1598func (config SetChatPermissionsConfig) params() (Params, error) {
1599	params := make(Params)
1600
1601	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1602	params.AddBool("use_independent_chat_permissions", config.UseIndependentChatPermissions)
1603	err := params.AddInterface("permissions", config.Permissions)
1604
1605	return params, err
1606}
1607
1608// ChatInviteLinkConfig contains information about getting a chat link.
1609//
1610// Note that generating a new link will revoke any previous links.
1611type ChatInviteLinkConfig struct {
1612	ChatConfig
1613}
1614
1615func (ChatInviteLinkConfig) method() string {
1616	return "exportChatInviteLink"
1617}
1618
1619func (config ChatInviteLinkConfig) params() (Params, error) {
1620	params := make(Params)
1621
1622	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1623
1624	return params, nil
1625}
1626
1627// CreateChatInviteLinkConfig allows you to create an additional invite link for
1628// a chat. The bot must be an administrator in the chat for this to work and
1629// must have the appropriate admin rights. The link can be revoked using the
1630// RevokeChatInviteLinkConfig.
1631type CreateChatInviteLinkConfig struct {
1632	ChatConfig
1633	Name               string
1634	ExpireDate         int
1635	MemberLimit        int
1636	CreatesJoinRequest bool
1637}
1638
1639func (CreateChatInviteLinkConfig) method() string {
1640	return "createChatInviteLink"
1641}
1642
1643func (config CreateChatInviteLinkConfig) params() (Params, error) {
1644	params := make(Params)
1645
1646	params.AddNonEmpty("name", config.Name)
1647	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1648	params.AddNonZero("expire_date", config.ExpireDate)
1649	params.AddNonZero("member_limit", config.MemberLimit)
1650	params.AddBool("creates_join_request", config.CreatesJoinRequest)
1651
1652	return params, nil
1653}
1654
1655// EditChatInviteLinkConfig allows you to edit a non-primary invite link created
1656// by the bot. The bot must be an administrator in the chat for this to work and
1657// must have the appropriate admin rights.
1658type EditChatInviteLinkConfig struct {
1659	ChatConfig
1660	InviteLink         string
1661	Name               string
1662	ExpireDate         int
1663	MemberLimit        int
1664	CreatesJoinRequest bool
1665}
1666
1667func (EditChatInviteLinkConfig) method() string {
1668	return "editChatInviteLink"
1669}
1670
1671func (config EditChatInviteLinkConfig) params() (Params, error) {
1672	params := make(Params)
1673
1674	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1675	params.AddNonEmpty("name", config.Name)
1676	params["invite_link"] = config.InviteLink
1677	params.AddNonZero("expire_date", config.ExpireDate)
1678	params.AddNonZero("member_limit", config.MemberLimit)
1679	params.AddBool("creates_join_request", config.CreatesJoinRequest)
1680
1681	return params, nil
1682}
1683
1684// RevokeChatInviteLinkConfig allows you to revoke an invite link created by the
1685// bot. If the primary link is revoked, a new link is automatically generated.
1686// The bot must be an administrator in the chat for this to work and must have
1687// the appropriate admin rights.
1688type RevokeChatInviteLinkConfig struct {
1689	ChatConfig
1690	InviteLink string
1691}
1692
1693func (RevokeChatInviteLinkConfig) method() string {
1694	return "revokeChatInviteLink"
1695}
1696
1697func (config RevokeChatInviteLinkConfig) params() (Params, error) {
1698	params := make(Params)
1699
1700	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1701	params["invite_link"] = config.InviteLink
1702
1703	return params, nil
1704}
1705
1706// ApproveChatJoinRequestConfig allows you to approve a chat join request.
1707type ApproveChatJoinRequestConfig struct {
1708	ChatConfig
1709	UserID int64
1710}
1711
1712func (ApproveChatJoinRequestConfig) method() string {
1713	return "approveChatJoinRequest"
1714}
1715
1716func (config ApproveChatJoinRequestConfig) params() (Params, error) {
1717	params := make(Params)
1718
1719	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1720	params.AddNonZero("user_id", int(config.UserID))
1721
1722	return params, nil
1723}
1724
1725// DeclineChatJoinRequest allows you to decline a chat join request.
1726type DeclineChatJoinRequest struct {
1727	ChatConfig
1728	UserID int64
1729}
1730
1731func (DeclineChatJoinRequest) method() string {
1732	return "declineChatJoinRequest"
1733}
1734
1735func (config DeclineChatJoinRequest) params() (Params, error) {
1736	params := make(Params)
1737
1738	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1739	params.AddNonZero("user_id", int(config.UserID))
1740
1741	return params, nil
1742}
1743
1744// LeaveChatConfig allows you to leave a chat.
1745type LeaveChatConfig struct {
1746	ChatID          int64
1747	ChannelUsername string
1748}
1749
1750func (config LeaveChatConfig) method() string {
1751	return "leaveChat"
1752}
1753
1754func (config LeaveChatConfig) params() (Params, error) {
1755	params := make(Params)
1756
1757	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1758
1759	return params, nil
1760}
1761
1762// ChatConfigWithUser contains information about a chat and a user.
1763type ChatConfigWithUser struct {
1764	ChatID             int64
1765	SuperGroupUsername string
1766	UserID             int64
1767}
1768
1769func (config ChatConfigWithUser) params() (Params, error) {
1770	params := make(Params)
1771
1772	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1773	params.AddNonZero64("user_id", config.UserID)
1774
1775	return params, nil
1776}
1777
1778// GetChatMemberConfig is information about getting a specific member in a chat.
1779type GetChatMemberConfig struct {
1780	ChatConfigWithUser
1781}
1782
1783func (GetChatMemberConfig) method() string {
1784	return "getChatMember"
1785}
1786
1787// InvoiceConfig contains information for sendInvoice request.
1788type InvoiceConfig struct {
1789	BaseChat
1790	Title                     string         // required
1791	Description               string         // required
1792	Payload                   string         // required
1793	ProviderToken             string         // required
1794	Currency                  string         // required
1795	Prices                    []LabeledPrice // required
1796	MaxTipAmount              int
1797	SuggestedTipAmounts       []int
1798	StartParameter            string
1799	ProviderData              string
1800	PhotoURL                  string
1801	PhotoSize                 int
1802	PhotoWidth                int
1803	PhotoHeight               int
1804	NeedName                  bool
1805	NeedPhoneNumber           bool
1806	NeedEmail                 bool
1807	NeedShippingAddress       bool
1808	SendPhoneNumberToProvider bool
1809	SendEmailToProvider       bool
1810	IsFlexible                bool
1811}
1812
1813func (config InvoiceConfig) params() (Params, error) {
1814	params, err := config.BaseChat.params()
1815	if err != nil {
1816		return params, err
1817	}
1818
1819	params["title"] = config.Title
1820	params["description"] = config.Description
1821	params["payload"] = config.Payload
1822	params["provider_token"] = config.ProviderToken
1823	params["currency"] = config.Currency
1824	if err = params.AddInterface("prices", config.Prices); err != nil {
1825		return params, err
1826	}
1827
1828	params.AddNonZero("max_tip_amount", config.MaxTipAmount)
1829	err = params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
1830	params.AddNonEmpty("start_parameter", config.StartParameter)
1831	params.AddNonEmpty("provider_data", config.ProviderData)
1832	params.AddNonEmpty("photo_url", config.PhotoURL)
1833	params.AddNonZero("photo_size", config.PhotoSize)
1834	params.AddNonZero("photo_width", config.PhotoWidth)
1835	params.AddNonZero("photo_height", config.PhotoHeight)
1836	params.AddBool("need_name", config.NeedName)
1837	params.AddBool("need_phone_number", config.NeedPhoneNumber)
1838	params.AddBool("need_email", config.NeedEmail)
1839	params.AddBool("need_shipping_address", config.NeedShippingAddress)
1840	params.AddBool("is_flexible", config.IsFlexible)
1841	params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider)
1842	params.AddBool("send_email_to_provider", config.SendEmailToProvider)
1843
1844	return params, err
1845}
1846
1847func (config InvoiceConfig) method() string {
1848	return "sendInvoice"
1849}
1850
1851// InvoiceLinkConfig contains information for createInvoiceLink method
1852type InvoiceLinkConfig struct {
1853	Title                     string         //Required
1854	Description               string         //Required
1855	Payload                   string         //Required
1856	ProviderToken             string         //Required
1857	Currency                  string         //Required
1858	Prices                    []LabeledPrice //Required
1859	MaxTipAmount              int
1860	SuggestedTipAmounts       []int
1861	ProviderData              string
1862	PhotoURL                  string
1863	PhotoSize                 int
1864	PhotoWidth                int
1865	PhotoHeight               int
1866	NeedName                  bool
1867	NeedPhoneNumber           bool
1868	NeedEmail                 bool
1869	NeedShippingAddress       bool
1870	SendPhoneNumberToProvider bool
1871	SendEmailToProvider       bool
1872	IsFlexible                bool
1873}
1874
1875func (config InvoiceLinkConfig) params() (Params, error) {
1876	params := make(Params)
1877
1878	params["title"] = config.Title
1879	params["description"] = config.Description
1880	params["payload"] = config.Payload
1881	params["provider_token"] = config.ProviderToken
1882	params["currency"] = config.Currency
1883	if err := params.AddInterface("prices", config.Prices); err != nil {
1884		return params, err
1885	}
1886
1887	params.AddNonZero("max_tip_amount", config.MaxTipAmount)
1888	err := params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
1889	params.AddNonEmpty("provider_data", config.ProviderData)
1890	params.AddNonEmpty("photo_url", config.PhotoURL)
1891	params.AddNonZero("photo_size", config.PhotoSize)
1892	params.AddNonZero("photo_width", config.PhotoWidth)
1893	params.AddNonZero("photo_height", config.PhotoHeight)
1894	params.AddBool("need_name", config.NeedName)
1895	params.AddBool("need_phone_number", config.NeedPhoneNumber)
1896	params.AddBool("need_email", config.NeedEmail)
1897	params.AddBool("need_shipping_address", config.NeedShippingAddress)
1898	params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider)
1899	params.AddBool("send_email_to_provider", config.SendEmailToProvider)
1900	params.AddBool("is_flexible", config.IsFlexible)
1901
1902	return params, err
1903}
1904
1905func (config InvoiceLinkConfig) method() string {
1906	return "createInvoiceLink"
1907}
1908
1909// ShippingConfig contains information for answerShippingQuery request.
1910type ShippingConfig struct {
1911	ShippingQueryID string // required
1912	OK              bool   // required
1913	ShippingOptions []ShippingOption
1914	ErrorMessage    string
1915}
1916
1917func (config ShippingConfig) method() string {
1918	return "answerShippingQuery"
1919}
1920
1921func (config ShippingConfig) params() (Params, error) {
1922	params := make(Params)
1923
1924	params["shipping_query_id"] = config.ShippingQueryID
1925	params.AddBool("ok", config.OK)
1926	err := params.AddInterface("shipping_options", config.ShippingOptions)
1927	params.AddNonEmpty("error_message", config.ErrorMessage)
1928
1929	return params, err
1930}
1931
1932// PreCheckoutConfig contains information for answerPreCheckoutQuery request.
1933type PreCheckoutConfig struct {
1934	PreCheckoutQueryID string // required
1935	OK                 bool   // required
1936	ErrorMessage       string
1937}
1938
1939func (config PreCheckoutConfig) method() string {
1940	return "answerPreCheckoutQuery"
1941}
1942
1943func (config PreCheckoutConfig) params() (Params, error) {
1944	params := make(Params)
1945
1946	params["pre_checkout_query_id"] = config.PreCheckoutQueryID
1947	params.AddBool("ok", config.OK)
1948	params.AddNonEmpty("error_message", config.ErrorMessage)
1949
1950	return params, nil
1951}
1952
1953// DeleteMessageConfig contains information of a message in a chat to delete.
1954type DeleteMessageConfig struct {
1955	ChannelUsername string
1956	ChatID          int64
1957	MessageID       int
1958}
1959
1960func (config DeleteMessageConfig) method() string {
1961	return "deleteMessage"
1962}
1963
1964func (config DeleteMessageConfig) params() (Params, error) {
1965	params := make(Params)
1966
1967	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1968	params.AddNonZero("message_id", config.MessageID)
1969
1970	return params, nil
1971}
1972
1973// PinChatMessageConfig contains information of a message in a chat to pin.
1974type PinChatMessageConfig struct {
1975	ChatID              int64
1976	ChannelUsername     string
1977	MessageID           int
1978	DisableNotification bool
1979}
1980
1981func (config PinChatMessageConfig) method() string {
1982	return "pinChatMessage"
1983}
1984
1985func (config PinChatMessageConfig) params() (Params, error) {
1986	params := make(Params)
1987
1988	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1989	params.AddNonZero("message_id", config.MessageID)
1990	params.AddBool("disable_notification", config.DisableNotification)
1991
1992	return params, nil
1993}
1994
1995// UnpinChatMessageConfig contains information of a chat message to unpin.
1996//
1997// If MessageID is not specified, it will unpin the most recent pin.
1998type UnpinChatMessageConfig struct {
1999	ChatID          int64
2000	ChannelUsername string
2001	MessageID       int
2002}
2003
2004func (config UnpinChatMessageConfig) method() string {
2005	return "unpinChatMessage"
2006}
2007
2008func (config UnpinChatMessageConfig) params() (Params, error) {
2009	params := make(Params)
2010
2011	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2012	params.AddNonZero("message_id", config.MessageID)
2013
2014	return params, nil
2015}
2016
2017// UnpinAllChatMessagesConfig contains information of all messages to unpin in
2018// a chat.
2019type UnpinAllChatMessagesConfig struct {
2020	ChatID          int64
2021	ChannelUsername string
2022}
2023
2024func (config UnpinAllChatMessagesConfig) method() string {
2025	return "unpinAllChatMessages"
2026}
2027
2028func (config UnpinAllChatMessagesConfig) params() (Params, error) {
2029	params := make(Params)
2030
2031	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2032
2033	return params, nil
2034}
2035
2036// SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
2037type SetChatPhotoConfig struct {
2038	BaseFile
2039}
2040
2041func (config SetChatPhotoConfig) method() string {
2042	return "setChatPhoto"
2043}
2044
2045func (config SetChatPhotoConfig) files() []RequestFile {
2046	return []RequestFile{{
2047		Name: "photo",
2048		Data: config.File,
2049	}}
2050}
2051
2052// DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
2053type DeleteChatPhotoConfig struct {
2054	ChatID          int64
2055	ChannelUsername string
2056}
2057
2058func (config DeleteChatPhotoConfig) method() string {
2059	return "deleteChatPhoto"
2060}
2061
2062func (config DeleteChatPhotoConfig) params() (Params, error) {
2063	params := make(Params)
2064
2065	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2066
2067	return params, nil
2068}
2069
2070// SetChatTitleConfig allows you to set the title of something other than a private chat.
2071type SetChatTitleConfig struct {
2072	ChatID          int64
2073	ChannelUsername string
2074
2075	Title string
2076}
2077
2078func (config SetChatTitleConfig) method() string {
2079	return "setChatTitle"
2080}
2081
2082func (config SetChatTitleConfig) params() (Params, error) {
2083	params := make(Params)
2084
2085	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2086	params["title"] = config.Title
2087
2088	return params, nil
2089}
2090
2091// SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
2092type SetChatDescriptionConfig struct {
2093	ChatID          int64
2094	ChannelUsername string
2095
2096	Description string
2097}
2098
2099func (config SetChatDescriptionConfig) method() string {
2100	return "setChatDescription"
2101}
2102
2103func (config SetChatDescriptionConfig) params() (Params, error) {
2104	params := make(Params)
2105
2106	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2107	params["description"] = config.Description
2108
2109	return params, nil
2110}
2111
2112// GetStickerSetConfig allows you to get the stickers in a set.
2113type GetStickerSetConfig struct {
2114	Name string
2115}
2116
2117func (config GetStickerSetConfig) method() string {
2118	return "getStickerSet"
2119}
2120
2121func (config GetStickerSetConfig) params() (Params, error) {
2122	params := make(Params)
2123
2124	params["name"] = config.Name
2125
2126	return params, nil
2127}
2128
2129// GetCustomEmojiStickersConfig get information about
2130// custom emoji stickers by their identifiers.
2131type GetCustomEmojiStickersConfig struct {
2132	CustomEmojiIDs []string
2133}
2134
2135func (config GetCustomEmojiStickersConfig) params() (Params, error) {
2136	params := make(Params)
2137
2138	params.AddInterface("custom_emoji_ids", config.CustomEmojiIDs)
2139
2140	return params, nil
2141}
2142
2143func (config GetCustomEmojiStickersConfig) method() string {
2144	return "getCustomEmojiStickers"
2145}
2146
2147// UploadStickerConfig allows you to upload a sticker for use in a set later.
2148type UploadStickerConfig struct {
2149	UserID        int64
2150	Sticker       RequestFile
2151	StickerFormat string
2152}
2153
2154func (config UploadStickerConfig) method() string {
2155	return "uploadStickerFile"
2156}
2157
2158func (config UploadStickerConfig) params() (Params, error) {
2159	params := make(Params)
2160
2161	params.AddNonZero64("user_id", config.UserID)
2162	params["sticker_format"] = config.StickerFormat
2163
2164	return params, nil
2165}
2166
2167func (config UploadStickerConfig) files() []RequestFile {
2168	return []RequestFile{config.Sticker}
2169}
2170
2171// NewStickerSetConfig allows creating a new sticker set.
2172type NewStickerSetConfig struct {
2173	UserID          int64
2174	Name            string
2175	Title           string
2176	Stickers        []InputSticker
2177	StickerFormat   string
2178	StickerType     string
2179	NeedsRepainting bool //optional; Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only
2180}
2181
2182func (config NewStickerSetConfig) method() string {
2183	return "createNewStickerSet"
2184}
2185
2186func (config NewStickerSetConfig) params() (Params, error) {
2187	params := make(Params)
2188
2189	params.AddNonZero64("user_id", config.UserID)
2190	params["name"] = config.Name
2191	params["title"] = config.Title
2192	params["sticker_format"] = config.StickerFormat
2193
2194	params.AddBool("needs_repainting", config.NeedsRepainting)
2195	params.AddNonEmpty("sticker_type", string(config.StickerType))
2196	err := params.AddInterface("stickers", config.Stickers)
2197
2198	return params, err
2199}
2200
2201func (config NewStickerSetConfig) files() []RequestFile {
2202	requestFiles := []RequestFile{}
2203	for _, v := range config.Stickers {
2204		requestFiles = append(requestFiles, v.Sticker)
2205	}
2206	return requestFiles
2207}
2208
2209// AddStickerConfig allows you to add a sticker to a set.
2210type AddStickerConfig struct {
2211	UserID  int64
2212	Name    string
2213	Sticker InputSticker
2214}
2215
2216func (config AddStickerConfig) method() string {
2217	return "addStickerToSet"
2218}
2219
2220func (config AddStickerConfig) params() (Params, error) {
2221	params := make(Params)
2222
2223	params.AddNonZero64("user_id", config.UserID)
2224	params["name"] = config.Name
2225	err := params.AddInterface("sticker", config.Sticker)
2226	return params, err
2227}
2228
2229func (config AddStickerConfig) files() []RequestFile {
2230	return []RequestFile{config.Sticker.Sticker}
2231}
2232
2233// SetStickerPositionConfig allows you to change the position of a sticker in a set.
2234type SetStickerPositionConfig struct {
2235	Sticker  string
2236	Position int
2237}
2238
2239func (config SetStickerPositionConfig) method() string {
2240	return "setStickerPositionInSet"
2241}
2242
2243func (config SetStickerPositionConfig) params() (Params, error) {
2244	params := make(Params)
2245
2246	params["sticker"] = config.Sticker
2247	params.AddNonZero("position", config.Position)
2248
2249	return params, nil
2250}
2251
2252// SetCustomEmojiStickerSetThumbnalConfig allows you to set the thumbnail of a custom emoji sticker set
2253type SetCustomEmojiStickerSetThumbnalConfig struct {
2254	Name          string
2255	CustomEmojiID string
2256}
2257
2258func (config SetCustomEmojiStickerSetThumbnalConfig) method() string {
2259	return "setCustomEmojiStickerSetThumbnail"
2260}
2261
2262func (config SetCustomEmojiStickerSetThumbnalConfig) params() (Params, error) {
2263	params := make(Params)
2264
2265	params["name"] = config.Name
2266	params.AddNonEmpty("position", config.CustomEmojiID)
2267
2268	return params, nil
2269}
2270
2271// SetStickerSetTitle allows you to set the title of a created sticker set
2272type SetStickerSetTitleConfig struct {
2273	Name  string
2274	Title string
2275}
2276
2277func (config SetStickerSetTitleConfig) method() string {
2278	return "setStickerSetTitle"
2279}
2280
2281func (config SetStickerSetTitleConfig) params() (Params, error) {
2282	params := make(Params)
2283
2284	params["name"] = config.Name
2285	params["title"] = config.Title
2286
2287	return params, nil
2288}
2289
2290// DeleteStickerSetConfig allows you to delete a sticker set that was created by the bot.
2291type DeleteStickerSetConfig struct {
2292	Name string
2293}
2294
2295func (config DeleteStickerSetConfig) method() string {
2296	return "deleteStickerSet"
2297}
2298
2299func (config DeleteStickerSetConfig) params() (Params, error) {
2300	params := make(Params)
2301
2302	params["name"] = config.Name
2303
2304	return params, nil
2305}
2306
2307// DeleteStickerConfig allows you to delete a sticker from a set.
2308type DeleteStickerConfig struct {
2309	Sticker string
2310}
2311
2312func (config DeleteStickerConfig) method() string {
2313	return "deleteStickerFromSet"
2314}
2315
2316func (config DeleteStickerConfig) params() (Params, error) {
2317	params := make(Params)
2318
2319	params["sticker"] = config.Sticker
2320
2321	return params, nil
2322}
2323
2324// SetStickerEmojiListConfig allows you to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot
2325type SetStickerEmojiListConfig struct {
2326	Sticker   string
2327	EmojiList []string
2328}
2329
2330func (config SetStickerEmojiListConfig) method() string {
2331	return "setStickerEmojiList"
2332}
2333
2334func (config SetStickerEmojiListConfig) params() (Params, error) {
2335	params := make(Params)
2336
2337	params["sticker"] = config.Sticker
2338	err := params.AddInterface("emoji_list", config.EmojiList)
2339
2340	return params, err
2341}
2342
2343// SetStickerKeywordsConfig allows you to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot.
2344type SetStickerKeywordsConfig struct {
2345	Sticker  string
2346	Keywords []string
2347}
2348
2349func (config SetStickerKeywordsConfig) method() string {
2350	return "setStickerKeywords"
2351}
2352
2353func (config SetStickerKeywordsConfig) params() (Params, error) {
2354	params := make(Params)
2355
2356	params["sticker"] = config.Sticker
2357	err := params.AddInterface("keywords", config.Keywords)
2358
2359	return params, err
2360}
2361
2362// SetStickerMaskPositionConfig allows you to  change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot
2363type SetStickerMaskPositionConfig struct {
2364	Sticker      string
2365	MaskPosition *MaskPosition
2366}
2367
2368func (config SetStickerMaskPositionConfig) method() string {
2369	return "setStickerMaskPosition"
2370}
2371
2372func (config SetStickerMaskPositionConfig) params() (Params, error) {
2373	params := make(Params)
2374
2375	params["sticker"] = config.Sticker
2376	err := params.AddInterface("keywords", config.MaskPosition)
2377
2378	return params, err
2379}
2380
2381// SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
2382type SetStickerSetThumbConfig struct {
2383	Name   string
2384	UserID int64
2385	Thumb  RequestFileData
2386}
2387
2388func (config SetStickerSetThumbConfig) method() string {
2389	return "setStickerSetThumbnail"
2390}
2391
2392func (config SetStickerSetThumbConfig) params() (Params, error) {
2393	params := make(Params)
2394
2395	params["name"] = config.Name
2396	params.AddNonZero64("user_id", config.UserID)
2397
2398	return params, nil
2399}
2400
2401func (config SetStickerSetThumbConfig) files() []RequestFile {
2402	return []RequestFile{{
2403		Name: "thumbnail",
2404		Data: config.Thumb,
2405	}}
2406}
2407
2408// SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
2409type SetChatStickerSetConfig struct {
2410	ChatID             int64
2411	SuperGroupUsername string
2412
2413	StickerSetName string
2414}
2415
2416func (config SetChatStickerSetConfig) method() string {
2417	return "setChatStickerSet"
2418}
2419
2420func (config SetChatStickerSetConfig) params() (Params, error) {
2421	params := make(Params)
2422
2423	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
2424	params["sticker_set_name"] = config.StickerSetName
2425
2426	return params, nil
2427}
2428
2429// DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
2430type DeleteChatStickerSetConfig struct {
2431	ChatID             int64
2432	SuperGroupUsername string
2433}
2434
2435func (config DeleteChatStickerSetConfig) method() string {
2436	return "deleteChatStickerSet"
2437}
2438
2439func (config DeleteChatStickerSetConfig) params() (Params, error) {
2440	params := make(Params)
2441
2442	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
2443
2444	return params, nil
2445}
2446
2447// GetForumTopicIconStickersConfig allows you to get custom emoji stickers,
2448// which can be used as a forum topic icon by any user.
2449type GetForumTopicIconStickersConfig struct{}
2450
2451func (config GetForumTopicIconStickersConfig) method() string {
2452	return "getForumTopicIconStickers"
2453}
2454
2455func (config GetForumTopicIconStickersConfig) params() (Params, error) {
2456	return nil, nil
2457}
2458
2459// BaseForum is a base type for all forum config types.
2460type BaseForum struct {
2461	ChatID             int64
2462	SuperGroupUsername string
2463}
2464
2465func (config BaseForum) params() (Params, error) {
2466	params := make(Params)
2467
2468	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
2469
2470	return params, nil
2471}
2472
2473// CreateForumTopicConfig allows you to create a topic
2474// in a forum supergroup chat.
2475type CreateForumTopicConfig struct {
2476	BaseForum
2477	Name              string
2478	IconColor         int
2479	IconCustomEmojiID string
2480}
2481
2482func (config CreateForumTopicConfig) method() string {
2483	return "createForumTopic"
2484}
2485
2486func (config CreateForumTopicConfig) params() (Params, error) {
2487	params := make(Params)
2488
2489	params.AddNonEmpty("name", config.Name)
2490	params.AddNonZero("icon_color", config.IconColor)
2491	params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
2492
2493	p1, _ := config.BaseForum.params()
2494	params.Merge(p1)
2495
2496	return params, nil
2497}
2498
2499// EditForumTopicConfig allows you to edit
2500// name and icon of a topic in a forum supergroup chat.
2501type EditForumTopicConfig struct {
2502	BaseForum
2503	MessageThreadID   int
2504	Name              string
2505	IconCustomEmojiID string
2506}
2507
2508func (config EditForumTopicConfig) method() string {
2509	return "editForumTopic"
2510}
2511
2512func (config EditForumTopicConfig) params() (Params, error) {
2513	params := make(Params)
2514
2515	params.AddNonZero("message_thread_id", config.MessageThreadID)
2516	params.AddNonEmpty("name", config.Name)
2517	params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
2518
2519	p1, _ := config.BaseForum.params()
2520	params.Merge(p1)
2521
2522	return params, nil
2523}
2524
2525// CloseForumTopicConfig allows you to close
2526// an open topic in a forum supergroup chat.
2527type CloseForumTopicConfig struct {
2528	BaseForum
2529	MessageThreadID int
2530}
2531
2532func (config CloseForumTopicConfig) method() string {
2533	return "closeForumTopic"
2534}
2535
2536func (config CloseForumTopicConfig) params() (Params, error) {
2537	params := make(Params)
2538
2539	params.AddNonZero("message_thread_id", config.MessageThreadID)
2540
2541	p1, _ := config.BaseForum.params()
2542	params.Merge(p1)
2543
2544	return params, nil
2545}
2546
2547// ReopenForumTopicConfig allows you to reopen
2548// an closed topic in a forum supergroup chat.
2549type ReopenForumTopicConfig struct {
2550	BaseForum
2551	MessageThreadID int
2552}
2553
2554func (config ReopenForumTopicConfig) method() string {
2555	return "reopenForumTopic"
2556}
2557
2558func (config ReopenForumTopicConfig) params() (Params, error) {
2559	params := make(Params)
2560
2561	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
2562	params.AddNonZero("message_thread_id", config.MessageThreadID)
2563
2564	p1, _ := config.BaseForum.params()
2565	params.Merge(p1)
2566
2567	return params, nil
2568}
2569
2570// DeleteForumTopicConfig allows you to delete a forum topic
2571// along with all its messages in a forum supergroup chat.
2572type DeleteForumTopicConfig struct {
2573	BaseForum
2574	MessageThreadID int
2575}
2576
2577func (config DeleteForumTopicConfig) method() string {
2578	return "deleteForumTopic"
2579}
2580
2581func (config DeleteForumTopicConfig) params() (Params, error) {
2582	params := make(Params)
2583
2584	params.AddNonZero("message_thread_id", config.MessageThreadID)
2585
2586	p1, _ := config.BaseForum.params()
2587	params.Merge(p1)
2588
2589	return params, nil
2590}
2591
2592// UnpinAllForumTopicMessagesConfig allows you to clear the list
2593// of pinned messages in a forum topic.
2594type UnpinAllForumTopicMessagesConfig struct {
2595	BaseForum
2596	MessageThreadID int
2597}
2598
2599func (config UnpinAllForumTopicMessagesConfig) method() string {
2600	return "unpinAllForumTopicMessages"
2601}
2602
2603func (config UnpinAllForumTopicMessagesConfig) params() (Params, error) {
2604	params := make(Params)
2605
2606	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
2607	params.AddNonZero("message_thread_id", config.MessageThreadID)
2608
2609	p1, _ := config.BaseForum.params()
2610	params.Merge(p1)
2611
2612	return params, nil
2613}
2614
2615// UnpinAllForumTopicMessagesConfig allows you to edit the name of
2616// the 'General' topic in a forum supergroup chat.
2617// The bot must be an administrator in the chat for this to work
2618// and must have can_manage_topics administrator rights. Returns True on success.
2619type EditGeneralForumTopicConfig struct {
2620	BaseForum
2621	Name string
2622}
2623
2624func (config EditGeneralForumTopicConfig) method() string {
2625	return "editGeneralForumTopic"
2626}
2627
2628func (config EditGeneralForumTopicConfig) params() (Params, error) {
2629	params := make(Params)
2630
2631	params.AddNonEmpty("name", config.Name)
2632
2633	p1, _ := config.BaseForum.params()
2634	params.Merge(p1)
2635
2636	return params, nil
2637}
2638
2639// CloseGeneralForumTopicConfig allows you to to close an open 'General' topic
2640// in a forum supergroup chat. The bot must be an administrator in the chat
2641// for this to work and must have the can_manage_topics administrator rights.
2642// Returns True on success.
2643type CloseGeneralForumTopicConfig struct{ BaseForum }
2644
2645func (config CloseGeneralForumTopicConfig) method() string {
2646	return "closeGeneralForumTopic"
2647}
2648
2649// CloseGeneralForumTopicConfig allows you to reopen a closed 'General' topic
2650// in a forum supergroup chat. The bot must be an administrator in the chat
2651// for this to work and must have the can_manage_topics administrator rights.
2652// The topic will be automatically unhidden if it was hidden.
2653// Returns True on success.
2654type ReopenGeneralForumTopicConfig struct{ BaseForum }
2655
2656func (config ReopenGeneralForumTopicConfig) method() string {
2657	return "reopenGeneralForumTopic"
2658}
2659
2660// HideGeneralForumTopicConfig allows you to hide the 'General' topic
2661// in a forum supergroup chat. The bot must be an administrator in the chat
2662// for this to work and must have the can_manage_topics administrator rights.
2663// The topic will be automatically closed if it was open.
2664// Returns True on success.
2665type HideGeneralForumTopicConfig struct{ BaseForum }
2666
2667func (config HideGeneralForumTopicConfig) method() string {
2668	return "hideGeneralForumTopic"
2669}
2670
2671// UnhideGeneralForumTopicConfig allows you to unhide the 'General' topic
2672// in a forum supergroup chat. The bot must be an administrator in the chat
2673// for this to work and must have the can_manage_topics administrator rights.
2674// Returns True on success.
2675type UnhideGeneralForumTopicConfig struct{ BaseForum }
2676
2677func (config UnhideGeneralForumTopicConfig) method() string {
2678	return "unhideGeneralForumTopic"
2679}
2680
2681// MediaGroupConfig allows you to send a group of media.
2682//
2683// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
2684type MediaGroupConfig struct {
2685	BaseChat
2686	Media []interface{}
2687}
2688
2689func (config MediaGroupConfig) method() string {
2690	return "sendMediaGroup"
2691}
2692
2693func (config MediaGroupConfig) params() (Params, error) {
2694	params, err := config.BaseChat.params()
2695	if err != nil {
2696		return nil, err
2697	}
2698
2699	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2700	params.AddBool("disable_notification", config.DisableNotification)
2701	params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
2702
2703	err = params.AddInterface("media", prepareInputMediaForParams(config.Media))
2704
2705	return params, err
2706}
2707
2708func (config MediaGroupConfig) files() []RequestFile {
2709	return prepareInputMediaForFiles(config.Media)
2710}
2711
2712// DiceConfig contains information about a sendDice request.
2713type DiceConfig struct {
2714	BaseChat
2715	// Emoji on which the dice throw animation is based.
2716	// Currently, must be one of 🎲, 🎯, 🏀, ⚽, 🎳, or 🎰.
2717	// Dice can have values 1-6 for 🎲, 🎯, and 🎳, values 1-5 for 🏀 and ⚽,
2718	// and values 1-64 for 🎰.
2719	// Defaults to “🎲”
2720	Emoji string
2721}
2722
2723func (config DiceConfig) method() string {
2724	return "sendDice"
2725}
2726
2727func (config DiceConfig) params() (Params, error) {
2728	params, err := config.BaseChat.params()
2729	if err != nil {
2730		return params, err
2731	}
2732
2733	params.AddNonEmpty("emoji", config.Emoji)
2734
2735	return params, err
2736}
2737
2738// GetMyCommandsConfig gets a list of the currently registered commands.
2739type GetMyCommandsConfig struct {
2740	Scope        *BotCommandScope
2741	LanguageCode string
2742}
2743
2744func (config GetMyCommandsConfig) method() string {
2745	return "getMyCommands"
2746}
2747
2748func (config GetMyCommandsConfig) params() (Params, error) {
2749	params := make(Params)
2750
2751	err := params.AddInterface("scope", config.Scope)
2752	params.AddNonEmpty("language_code", config.LanguageCode)
2753
2754	return params, err
2755}
2756
2757// SetMyCommandsConfig sets a list of commands the bot understands.
2758type SetMyCommandsConfig struct {
2759	Commands     []BotCommand
2760	Scope        *BotCommandScope
2761	LanguageCode string
2762}
2763
2764func (config SetMyCommandsConfig) method() string {
2765	return "setMyCommands"
2766}
2767
2768func (config SetMyCommandsConfig) params() (Params, error) {
2769	params := make(Params)
2770
2771	if err := params.AddInterface("commands", config.Commands); err != nil {
2772		return params, err
2773	}
2774	err := params.AddInterface("scope", config.Scope)
2775	params.AddNonEmpty("language_code", config.LanguageCode)
2776
2777	return params, err
2778}
2779
2780type DeleteMyCommandsConfig struct {
2781	Scope        *BotCommandScope
2782	LanguageCode string
2783}
2784
2785func (config DeleteMyCommandsConfig) method() string {
2786	return "deleteMyCommands"
2787}
2788
2789func (config DeleteMyCommandsConfig) params() (Params, error) {
2790	params := make(Params)
2791
2792	err := params.AddInterface("scope", config.Scope)
2793	params.AddNonEmpty("language_code", config.LanguageCode)
2794
2795	return params, err
2796}
2797
2798// GetMyDescriptionConfig get the current bot description for the given user language
2799type GetMyDescriptionConfig struct {
2800	LanguageCode string
2801}
2802
2803func (config GetMyDescriptionConfig) method() string {
2804	return "getMyDescription"
2805}
2806
2807func (config GetMyDescriptionConfig) params() (Params, error) {
2808	params := make(Params)
2809
2810	params.AddNonEmpty("language_code", config.LanguageCode)
2811
2812	return params, nil
2813}
2814
2815// SetMyDescroptionConfig sets the bot's description, which is shown in the chat with the bot if the chat is empty
2816type SetMyDescriptionConfig struct {
2817	// Pass an empty string to remove the dedicated description for the given language.
2818	Description string
2819	//If empty, the description will be applied to all users for whose language there is no dedicated description.
2820	LanguageCode string
2821}
2822
2823func (config SetMyDescriptionConfig) method() string {
2824	return "setMyDescription"
2825}
2826
2827func (config SetMyDescriptionConfig) params() (Params, error) {
2828	params := make(Params)
2829
2830	params.AddNonEmpty("description", config.Description)
2831	params.AddNonEmpty("language_code", config.LanguageCode)
2832
2833	return params, nil
2834}
2835
2836// GetMyShortDescriptionConfig get the current bot short description for the given user language
2837type GetMyShortDescriptionConfig struct {
2838	LanguageCode string
2839}
2840
2841func (config GetMyShortDescriptionConfig) method() string {
2842	return "getMyShortDescription"
2843}
2844
2845func (config GetMyShortDescriptionConfig) params() (Params, error) {
2846	params := make(Params)
2847
2848	params.AddNonEmpty("language_code", config.LanguageCode)
2849
2850	return params, nil
2851}
2852
2853// SetMyDescroptionConfig sets the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
2854type SetMyShortDescriptionConfig struct {
2855	// New short description for the bot; 0-120 characters.
2856	//
2857	//Pass an empty string to remove the dedicated short description for the given language.
2858	ShortDescription string
2859	//A two-letter ISO 639-1 language code.
2860	//
2861	//If empty, the short description will be applied to all users for whose language there is no dedicated short description.
2862	LanguageCode string
2863}
2864
2865func (config SetMyShortDescriptionConfig) method() string {
2866	return "setMyDescription"
2867}
2868
2869func (config SetMyShortDescriptionConfig) params() (Params, error) {
2870	params := make(Params)
2871
2872	params.AddNonEmpty("short_description", config.ShortDescription)
2873	params.AddNonEmpty("language_code", config.LanguageCode)
2874
2875	return params, nil
2876}
2877
2878// SetChatMenuButtonConfig changes the bot's menu button in a private chat,
2879// or the default menu button.
2880type SetChatMenuButtonConfig struct {
2881	ChatID          int64
2882	ChannelUsername string
2883
2884	MenuButton *MenuButton
2885}
2886
2887func (config SetChatMenuButtonConfig) method() string {
2888	return "setChatMenuButton"
2889}
2890
2891func (config SetChatMenuButtonConfig) params() (Params, error) {
2892	params := make(Params)
2893
2894	if err := params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername); err != nil {
2895		return params, err
2896	}
2897	err := params.AddInterface("menu_button", config.MenuButton)
2898
2899	return params, err
2900}
2901
2902type GetChatMenuButtonConfig struct {
2903	ChatID          int64
2904	ChannelUsername string
2905}
2906
2907func (config GetChatMenuButtonConfig) method() string {
2908	return "getChatMenuButton"
2909}
2910
2911func (config GetChatMenuButtonConfig) params() (Params, error) {
2912	params := make(Params)
2913
2914	err := params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
2915
2916	return params, err
2917}
2918
2919type SetMyDefaultAdministratorRightsConfig struct {
2920	Rights      ChatAdministratorRights
2921	ForChannels bool
2922}
2923
2924func (config SetMyDefaultAdministratorRightsConfig) method() string {
2925	return "setMyDefaultAdministratorRights"
2926}
2927
2928func (config SetMyDefaultAdministratorRightsConfig) params() (Params, error) {
2929	params := make(Params)
2930
2931	err := params.AddInterface("rights", config.Rights)
2932	params.AddBool("for_channels", config.ForChannels)
2933
2934	return params, err
2935}
2936
2937type GetMyDefaultAdministratorRightsConfig struct {
2938	ForChannels bool
2939}
2940
2941func (config GetMyDefaultAdministratorRightsConfig) method() string {
2942	return "getMyDefaultAdministratorRights"
2943}
2944
2945func (config GetMyDefaultAdministratorRightsConfig) params() (Params, error) {
2946	params := make(Params)
2947
2948	params.AddBool("for_channels", config.ForChannels)
2949
2950	return params, nil
2951}
2952
2953// prepareInputMediaParam evaluates a single InputMedia and determines if it
2954// needs to be modified for a successful upload. If it returns nil, then the
2955// value does not need to be included in the params. Otherwise, it will return
2956// the same type as was originally provided.
2957//
2958// The idx is used to calculate the file field name. If you only have a single
2959// file, 0 may be used. It is formatted into "attach://file-%d" for the primary
2960// media and "attach://file-%d-thumb" for thumbnails.
2961//
2962// It is expected to be used in conjunction with prepareInputMediaFile.
2963func prepareInputMediaParam(inputMedia interface{}, idx int) interface{} {
2964	switch m := inputMedia.(type) {
2965	case InputMediaPhoto:
2966		if m.Media.NeedsUpload() {
2967			m.Media = fileAttach(fmt.Sprintf("attach://file-%d", idx))
2968		}
2969
2970		return m
2971	case InputMediaVideo:
2972		if m.Media.NeedsUpload() {
2973			m.Media = fileAttach(fmt.Sprintf("attach://file-%d", idx))
2974		}
2975
2976		if m.Thumb != nil && m.Thumb.NeedsUpload() {
2977			m.Thumb = fileAttach(fmt.Sprintf("attach://file-%d-thumb", idx))
2978		}
2979
2980		return m
2981	case InputMediaAudio:
2982		if m.Media.NeedsUpload() {
2983			m.Media = fileAttach(fmt.Sprintf("attach://file-%d", idx))
2984		}
2985
2986		if m.Thumb != nil && m.Thumb.NeedsUpload() {
2987			m.Thumb = fileAttach(fmt.Sprintf("attach://file-%d-thumb", idx))
2988		}
2989
2990		return m
2991	case InputMediaDocument:
2992		if m.Media.NeedsUpload() {
2993			m.Media = fileAttach(fmt.Sprintf("attach://file-%d", idx))
2994		}
2995
2996		if m.Thumb != nil && m.Thumb.NeedsUpload() {
2997			m.Thumb = fileAttach(fmt.Sprintf("attach://file-%d-thumb", idx))
2998		}
2999
3000		return m
3001	}
3002
3003	return nil
3004}
3005
3006// prepareInputMediaFile generates an array of RequestFile to provide for
3007// Fileable's files method. It returns an array as a single InputMedia may have
3008// multiple files, for the primary media and a thumbnail.
3009//
3010// The idx parameter is used to generate file field names. It uses the names
3011// "file-%d" for the main file and "file-%d-thumb" for the thumbnail.
3012//
3013// It is expected to be used in conjunction with prepareInputMediaParam.
3014func prepareInputMediaFile(inputMedia interface{}, idx int) []RequestFile {
3015	files := []RequestFile{}
3016
3017	switch m := inputMedia.(type) {
3018	case InputMediaPhoto:
3019		if m.Media.NeedsUpload() {
3020			files = append(files, RequestFile{
3021				Name: fmt.Sprintf("file-%d", idx),
3022				Data: m.Media,
3023			})
3024		}
3025	case InputMediaVideo:
3026		if m.Media.NeedsUpload() {
3027			files = append(files, RequestFile{
3028				Name: fmt.Sprintf("file-%d", idx),
3029				Data: m.Media,
3030			})
3031		}
3032
3033		if m.Thumb != nil && m.Thumb.NeedsUpload() {
3034			files = append(files, RequestFile{
3035				Name: fmt.Sprintf("file-%d", idx),
3036				Data: m.Thumb,
3037			})
3038		}
3039	case InputMediaDocument:
3040		if m.Media.NeedsUpload() {
3041			files = append(files, RequestFile{
3042				Name: fmt.Sprintf("file-%d", idx),
3043				Data: m.Media,
3044			})
3045		}
3046
3047		if m.Thumb != nil && m.Thumb.NeedsUpload() {
3048			files = append(files, RequestFile{
3049				Name: fmt.Sprintf("file-%d", idx),
3050				Data: m.Thumb,
3051			})
3052		}
3053	case InputMediaAudio:
3054		if m.Media.NeedsUpload() {
3055			files = append(files, RequestFile{
3056				Name: fmt.Sprintf("file-%d", idx),
3057				Data: m.Media,
3058			})
3059		}
3060
3061		if m.Thumb != nil && m.Thumb.NeedsUpload() {
3062			files = append(files, RequestFile{
3063				Name: fmt.Sprintf("file-%d", idx),
3064				Data: m.Thumb,
3065			})
3066		}
3067	}
3068
3069	return files
3070}
3071
3072// prepareInputMediaForParams calls prepareInputMediaParam for each item
3073// provided and returns a new array with the correct params for a request.
3074//
3075// It is expected that files will get data from the associated function,
3076// prepareInputMediaForFiles.
3077func prepareInputMediaForParams(inputMedia []interface{}) []interface{} {
3078	newMedia := make([]interface{}, len(inputMedia))
3079	copy(newMedia, inputMedia)
3080
3081	for idx, media := range inputMedia {
3082		if param := prepareInputMediaParam(media, idx); param != nil {
3083			newMedia[idx] = param
3084		}
3085	}
3086
3087	return newMedia
3088}
3089
3090// prepareInputMediaForFiles calls prepareInputMediaFile for each item
3091// provided and returns a new array with the correct files for a request.
3092//
3093// It is expected that params will get data from the associated function,
3094// prepareInputMediaForParams.
3095func prepareInputMediaForFiles(inputMedia []interface{}) []RequestFile {
3096	files := []RequestFile{}
3097
3098	for idx, media := range inputMedia {
3099		if file := prepareInputMediaFile(media, idx); file != nil {
3100			files = append(files, file...)
3101		}
3102	}
3103
3104	return files
3105}