all repos — telegram-bot-api @ 99b74b8efaa519636cf7f56afed97b65ecafb512

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