all repos — telegram-bot-api @ 63cbbdc63c09713ecb0d449236568b7fa18e4e6d

Golang bindings for the Telegram Bot API

configs.go (view raw)

   1package tgbotapi
   2
   3import (
   4	"io"
   5	"net/url"
   6	"strconv"
   7)
   8
   9// Telegram constants
  10const (
  11	// APIEndpoint is the endpoint for all API methods,
  12	// with formatting for Sprintf.
  13	APIEndpoint = "https://api.telegram.org/bot%s/%s"
  14	// FileEndpoint is the endpoint for downloading a file from Telegram.
  15	FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
  16)
  17
  18// Constant values for ChatActions
  19const (
  20	ChatTyping          = "typing"
  21	ChatUploadPhoto     = "upload_photo"
  22	ChatRecordVideo     = "record_video"
  23	ChatUploadVideo     = "upload_video"
  24	ChatRecordAudio     = "record_audio"
  25	ChatUploadAudio     = "upload_audio"
  26	ChatUploadDocument  = "upload_document"
  27	ChatFindLocation    = "find_location"
  28	ChatRecordVideoNote = "record_video_note"
  29	ChatUploadVideoNote = "upload_video_note"
  30)
  31
  32// API errors
  33const (
  34	// ErrAPIForbidden happens when a token is bad
  35	ErrAPIForbidden = "forbidden"
  36)
  37
  38// Constant values for ParseMode in MessageConfig
  39const (
  40	ModeMarkdown   = "Markdown"
  41	ModeMarkdownV2 = "MarkdownV2"
  42	ModeHTML       = "HTML"
  43)
  44
  45// Library errors
  46const (
  47	// ErrBadFileType happens when you pass an unknown type
  48	ErrBadFileType = "bad file type"
  49	ErrBadURL      = "bad or empty url"
  50)
  51
  52// Chattable is any config type that can be sent.
  53type Chattable interface {
  54	params() (Params, error)
  55	method() string
  56}
  57
  58// Fileable is any config type that can be sent that includes a file.
  59type Fileable interface {
  60	Chattable
  61	name() string
  62	getFile() interface{}
  63	useExistingFile() bool
  64}
  65
  66// BaseChat is base type for all chat config types.
  67type BaseChat struct {
  68	ChatID              int64 // required
  69	ChannelUsername     string
  70	ReplyToMessageID    int
  71	ReplyMarkup         interface{}
  72	DisableNotification bool
  73}
  74
  75func (chat *BaseChat) params() (Params, error) {
  76	params := make(Params)
  77
  78	params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
  79	params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
  80	params.AddBool("disable_notification", chat.DisableNotification)
  81
  82	err := params.AddInterface("reply_markup", chat.ReplyMarkup)
  83
  84	return params, err
  85}
  86
  87// BaseFile is a base type for all file config types.
  88type BaseFile struct {
  89	BaseChat
  90	File        interface{}
  91	FileID      string
  92	UseExisting bool
  93	MimeType    string
  94	FileSize    int
  95}
  96
  97func (file BaseFile) params() (Params, error) {
  98	params, err := file.BaseChat.params()
  99
 100	params.AddNonEmpty("mime_type", file.MimeType)
 101	params.AddNonZero("file_size", file.FileSize)
 102
 103	return params, err
 104}
 105
 106func (file BaseFile) getFile() interface{} {
 107	return file.File
 108}
 109
 110func (file BaseFile) useExistingFile() bool {
 111	return file.UseExisting
 112}
 113
 114// BaseEdit is base type of all chat edits.
 115type BaseEdit struct {
 116	ChatID          int64
 117	ChannelUsername string
 118	MessageID       int
 119	InlineMessageID string
 120	ReplyMarkup     *InlineKeyboardMarkup
 121}
 122
 123func (edit BaseEdit) params() (Params, error) {
 124	params := make(Params)
 125
 126	if edit.InlineMessageID != "" {
 127		params["inline_message_id"] = edit.InlineMessageID
 128	} else {
 129		params.AddFirstValid("chat_id", edit.ChatID, edit.ChannelUsername)
 130		params.AddNonZero("message_id", edit.MessageID)
 131	}
 132
 133	err := params.AddInterface("reply_markup", edit.ReplyMarkup)
 134
 135	return params, err
 136}
 137
 138// MessageConfig contains information about a SendMessage request.
 139type MessageConfig struct {
 140	BaseChat
 141	Text                  string
 142	ParseMode             string
 143	DisableWebPagePreview bool
 144}
 145
 146func (config MessageConfig) params() (Params, error) {
 147	params, err := config.BaseChat.params()
 148	if err != nil {
 149		return params, err
 150	}
 151
 152	params.AddNonEmpty("text", config.Text)
 153	params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
 154	params.AddNonEmpty("parse_mode", config.ParseMode)
 155
 156	return params, nil
 157}
 158
 159func (config MessageConfig) method() string {
 160	return "sendMessage"
 161}
 162
 163// ForwardConfig contains information about a ForwardMessage request.
 164type ForwardConfig struct {
 165	BaseChat
 166	FromChatID          int64 // required
 167	FromChannelUsername string
 168	MessageID           int // required
 169}
 170
 171func (config ForwardConfig) params() (Params, error) {
 172	params, err := config.BaseChat.params()
 173	if err != nil {
 174		return params, err
 175	}
 176
 177	params.AddNonZero64("from_chat_id", config.FromChatID)
 178	params.AddNonZero("message_id", config.MessageID)
 179
 180	return params, nil
 181}
 182
 183func (config ForwardConfig) method() string {
 184	return "forwardMessage"
 185}
 186
 187// PhotoConfig contains information about a SendPhoto request.
 188type PhotoConfig struct {
 189	BaseFile
 190	Caption   string
 191	ParseMode string
 192}
 193
 194func (config PhotoConfig) params() (Params, error) {
 195	params, err := config.BaseFile.params()
 196
 197	params.AddNonEmpty(config.name(), config.FileID)
 198	params.AddNonEmpty("caption", config.Caption)
 199	params.AddNonEmpty("parse_mode", config.ParseMode)
 200
 201	return params, err
 202}
 203
 204func (config PhotoConfig) name() string {
 205	return "photo"
 206}
 207
 208func (config PhotoConfig) method() string {
 209	return "sendPhoto"
 210}
 211
 212// AudioConfig contains information about a SendAudio request.
 213type AudioConfig struct {
 214	BaseFile
 215	Caption   string
 216	ParseMode string
 217	Duration  int
 218	Performer string
 219	Title     string
 220}
 221
 222func (config AudioConfig) params() (Params, error) {
 223	params, err := config.BaseChat.params()
 224	if err != nil {
 225		return params, err
 226	}
 227
 228	params.AddNonEmpty(config.name(), config.FileID)
 229	params.AddNonZero("duration", config.Duration)
 230	params.AddNonEmpty("performer", config.Performer)
 231	params.AddNonEmpty("title", config.Title)
 232	params.AddNonEmpty("caption", config.Caption)
 233	params.AddNonEmpty("parse_mode", config.ParseMode)
 234
 235	return params, nil
 236}
 237
 238func (config AudioConfig) name() string {
 239	return "audio"
 240}
 241
 242func (config AudioConfig) method() string {
 243	return "sendAudio"
 244}
 245
 246// DocumentConfig contains information about a SendDocument request.
 247type DocumentConfig struct {
 248	BaseFile
 249	Caption   string
 250	ParseMode string
 251}
 252
 253func (config DocumentConfig) params() (Params, error) {
 254	params, err := config.BaseFile.params()
 255
 256	params.AddNonEmpty(config.name(), config.FileID)
 257	params.AddNonEmpty("caption", config.Caption)
 258	params.AddNonEmpty("parse_mode", config.ParseMode)
 259
 260	return params, err
 261}
 262
 263func (config DocumentConfig) name() string {
 264	return "document"
 265}
 266
 267func (config DocumentConfig) method() string {
 268	return "sendDocument"
 269}
 270
 271// StickerConfig contains information about a SendSticker request.
 272type StickerConfig struct {
 273	BaseFile
 274}
 275
 276func (config StickerConfig) params() (Params, error) {
 277	params, err := config.BaseChat.params()
 278
 279	params.AddNonEmpty(config.name(), config.FileID)
 280
 281	return params, err
 282}
 283
 284func (config StickerConfig) name() string {
 285	return "sticker"
 286}
 287
 288func (config StickerConfig) method() string {
 289	return "sendSticker"
 290}
 291
 292// VideoConfig contains information about a SendVideo request.
 293type VideoConfig struct {
 294	BaseFile
 295	Duration          int
 296	Caption           string
 297	ParseMode         string
 298	SupportsStreaming bool
 299}
 300
 301func (config VideoConfig) params() (Params, error) {
 302	params, err := config.BaseChat.params()
 303
 304	params.AddNonEmpty(config.name(), config.FileID)
 305	params.AddNonZero("duration", config.Duration)
 306	params.AddNonEmpty("caption", config.Caption)
 307	params.AddNonEmpty("parse_mode", config.ParseMode)
 308	params.AddBool("supports_streaming", config.SupportsStreaming)
 309
 310	return params, err
 311}
 312
 313func (config VideoConfig) name() string {
 314	return "video"
 315}
 316
 317func (config VideoConfig) method() string {
 318	return "sendVideo"
 319}
 320
 321// AnimationConfig contains information about a SendAnimation request.
 322type AnimationConfig struct {
 323	BaseFile
 324	Duration  int
 325	Caption   string
 326	ParseMode string
 327}
 328
 329func (config AnimationConfig) params() (Params, error) {
 330	params, err := config.BaseChat.params()
 331
 332	params.AddNonEmpty(config.name(), config.FileID)
 333	params.AddNonZero("duration", config.Duration)
 334	params.AddNonEmpty("caption", config.Caption)
 335	params.AddNonEmpty("parse_mode", config.ParseMode)
 336
 337	return params, err
 338}
 339
 340func (config AnimationConfig) name() string {
 341	return "animation"
 342}
 343
 344func (config AnimationConfig) method() string {
 345	return "sendAnimation"
 346}
 347
 348// VideoNoteConfig contains information about a SendVideoNote request.
 349type VideoNoteConfig struct {
 350	BaseFile
 351	Duration int
 352	Length   int
 353}
 354
 355func (config VideoNoteConfig) params() (Params, error) {
 356	params, err := config.BaseChat.params()
 357
 358	params.AddNonEmpty(config.name(), config.FileID)
 359	params.AddNonZero("duration", config.Duration)
 360	params.AddNonZero("length", config.Length)
 361
 362	return params, err
 363}
 364
 365func (config VideoNoteConfig) name() string {
 366	return "video_note"
 367}
 368
 369func (config VideoNoteConfig) method() string {
 370	return "sendVideoNote"
 371}
 372
 373// VoiceConfig contains information about a SendVoice request.
 374type VoiceConfig struct {
 375	BaseFile
 376	Caption   string
 377	ParseMode string
 378	Duration  int
 379}
 380
 381func (config VoiceConfig) params() (Params, error) {
 382	params, err := config.BaseChat.params()
 383
 384	params.AddNonEmpty(config.name(), config.FileID)
 385	params.AddNonZero("duration", config.Duration)
 386	params.AddNonEmpty("caption", config.Caption)
 387	params.AddNonEmpty("parse_mode", config.ParseMode)
 388
 389	return params, err
 390}
 391
 392func (config VoiceConfig) name() string {
 393	return "voice"
 394}
 395
 396func (config VoiceConfig) method() string {
 397	return "sendVoice"
 398}
 399
 400// LocationConfig contains information about a SendLocation request.
 401type LocationConfig struct {
 402	BaseChat
 403	Latitude   float64 // required
 404	Longitude  float64 // required
 405	LivePeriod int     // optional
 406}
 407
 408func (config LocationConfig) params() (Params, error) {
 409	params, err := config.BaseChat.params()
 410
 411	params.AddNonZeroFloat("latitude", config.Latitude)
 412	params.AddNonZeroFloat("longitude", config.Longitude)
 413	params.AddNonZero("live_period", config.LivePeriod)
 414
 415	return params, err
 416}
 417
 418func (config LocationConfig) method() string {
 419	return "sendLocation"
 420}
 421
 422// EditMessageLiveLocationConfig allows you to update a live location.
 423type EditMessageLiveLocationConfig struct {
 424	BaseEdit
 425	Latitude  float64 // required
 426	Longitude float64 // required
 427}
 428
 429func (config EditMessageLiveLocationConfig) params() (Params, error) {
 430	params, err := config.BaseEdit.params()
 431
 432	params.AddNonZeroFloat("latitude", config.Latitude)
 433	params.AddNonZeroFloat("longitude", config.Longitude)
 434
 435	return params, err
 436}
 437
 438func (config EditMessageLiveLocationConfig) method() string {
 439	return "editMessageLiveLocation"
 440}
 441
 442// StopMessageLiveLocationConfig stops updating a live location.
 443type StopMessageLiveLocationConfig struct {
 444	BaseEdit
 445}
 446
 447func (config StopMessageLiveLocationConfig) params() (Params, error) {
 448	return config.BaseEdit.params()
 449}
 450
 451func (config StopMessageLiveLocationConfig) method() string {
 452	return "stopMessageLiveLocation"
 453}
 454
 455// VenueConfig contains information about a SendVenue request.
 456type VenueConfig struct {
 457	BaseChat
 458	Latitude     float64 // required
 459	Longitude    float64 // required
 460	Title        string  // required
 461	Address      string  // required
 462	FoursquareID string
 463}
 464
 465func (config VenueConfig) params() (Params, error) {
 466	params, err := config.BaseChat.params()
 467
 468	params.AddNonZeroFloat("latitude", config.Latitude)
 469	params.AddNonZeroFloat("longitude", config.Longitude)
 470	params["title"] = config.Title
 471	params["address"] = config.Address
 472	params.AddNonEmpty("foursquare_id", config.FoursquareID)
 473
 474	return params, err
 475}
 476
 477func (config VenueConfig) method() string {
 478	return "sendVenue"
 479}
 480
 481// ContactConfig allows you to send a contact.
 482type ContactConfig struct {
 483	BaseChat
 484	PhoneNumber string
 485	FirstName   string
 486	LastName    string
 487	VCard       string
 488}
 489
 490func (config ContactConfig) params() (Params, error) {
 491	params, err := config.BaseChat.params()
 492
 493	params["phone_number"] = config.PhoneNumber
 494	params["first_name"] = config.FirstName
 495
 496	params.AddNonEmpty("last_name", config.LastName)
 497	params.AddNonEmpty("vcard", config.VCard)
 498
 499	return params, err
 500}
 501
 502func (config ContactConfig) method() string {
 503	return "sendContact"
 504}
 505
 506// SendPollConfig allows you to send a poll.
 507type SendPollConfig struct {
 508	BaseChat
 509	Question              string
 510	Options               []string
 511	IsAnonymous           bool
 512	Type                  string
 513	AllowsMultipleAnswers bool
 514	CorrectOptionID       int64
 515	Explanation           string
 516	ExplanationParseMode  string
 517	OpenPeriod            int
 518	CloseDate             int
 519	IsClosed              bool
 520}
 521
 522func (config SendPollConfig) params() (Params, error) {
 523	params, err := config.BaseChat.params()
 524	if err != nil {
 525		return params, err
 526	}
 527
 528	params["question"] = config.Question
 529	err = params.AddInterface("options", config.Options)
 530	params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous)
 531	params.AddNonEmpty("type", config.Type)
 532	params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
 533	params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10)
 534	params.AddBool("is_closed", config.IsClosed)
 535	params.AddNonEmpty("explanation", config.Explanation)
 536	params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode)
 537	params.AddNonZero("open_period", config.OpenPeriod)
 538	params.AddNonZero("close_date", config.CloseDate)
 539
 540	return params, err
 541}
 542
 543func (SendPollConfig) method() string {
 544	return "sendPoll"
 545}
 546
 547// GameConfig allows you to send a game.
 548type GameConfig struct {
 549	BaseChat
 550	GameShortName string
 551}
 552
 553func (config GameConfig) params() (Params, error) {
 554	params, err := config.BaseChat.params()
 555
 556	params["game_short_name"] = config.GameShortName
 557
 558	return params, err
 559}
 560
 561func (config GameConfig) method() string {
 562	return "sendGame"
 563}
 564
 565// SetGameScoreConfig allows you to update the game score in a chat.
 566type SetGameScoreConfig struct {
 567	UserID             int
 568	Score              int
 569	Force              bool
 570	DisableEditMessage bool
 571	ChatID             int64
 572	ChannelUsername    string
 573	MessageID          int
 574	InlineMessageID    string
 575}
 576
 577func (config SetGameScoreConfig) params() (Params, error) {
 578	params := make(Params)
 579
 580	params.AddNonZero("user_id", config.UserID)
 581	params.AddNonZero("scrore", config.Score)
 582	params.AddBool("disable_edit_message", config.DisableEditMessage)
 583
 584	if config.InlineMessageID != "" {
 585		params["inline_message_id"] = config.InlineMessageID
 586	} else {
 587		params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
 588		params.AddNonZero("message_id", config.MessageID)
 589	}
 590
 591	return params, nil
 592}
 593
 594func (config SetGameScoreConfig) method() string {
 595	return "setGameScore"
 596}
 597
 598// GetGameHighScoresConfig allows you to fetch the high scores for a game.
 599type GetGameHighScoresConfig struct {
 600	UserID          int
 601	ChatID          int
 602	ChannelUsername string
 603	MessageID       int
 604	InlineMessageID string
 605}
 606
 607func (config GetGameHighScoresConfig) params() (Params, error) {
 608	params := make(Params)
 609
 610	params.AddNonZero("user_id", config.UserID)
 611
 612	if config.InlineMessageID != "" {
 613		params["inline_message_id"] = config.InlineMessageID
 614	} else {
 615		params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
 616		params.AddNonZero("message_id", config.MessageID)
 617	}
 618
 619	return params, nil
 620}
 621
 622func (config GetGameHighScoresConfig) method() string {
 623	return "getGameHighScores"
 624}
 625
 626// ChatActionConfig contains information about a SendChatAction request.
 627type ChatActionConfig struct {
 628	BaseChat
 629	Action string // required
 630}
 631
 632func (config ChatActionConfig) params() (Params, error) {
 633	params, err := config.BaseChat.params()
 634
 635	params["action"] = config.Action
 636
 637	return params, err
 638}
 639
 640func (config ChatActionConfig) method() string {
 641	return "sendChatAction"
 642}
 643
 644// EditMessageTextConfig allows you to modify the text in a message.
 645type EditMessageTextConfig struct {
 646	BaseEdit
 647	Text                  string
 648	ParseMode             string
 649	DisableWebPagePreview bool
 650}
 651
 652func (config EditMessageTextConfig) params() (Params, error) {
 653	params, err := config.BaseEdit.params()
 654
 655	params["text"] = config.Text
 656	params.AddNonEmpty("parse_mode", config.ParseMode)
 657	params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
 658
 659	return params, err
 660}
 661
 662func (config EditMessageTextConfig) method() string {
 663	return "editMessageText"
 664}
 665
 666// EditMessageCaptionConfig allows you to modify the caption of a message.
 667type EditMessageCaptionConfig struct {
 668	BaseEdit
 669	Caption   string
 670	ParseMode string
 671}
 672
 673func (config EditMessageCaptionConfig) params() (Params, error) {
 674	params, err := config.BaseEdit.params()
 675
 676	params["caption"] = config.Caption
 677	params.AddNonEmpty("parse_mode", config.ParseMode)
 678
 679	return params, err
 680}
 681
 682func (config EditMessageCaptionConfig) method() string {
 683	return "editMessageCaption"
 684}
 685
 686// EditMessageMediaConfig contains information about editing a message's media.
 687type EditMessageMediaConfig struct {
 688	BaseEdit
 689
 690	Media interface{}
 691}
 692
 693func (EditMessageMediaConfig) method() string {
 694	return "editMessageMedia"
 695}
 696
 697func (config EditMessageMediaConfig) params() (Params, error) {
 698	params, err := config.BaseEdit.params()
 699
 700	params.AddInterface("media", config.Media)
 701
 702	return params, err
 703}
 704
 705// EditMessageReplyMarkupConfig allows you to modify the reply markup
 706// of a message.
 707type EditMessageReplyMarkupConfig struct {
 708	BaseEdit
 709}
 710
 711func (config EditMessageReplyMarkupConfig) params() (Params, error) {
 712	return config.BaseEdit.params()
 713}
 714
 715func (config EditMessageReplyMarkupConfig) method() string {
 716	return "editMessageReplyMarkup"
 717}
 718
 719// StopPollConfig allows you to stop a poll sent by the bot.
 720type StopPollConfig struct {
 721	BaseEdit
 722}
 723
 724func (config StopPollConfig) params() (Params, error) {
 725	return config.BaseEdit.params()
 726}
 727
 728func (StopPollConfig) method() string {
 729	return "stopPoll"
 730}
 731
 732// UserProfilePhotosConfig contains information about a
 733// GetUserProfilePhotos request.
 734type UserProfilePhotosConfig struct {
 735	UserID int
 736	Offset int
 737	Limit  int
 738}
 739
 740func (UserProfilePhotosConfig) method() string {
 741	return "getUserProfilePhotos"
 742}
 743
 744func (config UserProfilePhotosConfig) params() (Params, error) {
 745	params := make(Params)
 746
 747	params.AddNonZero("user_id", config.UserID)
 748	params.AddNonZero("offset", config.Offset)
 749	params.AddNonZero("limit", config.Limit)
 750
 751	return params, nil
 752}
 753
 754// FileConfig has information about a file hosted on Telegram.
 755type FileConfig struct {
 756	FileID string
 757}
 758
 759func (FileConfig) method() string {
 760	return "getFile"
 761}
 762
 763func (config FileConfig) params() (Params, error) {
 764	params := make(Params)
 765
 766	params["file_id"] = config.FileID
 767
 768	return params, nil
 769}
 770
 771// UpdateConfig contains information about a GetUpdates request.
 772type UpdateConfig struct {
 773	Offset  int
 774	Limit   int
 775	Timeout int
 776}
 777
 778func (UpdateConfig) method() string {
 779	return "getUpdates"
 780}
 781
 782func (config UpdateConfig) params() (Params, error) {
 783	params := make(Params)
 784
 785	params.AddNonZero("offset", config.Offset)
 786	params.AddNonZero("limit", config.Limit)
 787	params.AddNonZero("timeout", config.Timeout)
 788
 789	return params, nil
 790}
 791
 792// WebhookConfig contains information about a SetWebhook request.
 793type WebhookConfig struct {
 794	URL            *url.URL
 795	Certificate    interface{}
 796	MaxConnections int
 797	AllowedUpdates []string
 798}
 799
 800func (config WebhookConfig) method() string {
 801	return "setWebhook"
 802}
 803
 804func (config WebhookConfig) params() (Params, error) {
 805	params := make(Params)
 806
 807	if config.URL != nil {
 808		params["url"] = config.URL.String()
 809	}
 810
 811	params.AddNonZero("max_connections", config.MaxConnections)
 812	params.AddInterface("allowed_updates", config.AllowedUpdates)
 813
 814	return params, nil
 815}
 816
 817func (config WebhookConfig) name() string {
 818	return "certificate"
 819}
 820
 821func (config WebhookConfig) getFile() interface{} {
 822	return config.Certificate
 823}
 824
 825func (config WebhookConfig) useExistingFile() bool {
 826	return config.URL != nil
 827}
 828
 829// RemoveWebhookConfig is a helper to remove a webhook.
 830type RemoveWebhookConfig struct {
 831}
 832
 833func (config RemoveWebhookConfig) method() string {
 834	return "setWebhook"
 835}
 836
 837func (config RemoveWebhookConfig) params() (Params, error) {
 838	return nil, nil
 839}
 840
 841// FileBytes contains information about a set of bytes to upload
 842// as a File.
 843type FileBytes struct {
 844	Name  string
 845	Bytes []byte
 846}
 847
 848// FileReader contains information about a reader to upload as a File.
 849// If Size is -1, it will read the entire Reader into memory to
 850// calculate a Size.
 851type FileReader struct {
 852	Name   string
 853	Reader io.Reader
 854	Size   int64
 855}
 856
 857// InlineConfig contains information on making an InlineQuery response.
 858type InlineConfig struct {
 859	InlineQueryID     string        `json:"inline_query_id"`
 860	Results           []interface{} `json:"results"`
 861	CacheTime         int           `json:"cache_time"`
 862	IsPersonal        bool          `json:"is_personal"`
 863	NextOffset        string        `json:"next_offset"`
 864	SwitchPMText      string        `json:"switch_pm_text"`
 865	SwitchPMParameter string        `json:"switch_pm_parameter"`
 866}
 867
 868func (config InlineConfig) method() string {
 869	return "answerInlineQuery"
 870}
 871
 872func (config InlineConfig) params() (Params, error) {
 873	params := make(Params)
 874
 875	params["inline_query_id"] = config.InlineQueryID
 876	params.AddNonZero("cache_time", config.CacheTime)
 877	params.AddBool("is_personal", config.IsPersonal)
 878	params.AddNonEmpty("next_offset", config.NextOffset)
 879	params.AddNonEmpty("switch_pm_text", config.SwitchPMText)
 880	params.AddNonEmpty("switch_pm_parameter", config.SwitchPMParameter)
 881
 882	if err := params.AddInterface("results", config.Results); err != nil {
 883		return params, err
 884	}
 885
 886	return params, nil
 887}
 888
 889// CallbackConfig contains information on making a CallbackQuery response.
 890type CallbackConfig struct {
 891	CallbackQueryID string `json:"callback_query_id"`
 892	Text            string `json:"text"`
 893	ShowAlert       bool   `json:"show_alert"`
 894	URL             string `json:"url"`
 895	CacheTime       int    `json:"cache_time"`
 896}
 897
 898func (config CallbackConfig) method() string {
 899	return "answerCallbackQuery"
 900}
 901
 902func (config CallbackConfig) params() (Params, error) {
 903	params := make(Params)
 904
 905	params["callback_query_id"] = config.CallbackQueryID
 906	params.AddNonEmpty("text", config.Text)
 907	params.AddBool("show_alert", config.ShowAlert)
 908	params.AddNonEmpty("url", config.URL)
 909	params.AddNonZero("cache_time", config.CacheTime)
 910
 911	return params, nil
 912}
 913
 914// ChatMemberConfig contains information about a user in a chat for use
 915// with administrative functions such as kicking or unbanning a user.
 916type ChatMemberConfig struct {
 917	ChatID             int64
 918	SuperGroupUsername string
 919	ChannelUsername    string
 920	UserID             int
 921}
 922
 923// UnbanChatMemberConfig allows you to unban a user.
 924type UnbanChatMemberConfig struct {
 925	ChatMemberConfig
 926}
 927
 928func (config UnbanChatMemberConfig) method() string {
 929	return "unbanChatMember"
 930}
 931
 932func (config UnbanChatMemberConfig) params() (Params, error) {
 933	params := make(Params)
 934
 935	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
 936	params.AddNonZero("user_id", config.UserID)
 937
 938	return params, nil
 939}
 940
 941// KickChatMemberConfig contains extra fields to kick user
 942type KickChatMemberConfig struct {
 943	ChatMemberConfig
 944	UntilDate int64
 945}
 946
 947func (config KickChatMemberConfig) method() string {
 948	return "kickChatMember"
 949}
 950
 951func (config KickChatMemberConfig) params() (Params, error) {
 952	params := make(Params)
 953
 954	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
 955	params.AddNonZero("user_id", config.UserID)
 956	params.AddNonZero64("until_date", config.UntilDate)
 957
 958	return params, nil
 959}
 960
 961// RestrictChatMemberConfig contains fields to restrict members of chat
 962type RestrictChatMemberConfig struct {
 963	ChatMemberConfig
 964	UntilDate   int64
 965	Permissions *ChatPermissions
 966}
 967
 968func (config RestrictChatMemberConfig) method() string {
 969	return "restrictChatMember"
 970}
 971
 972func (config RestrictChatMemberConfig) params() (Params, error) {
 973	params := make(Params)
 974
 975	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
 976	params.AddNonZero("user_id", config.UserID)
 977
 978	if err := params.AddInterface("permissions", config.Permissions); err != nil {
 979		return params, err
 980	}
 981	params.AddNonZero64("until_date", config.UntilDate)
 982
 983	return params, nil
 984}
 985
 986// PromoteChatMemberConfig contains fields to promote members of chat
 987type PromoteChatMemberConfig struct {
 988	ChatMemberConfig
 989	CanChangeInfo      bool
 990	CanPostMessages    bool
 991	CanEditMessages    bool
 992	CanDeleteMessages  bool
 993	CanInviteUsers     bool
 994	CanRestrictMembers bool
 995	CanPinMessages     bool
 996	CanPromoteMembers  bool
 997}
 998
 999func (config PromoteChatMemberConfig) method() string {
1000	return "promoteChatMember"
1001}
1002
1003func (config PromoteChatMemberConfig) params() (Params, error) {
1004	params := make(Params)
1005
1006	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1007	params.AddNonZero("user_id", config.UserID)
1008
1009	params.AddBool("can_change_info", config.CanChangeInfo)
1010	params.AddBool("can_post_messages", config.CanPostMessages)
1011	params.AddBool("can_edit_messages", config.CanEditMessages)
1012	params.AddBool("can_delete_messages", config.CanDeleteMessages)
1013	params.AddBool("can_invite_users", config.CanInviteUsers)
1014	params.AddBool("can_restrict_members", config.CanRestrictMembers)
1015	params.AddBool("can_pin_messages", config.CanPinMessages)
1016	params.AddBool("can_promote_members", config.CanPromoteMembers)
1017
1018	return params, nil
1019}
1020
1021// SetChatAdministratorCustomTitle sets the title of an administrative user
1022// promoted by the bot for a chat.
1023type SetChatAdministratorCustomTitle struct {
1024	ChatMemberConfig
1025	CustomTitle string
1026}
1027
1028func (SetChatAdministratorCustomTitle) method() string {
1029	return "setChatAdministratorCustomTitle"
1030}
1031
1032func (config SetChatAdministratorCustomTitle) params() (Params, error) {
1033	params := make(Params)
1034
1035	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1036	params.AddNonZero("user_id", config.UserID)
1037	params.AddNonEmpty("custom_title", config.CustomTitle)
1038
1039	return params, nil
1040}
1041
1042// ChatConfig contains information about getting information on a chat.
1043type ChatConfig struct {
1044	ChatID             int64
1045	SuperGroupUsername string
1046}
1047
1048func (config ChatConfig) params() (Params, error) {
1049	params := make(Params)
1050
1051	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1052
1053	return params, nil
1054}
1055
1056// ChatInfoConfig contains information about getting chat information.
1057type ChatInfoConfig struct {
1058	ChatConfig
1059}
1060
1061func (ChatInfoConfig) method() string {
1062	return "getChat"
1063}
1064
1065// ChatMemberCountConfig contains information about getting the number of users in a chat.
1066type ChatMemberCountConfig struct {
1067	ChatConfig
1068}
1069
1070func (ChatMemberCountConfig) method() string {
1071	return "getChatMembersCount"
1072}
1073
1074// ChatAdministratorsConfig contains information about getting chat administrators.
1075type ChatAdministratorsConfig struct {
1076	ChatConfig
1077}
1078
1079func (ChatAdministratorsConfig) method() string {
1080	return "getChatAdministrators"
1081}
1082
1083// SetChatPermissionsConfig allows you to set default permissions for the
1084// members in a group. The bot must be an administrator and have rights to
1085// restrict members.
1086type SetChatPermissionsConfig struct {
1087	ChatConfig
1088	Permissions *ChatPermissions
1089}
1090
1091func (SetChatPermissionsConfig) method() string {
1092	return "setChatPermissions"
1093}
1094
1095func (config SetChatPermissionsConfig) params() (Params, error) {
1096	params := make(Params)
1097
1098	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1099	params.AddInterface("permissions", config.Permissions)
1100
1101	return params, nil
1102}
1103
1104// ChatInviteLinkConfig contains information about getting a chat link.
1105//
1106// Note that generating a new link will revoke any previous links.
1107type ChatInviteLinkConfig struct {
1108	ChatConfig
1109}
1110
1111func (ChatInviteLinkConfig) method() string {
1112	return "exportChatInviteLink"
1113}
1114
1115func (config ChatInviteLinkConfig) params() (Params, error) {
1116	params := make(Params)
1117
1118	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1119
1120	return params, nil
1121}
1122
1123// LeaveChatConfig allows you to leave a chat.
1124type LeaveChatConfig struct {
1125	ChatID          int64
1126	ChannelUsername string
1127}
1128
1129func (config LeaveChatConfig) method() string {
1130	return "leaveChat"
1131}
1132
1133func (config LeaveChatConfig) params() (Params, error) {
1134	params := make(Params)
1135
1136	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1137
1138	return params, nil
1139}
1140
1141// ChatConfigWithUser contains information about a chat and a user.
1142type ChatConfigWithUser struct {
1143	ChatID             int64
1144	SuperGroupUsername string
1145	UserID             int
1146}
1147
1148func (config ChatConfigWithUser) params() (Params, error) {
1149	params := make(Params)
1150
1151	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1152	params.AddNonZero("user_id", config.UserID)
1153
1154	return params, nil
1155}
1156
1157// GetChatMemberConfig is information about getting a specific member in a chat.
1158type GetChatMemberConfig struct {
1159	ChatConfigWithUser
1160}
1161
1162func (GetChatMemberConfig) method() string {
1163	return "getChatMember"
1164}
1165
1166// InvoiceConfig contains information for sendInvoice request.
1167type InvoiceConfig struct {
1168	BaseChat
1169	Title                     string         // required
1170	Description               string         // required
1171	Payload                   string         // required
1172	ProviderToken             string         // required
1173	StartParameter            string         // required
1174	Currency                  string         // required
1175	Prices                    []LabeledPrice // required
1176	ProviderData              string
1177	PhotoURL                  string
1178	PhotoSize                 int
1179	PhotoWidth                int
1180	PhotoHeight               int
1181	NeedName                  bool
1182	NeedPhoneNumber           bool
1183	NeedEmail                 bool
1184	NeedShippingAddress       bool
1185	SendPhoneNumberToProvider bool
1186	SendEmailToProvider       bool
1187	IsFlexible                bool
1188}
1189
1190func (config InvoiceConfig) params() (Params, error) {
1191	params, err := config.BaseChat.params()
1192	if err != nil {
1193		return params, err
1194	}
1195
1196	params["title"] = config.Title
1197	params["description"] = config.Description
1198	params["payload"] = config.Payload
1199	params["provider_token"] = config.ProviderToken
1200	params["start_parameter"] = config.StartParameter
1201	params["currency"] = config.Currency
1202
1203	if err = params.AddInterface("prices", config.Prices); err != nil {
1204		return params, err
1205	}
1206
1207	params.AddNonEmpty("provider_data", config.ProviderData)
1208	params.AddNonEmpty("photo_url", config.PhotoURL)
1209	params.AddNonZero("photo_size", config.PhotoSize)
1210	params.AddNonZero("photo_width", config.PhotoWidth)
1211	params.AddNonZero("photo_height", config.PhotoHeight)
1212	params.AddBool("need_name", config.NeedName)
1213	params.AddBool("need_phone_number", config.NeedPhoneNumber)
1214	params.AddBool("need_email", config.NeedEmail)
1215	params.AddBool("need_shipping_address", config.NeedShippingAddress)
1216	params.AddBool("is_flexible", config.IsFlexible)
1217	params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider)
1218	params.AddBool("send_email_to_provider", config.SendEmailToProvider)
1219
1220	return params, nil
1221}
1222
1223func (config InvoiceConfig) method() string {
1224	return "sendInvoice"
1225}
1226
1227// ShippingConfig contains information for answerShippingQuery request.
1228type ShippingConfig struct {
1229	ShippingQueryID string // required
1230	OK              bool   // required
1231	ShippingOptions []ShippingOption
1232	ErrorMessage    string
1233}
1234
1235// PreCheckoutConfig conatins information for answerPreCheckoutQuery request.
1236type PreCheckoutConfig struct {
1237	PreCheckoutQueryID string // required
1238	OK                 bool   // required
1239	ErrorMessage       string
1240}
1241
1242// DeleteMessageConfig contains information of a message in a chat to delete.
1243type DeleteMessageConfig struct {
1244	ChatID    int64
1245	MessageID int
1246}
1247
1248func (config DeleteMessageConfig) method() string {
1249	return "deleteMessage"
1250}
1251
1252func (config DeleteMessageConfig) params() (Params, error) {
1253	params := make(Params)
1254
1255	params.AddNonZero64("chat_id", config.ChatID)
1256	params.AddNonZero("message_id", config.MessageID)
1257
1258	return params, nil
1259}
1260
1261// PinChatMessageConfig contains information of a message in a chat to pin.
1262type PinChatMessageConfig struct {
1263	ChatID              int64
1264	ChannelUsername     string
1265	MessageID           int
1266	DisableNotification bool
1267}
1268
1269func (config PinChatMessageConfig) method() string {
1270	return "pinChatMessage"
1271}
1272
1273func (config PinChatMessageConfig) params() (Params, error) {
1274	params := make(Params)
1275
1276	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1277	params.AddNonZero("message_id", config.MessageID)
1278	params.AddBool("disable_notification", config.DisableNotification)
1279
1280	return params, nil
1281}
1282
1283// UnpinChatMessageConfig contains information of chat to unpin.
1284type UnpinChatMessageConfig struct {
1285	ChatID          int64
1286	ChannelUsername string
1287}
1288
1289func (config UnpinChatMessageConfig) method() string {
1290	return "unpinChatMessage"
1291}
1292
1293func (config UnpinChatMessageConfig) params() (Params, error) {
1294	params := make(Params)
1295
1296	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1297
1298	return params, nil
1299}
1300
1301// SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
1302type SetChatPhotoConfig struct {
1303	BaseFile
1304}
1305
1306func (config SetChatPhotoConfig) method() string {
1307	return "setChatPhoto"
1308}
1309
1310func (config SetChatPhotoConfig) name() string {
1311	return "photo"
1312}
1313
1314func (config SetChatPhotoConfig) getFile() interface{} {
1315	return config.File
1316}
1317
1318func (config SetChatPhotoConfig) useExistingFile() bool {
1319	return config.UseExisting
1320}
1321
1322// DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
1323type DeleteChatPhotoConfig struct {
1324	ChatID          int64
1325	ChannelUsername string
1326}
1327
1328func (config DeleteChatPhotoConfig) method() string {
1329	return "deleteChatPhoto"
1330}
1331
1332func (config DeleteChatPhotoConfig) params() (Params, error) {
1333	params := make(Params)
1334
1335	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1336
1337	return params, nil
1338}
1339
1340// SetChatTitleConfig allows you to set the title of something other than a private chat.
1341type SetChatTitleConfig struct {
1342	ChatID          int64
1343	ChannelUsername string
1344
1345	Title string
1346}
1347
1348func (config SetChatTitleConfig) method() string {
1349	return "setChatTitle"
1350}
1351
1352func (config SetChatTitleConfig) params() (Params, error) {
1353	params := make(Params)
1354
1355	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1356	params["title"] = config.Title
1357
1358	return params, nil
1359}
1360
1361// SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
1362type SetChatDescriptionConfig struct {
1363	ChatID          int64
1364	ChannelUsername string
1365
1366	Description string
1367}
1368
1369func (config SetChatDescriptionConfig) method() string {
1370	return "setChatDescription"
1371}
1372
1373func (config SetChatDescriptionConfig) params() (Params, error) {
1374	params := make(Params)
1375
1376	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1377	params["description"] = config.Description
1378
1379	return params, nil
1380}
1381
1382// GetStickerSetConfig allows you to get the stickers in a set.
1383type GetStickerSetConfig struct {
1384	Name string
1385}
1386
1387func (config GetStickerSetConfig) method() string {
1388	return "getStickerSet"
1389}
1390
1391func (config GetStickerSetConfig) params() (Params, error) {
1392	params := make(Params)
1393
1394	params["name"] = config.Name
1395
1396	return params, nil
1397}
1398
1399// UploadStickerConfig allows you to upload a sticker for use in a set later.
1400type UploadStickerConfig struct {
1401	UserID     int64
1402	PNGSticker interface{}
1403}
1404
1405func (config UploadStickerConfig) method() string {
1406	return "uploadStickerFile"
1407}
1408
1409func (config UploadStickerConfig) params() (Params, error) {
1410	params := make(Params)
1411
1412	params.AddNonZero64("user_id", config.UserID)
1413
1414	return params, nil
1415}
1416
1417func (config UploadStickerConfig) name() string {
1418	return "png_sticker"
1419}
1420
1421func (config UploadStickerConfig) getFile() interface{} {
1422	return config.PNGSticker
1423}
1424
1425func (config UploadStickerConfig) useExistingFile() bool {
1426	_, ok := config.PNGSticker.(string)
1427
1428	return ok
1429}
1430
1431// NewStickerSetConfig allows creating a new sticker set.
1432//
1433// You must set either PNGSticker or TGSSticker.
1434type NewStickerSetConfig struct {
1435	UserID        int64
1436	Name          string
1437	Title         string
1438	PNGSticker    interface{}
1439	TGSSticker    interface{}
1440	Emojis        string
1441	ContainsMasks bool
1442	MaskPosition  *MaskPosition
1443}
1444
1445func (config NewStickerSetConfig) method() string {
1446	return "createNewStickerSet"
1447}
1448
1449func (config NewStickerSetConfig) params() (Params, error) {
1450	params := make(Params)
1451
1452	params.AddNonZero64("user_id", config.UserID)
1453	params["name"] = config.Name
1454	params["title"] = config.Title
1455
1456	if sticker, ok := config.PNGSticker.(string); ok {
1457		params[config.name()] = sticker
1458	} else if sticker, ok := config.TGSSticker.(string); ok {
1459		params[config.name()] = sticker
1460	}
1461
1462	params["emojis"] = config.Emojis
1463
1464	params.AddBool("contains_masks", config.ContainsMasks)
1465
1466	err := params.AddInterface("mask_position", config.MaskPosition)
1467
1468	return params, err
1469}
1470
1471func (config NewStickerSetConfig) getFile() interface{} {
1472	return config.PNGSticker
1473}
1474
1475func (config NewStickerSetConfig) name() string {
1476	return "png_sticker"
1477}
1478
1479func (config NewStickerSetConfig) useExistingFile() bool {
1480	if config.PNGSticker != nil {
1481		_, ok := config.PNGSticker.(string)
1482		return ok
1483	}
1484
1485	if config.TGSSticker != nil {
1486		_, ok := config.TGSSticker.(string)
1487		return ok
1488	}
1489
1490	panic("NewStickerSetConfig had nil PNGSticker and TGSSticker")
1491}
1492
1493// AddStickerConfig allows you to add a sticker to a set.
1494type AddStickerConfig struct {
1495	UserID       int64
1496	Name         string
1497	PNGSticker   interface{}
1498	TGSSticker   interface{}
1499	Emojis       string
1500	MaskPosition *MaskPosition
1501}
1502
1503func (config AddStickerConfig) method() string {
1504	return "addStickerToSet"
1505}
1506
1507func (config AddStickerConfig) params() (Params, error) {
1508	params := make(Params)
1509
1510	params.AddNonZero64("user_id", config.UserID)
1511	params["name"] = config.Name
1512	params["emojis"] = config.Emojis
1513
1514	if sticker, ok := config.PNGSticker.(string); ok {
1515		params[config.name()] = sticker
1516	} else if sticker, ok := config.TGSSticker.(string); ok {
1517		params[config.name()] = sticker
1518	}
1519
1520	err := params.AddInterface("mask_position", config.MaskPosition)
1521
1522	return params, err
1523}
1524
1525func (config AddStickerConfig) name() string {
1526	return "png_sticker"
1527}
1528
1529func (config AddStickerConfig) getFile() interface{} {
1530	return config.PNGSticker
1531}
1532
1533func (config AddStickerConfig) useExistingFile() bool {
1534	_, ok := config.PNGSticker.(string)
1535
1536	return ok
1537}
1538
1539// SetStickerPositionConfig allows you to change the position of a sticker in a set.
1540type SetStickerPositionConfig struct {
1541	Sticker  string
1542	Position int
1543}
1544
1545func (config SetStickerPositionConfig) method() string {
1546	return "setStickerPositionInSet"
1547}
1548
1549func (config SetStickerPositionConfig) params() (Params, error) {
1550	params := make(Params)
1551
1552	params["sticker"] = config.Sticker
1553	params.AddNonZero("position", config.Position)
1554
1555	return params, nil
1556}
1557
1558// DeleteStickerConfig allows you to delete a sticker from a set.
1559type DeleteStickerConfig struct {
1560	Sticker string
1561}
1562
1563func (config DeleteStickerConfig) method() string {
1564	return "deleteStickerFromSet"
1565}
1566
1567func (config DeleteStickerConfig) params() (Params, error) {
1568	params := make(Params)
1569
1570	params["sticker"] = config.Sticker
1571
1572	return params, nil
1573}
1574
1575// SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
1576type SetStickerSetThumbConfig struct {
1577	Name   string
1578	UserID int
1579	Thumb  interface{}
1580}
1581
1582func (config SetStickerSetThumbConfig) method() string {
1583	return "setStickerSetThumb"
1584}
1585
1586func (config SetStickerSetThumbConfig) params() (Params, error) {
1587	params := make(Params)
1588
1589	params["name"] = config.Name
1590	params.AddNonZero("user_id", config.UserID)
1591
1592	if thumb, ok := config.Thumb.(string); ok {
1593		params["thumb"] = thumb
1594	}
1595
1596	return params, nil
1597}
1598
1599func (config SetStickerSetThumbConfig) name() string {
1600	return "thumb"
1601}
1602
1603func (config SetStickerSetThumbConfig) getFile() interface{} {
1604	return config.Thumb
1605}
1606
1607func (config SetStickerSetThumbConfig) useExistingFile() bool {
1608	_, ok := config.Thumb.(string)
1609	return ok
1610}
1611
1612// SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
1613type SetChatStickerSetConfig struct {
1614	ChatID             int64
1615	SuperGroupUsername string
1616
1617	StickerSetName string
1618}
1619
1620func (config SetChatStickerSetConfig) method() string {
1621	return "setChatStickerSet"
1622}
1623
1624func (config SetChatStickerSetConfig) params() (Params, error) {
1625	params := make(Params)
1626
1627	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1628	params["sticker_set_name"] = config.StickerSetName
1629
1630	return params, nil
1631}
1632
1633// DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
1634type DeleteChatStickerSetConfig struct {
1635	ChatID             int64
1636	SuperGroupUsername string
1637}
1638
1639func (config DeleteChatStickerSetConfig) method() string {
1640	return "deleteChatStickerSet"
1641}
1642
1643func (config DeleteChatStickerSetConfig) params() (Params, error) {
1644	params := make(Params)
1645
1646	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1647
1648	return params, nil
1649}
1650
1651// MediaGroupConfig allows you to send a group of media.
1652//
1653// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
1654type MediaGroupConfig struct {
1655	ChatID          int64
1656	ChannelUsername string
1657
1658	Media               []interface{}
1659	DisableNotification bool
1660	ReplyToMessageID    int
1661}
1662
1663func (config MediaGroupConfig) method() string {
1664	return "sendMediaGroup"
1665}
1666
1667func (config MediaGroupConfig) params() (Params, error) {
1668	params := make(Params)
1669
1670	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1671	if err := params.AddInterface("media", config.Media); err != nil {
1672		return params, nil
1673	}
1674	params.AddBool("disable_notification", config.DisableNotification)
1675	params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
1676
1677	return params, nil
1678}
1679
1680// DiceConfig allows you to send a random dice roll to Telegram.
1681type DiceConfig struct {
1682	BaseChat
1683
1684	Emoji string
1685}
1686
1687func (config DiceConfig) method() string {
1688	return "sendDice"
1689}
1690
1691func (config DiceConfig) params() (Params, error) {
1692	params, err := config.BaseChat.params()
1693	if err != nil {
1694		return params, err
1695	}
1696
1697	params.AddNonEmpty("emoji", config.Emoji)
1698
1699	return params, err
1700}
1701
1702// GetMyCommandsConfig gets a list of the currently registered commands.
1703type GetMyCommandsConfig struct{}
1704
1705func (config GetMyCommandsConfig) method() string {
1706	return "getMyCommands"
1707}
1708
1709func (config GetMyCommandsConfig) params() (Params, error) {
1710	return make(Params), nil
1711}
1712
1713// SetMyCommandsConfig sets a list of commands the bot understands.
1714type SetMyCommandsConfig struct {
1715	commands []BotCommand
1716}
1717
1718func (config SetMyCommandsConfig) method() string {
1719	return "setMyCommands"
1720}
1721
1722func (config SetMyCommandsConfig) params() (Params, error) {
1723	params := make(Params)
1724
1725	err := params.AddInterface("commands", config.commands)
1726
1727	return params, err
1728}