all repos — telegram-bot-api @ 1059fc759ddd50b5380daa671bd34544302fd62d

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	ChannelUsername string
1245	ChatID          int64
1246	MessageID       int
1247}
1248
1249func (config DeleteMessageConfig) method() string {
1250	return "deleteMessage"
1251}
1252
1253func (config DeleteMessageConfig) params() (Params, error) {
1254	params := make(Params)
1255
1256	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1257	params.AddNonZero("message_id", config.MessageID)
1258
1259	return params, nil
1260}
1261
1262// PinChatMessageConfig contains information of a message in a chat to pin.
1263type PinChatMessageConfig struct {
1264	ChatID              int64
1265	ChannelUsername     string
1266	MessageID           int
1267	DisableNotification bool
1268}
1269
1270func (config PinChatMessageConfig) method() string {
1271	return "pinChatMessage"
1272}
1273
1274func (config PinChatMessageConfig) params() (Params, error) {
1275	params := make(Params)
1276
1277	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1278	params.AddNonZero("message_id", config.MessageID)
1279	params.AddBool("disable_notification", config.DisableNotification)
1280
1281	return params, nil
1282}
1283
1284// UnpinChatMessageConfig contains information of chat to unpin.
1285type UnpinChatMessageConfig struct {
1286	ChatID          int64
1287	ChannelUsername string
1288}
1289
1290func (config UnpinChatMessageConfig) method() string {
1291	return "unpinChatMessage"
1292}
1293
1294func (config UnpinChatMessageConfig) params() (Params, error) {
1295	params := make(Params)
1296
1297	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1298
1299	return params, nil
1300}
1301
1302// SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
1303type SetChatPhotoConfig struct {
1304	BaseFile
1305}
1306
1307func (config SetChatPhotoConfig) method() string {
1308	return "setChatPhoto"
1309}
1310
1311func (config SetChatPhotoConfig) name() string {
1312	return "photo"
1313}
1314
1315func (config SetChatPhotoConfig) getFile() interface{} {
1316	return config.File
1317}
1318
1319func (config SetChatPhotoConfig) useExistingFile() bool {
1320	return config.UseExisting
1321}
1322
1323// DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
1324type DeleteChatPhotoConfig struct {
1325	ChatID          int64
1326	ChannelUsername string
1327}
1328
1329func (config DeleteChatPhotoConfig) method() string {
1330	return "deleteChatPhoto"
1331}
1332
1333func (config DeleteChatPhotoConfig) params() (Params, error) {
1334	params := make(Params)
1335
1336	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1337
1338	return params, nil
1339}
1340
1341// SetChatTitleConfig allows you to set the title of something other than a private chat.
1342type SetChatTitleConfig struct {
1343	ChatID          int64
1344	ChannelUsername string
1345
1346	Title string
1347}
1348
1349func (config SetChatTitleConfig) method() string {
1350	return "setChatTitle"
1351}
1352
1353func (config SetChatTitleConfig) params() (Params, error) {
1354	params := make(Params)
1355
1356	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1357	params["title"] = config.Title
1358
1359	return params, nil
1360}
1361
1362// SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
1363type SetChatDescriptionConfig struct {
1364	ChatID          int64
1365	ChannelUsername string
1366
1367	Description string
1368}
1369
1370func (config SetChatDescriptionConfig) method() string {
1371	return "setChatDescription"
1372}
1373
1374func (config SetChatDescriptionConfig) params() (Params, error) {
1375	params := make(Params)
1376
1377	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1378	params["description"] = config.Description
1379
1380	return params, nil
1381}
1382
1383// GetStickerSetConfig allows you to get the stickers in a set.
1384type GetStickerSetConfig struct {
1385	Name string
1386}
1387
1388func (config GetStickerSetConfig) method() string {
1389	return "getStickerSet"
1390}
1391
1392func (config GetStickerSetConfig) params() (Params, error) {
1393	params := make(Params)
1394
1395	params["name"] = config.Name
1396
1397	return params, nil
1398}
1399
1400// UploadStickerConfig allows you to upload a sticker for use in a set later.
1401type UploadStickerConfig struct {
1402	UserID     int64
1403	PNGSticker interface{}
1404}
1405
1406func (config UploadStickerConfig) method() string {
1407	return "uploadStickerFile"
1408}
1409
1410func (config UploadStickerConfig) params() (Params, error) {
1411	params := make(Params)
1412
1413	params.AddNonZero64("user_id", config.UserID)
1414
1415	return params, nil
1416}
1417
1418func (config UploadStickerConfig) name() string {
1419	return "png_sticker"
1420}
1421
1422func (config UploadStickerConfig) getFile() interface{} {
1423	return config.PNGSticker
1424}
1425
1426func (config UploadStickerConfig) useExistingFile() bool {
1427	_, ok := config.PNGSticker.(string)
1428
1429	return ok
1430}
1431
1432// NewStickerSetConfig allows creating a new sticker set.
1433//
1434// You must set either PNGSticker or TGSSticker.
1435type NewStickerSetConfig struct {
1436	UserID        int64
1437	Name          string
1438	Title         string
1439	PNGSticker    interface{}
1440	TGSSticker    interface{}
1441	Emojis        string
1442	ContainsMasks bool
1443	MaskPosition  *MaskPosition
1444}
1445
1446func (config NewStickerSetConfig) method() string {
1447	return "createNewStickerSet"
1448}
1449
1450func (config NewStickerSetConfig) params() (Params, error) {
1451	params := make(Params)
1452
1453	params.AddNonZero64("user_id", config.UserID)
1454	params["name"] = config.Name
1455	params["title"] = config.Title
1456
1457	if sticker, ok := config.PNGSticker.(string); ok {
1458		params[config.name()] = sticker
1459	} else if sticker, ok := config.TGSSticker.(string); ok {
1460		params[config.name()] = sticker
1461	}
1462
1463	params["emojis"] = config.Emojis
1464
1465	params.AddBool("contains_masks", config.ContainsMasks)
1466
1467	err := params.AddInterface("mask_position", config.MaskPosition)
1468
1469	return params, err
1470}
1471
1472func (config NewStickerSetConfig) getFile() interface{} {
1473	return config.PNGSticker
1474}
1475
1476func (config NewStickerSetConfig) name() string {
1477	return "png_sticker"
1478}
1479
1480func (config NewStickerSetConfig) useExistingFile() bool {
1481	if config.PNGSticker != nil {
1482		_, ok := config.PNGSticker.(string)
1483		return ok
1484	}
1485
1486	if config.TGSSticker != nil {
1487		_, ok := config.TGSSticker.(string)
1488		return ok
1489	}
1490
1491	panic("NewStickerSetConfig had nil PNGSticker and TGSSticker")
1492}
1493
1494// AddStickerConfig allows you to add a sticker to a set.
1495type AddStickerConfig struct {
1496	UserID       int64
1497	Name         string
1498	PNGSticker   interface{}
1499	TGSSticker   interface{}
1500	Emojis       string
1501	MaskPosition *MaskPosition
1502}
1503
1504func (config AddStickerConfig) method() string {
1505	return "addStickerToSet"
1506}
1507
1508func (config AddStickerConfig) params() (Params, error) {
1509	params := make(Params)
1510
1511	params.AddNonZero64("user_id", config.UserID)
1512	params["name"] = config.Name
1513	params["emojis"] = config.Emojis
1514
1515	if sticker, ok := config.PNGSticker.(string); ok {
1516		params[config.name()] = sticker
1517	} else if sticker, ok := config.TGSSticker.(string); ok {
1518		params[config.name()] = sticker
1519	}
1520
1521	err := params.AddInterface("mask_position", config.MaskPosition)
1522
1523	return params, err
1524}
1525
1526func (config AddStickerConfig) name() string {
1527	return "png_sticker"
1528}
1529
1530func (config AddStickerConfig) getFile() interface{} {
1531	return config.PNGSticker
1532}
1533
1534func (config AddStickerConfig) useExistingFile() bool {
1535	_, ok := config.PNGSticker.(string)
1536
1537	return ok
1538}
1539
1540// SetStickerPositionConfig allows you to change the position of a sticker in a set.
1541type SetStickerPositionConfig struct {
1542	Sticker  string
1543	Position int
1544}
1545
1546func (config SetStickerPositionConfig) method() string {
1547	return "setStickerPositionInSet"
1548}
1549
1550func (config SetStickerPositionConfig) params() (Params, error) {
1551	params := make(Params)
1552
1553	params["sticker"] = config.Sticker
1554	params.AddNonZero("position", config.Position)
1555
1556	return params, nil
1557}
1558
1559// DeleteStickerConfig allows you to delete a sticker from a set.
1560type DeleteStickerConfig struct {
1561	Sticker string
1562}
1563
1564func (config DeleteStickerConfig) method() string {
1565	return "deleteStickerFromSet"
1566}
1567
1568func (config DeleteStickerConfig) params() (Params, error) {
1569	params := make(Params)
1570
1571	params["sticker"] = config.Sticker
1572
1573	return params, nil
1574}
1575
1576// SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
1577type SetStickerSetThumbConfig struct {
1578	Name   string
1579	UserID int
1580	Thumb  interface{}
1581}
1582
1583func (config SetStickerSetThumbConfig) method() string {
1584	return "setStickerSetThumb"
1585}
1586
1587func (config SetStickerSetThumbConfig) params() (Params, error) {
1588	params := make(Params)
1589
1590	params["name"] = config.Name
1591	params.AddNonZero("user_id", config.UserID)
1592
1593	if thumb, ok := config.Thumb.(string); ok {
1594		params["thumb"] = thumb
1595	}
1596
1597	return params, nil
1598}
1599
1600func (config SetStickerSetThumbConfig) name() string {
1601	return "thumb"
1602}
1603
1604func (config SetStickerSetThumbConfig) getFile() interface{} {
1605	return config.Thumb
1606}
1607
1608func (config SetStickerSetThumbConfig) useExistingFile() bool {
1609	_, ok := config.Thumb.(string)
1610	return ok
1611}
1612
1613// SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
1614type SetChatStickerSetConfig struct {
1615	ChatID             int64
1616	SuperGroupUsername string
1617
1618	StickerSetName string
1619}
1620
1621func (config SetChatStickerSetConfig) method() string {
1622	return "setChatStickerSet"
1623}
1624
1625func (config SetChatStickerSetConfig) params() (Params, error) {
1626	params := make(Params)
1627
1628	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1629	params["sticker_set_name"] = config.StickerSetName
1630
1631	return params, nil
1632}
1633
1634// DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
1635type DeleteChatStickerSetConfig struct {
1636	ChatID             int64
1637	SuperGroupUsername string
1638}
1639
1640func (config DeleteChatStickerSetConfig) method() string {
1641	return "deleteChatStickerSet"
1642}
1643
1644func (config DeleteChatStickerSetConfig) params() (Params, error) {
1645	params := make(Params)
1646
1647	params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1648
1649	return params, nil
1650}
1651
1652// MediaGroupConfig allows you to send a group of media.
1653//
1654// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
1655type MediaGroupConfig struct {
1656	ChatID          int64
1657	ChannelUsername string
1658
1659	Media               []interface{}
1660	DisableNotification bool
1661	ReplyToMessageID    int
1662}
1663
1664func (config MediaGroupConfig) method() string {
1665	return "sendMediaGroup"
1666}
1667
1668func (config MediaGroupConfig) params() (Params, error) {
1669	params := make(Params)
1670
1671	params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1672	if err := params.AddInterface("media", config.Media); err != nil {
1673		return params, nil
1674	}
1675	params.AddBool("disable_notification", config.DisableNotification)
1676	params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
1677
1678	return params, nil
1679}
1680
1681// DiceConfig allows you to send a random dice roll to Telegram.
1682type DiceConfig struct {
1683	BaseChat
1684
1685	Emoji string
1686}
1687
1688func (config DiceConfig) method() string {
1689	return "sendDice"
1690}
1691
1692func (config DiceConfig) params() (Params, error) {
1693	params, err := config.BaseChat.params()
1694	if err != nil {
1695		return params, err
1696	}
1697
1698	params.AddNonEmpty("emoji", config.Emoji)
1699
1700	return params, err
1701}
1702
1703// GetMyCommandsConfig gets a list of the currently registered commands.
1704type GetMyCommandsConfig struct{}
1705
1706func (config GetMyCommandsConfig) method() string {
1707	return "getMyCommands"
1708}
1709
1710func (config GetMyCommandsConfig) params() (Params, error) {
1711	return make(Params), nil
1712}
1713
1714// SetMyCommandsConfig sets a list of commands the bot understands.
1715type SetMyCommandsConfig struct {
1716	commands []BotCommand
1717}
1718
1719func (config SetMyCommandsConfig) method() string {
1720	return "setMyCommands"
1721}
1722
1723func (config SetMyCommandsConfig) params() (Params, error) {
1724	params := make(Params)
1725
1726	err := params.AddInterface("commands", config.commands)
1727
1728	return params, err
1729}