all repos — telegram-bot-api @ 8d235002285e104f167a231948b72bf286f5776e

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