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 "deleteWebhook"
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 err := params.AddInterface("results", config.Results)
882
883 return params, err
884}
885
886// CallbackConfig contains information on making a CallbackQuery response.
887type CallbackConfig struct {
888 CallbackQueryID string `json:"callback_query_id"`
889 Text string `json:"text"`
890 ShowAlert bool `json:"show_alert"`
891 URL string `json:"url"`
892 CacheTime int `json:"cache_time"`
893}
894
895func (config CallbackConfig) method() string {
896 return "answerCallbackQuery"
897}
898
899func (config CallbackConfig) params() (Params, error) {
900 params := make(Params)
901
902 params["callback_query_id"] = config.CallbackQueryID
903 params.AddNonEmpty("text", config.Text)
904 params.AddBool("show_alert", config.ShowAlert)
905 params.AddNonEmpty("url", config.URL)
906 params.AddNonZero("cache_time", config.CacheTime)
907
908 return params, nil
909}
910
911// ChatMemberConfig contains information about a user in a chat for use
912// with administrative functions such as kicking or unbanning a user.
913type ChatMemberConfig struct {
914 ChatID int64
915 SuperGroupUsername string
916 ChannelUsername string
917 UserID int
918}
919
920// UnbanChatMemberConfig allows you to unban a user.
921type UnbanChatMemberConfig struct {
922 ChatMemberConfig
923}
924
925func (config UnbanChatMemberConfig) method() string {
926 return "unbanChatMember"
927}
928
929func (config UnbanChatMemberConfig) params() (Params, error) {
930 params := make(Params)
931
932 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
933 params.AddNonZero("user_id", config.UserID)
934
935 return params, nil
936}
937
938// KickChatMemberConfig contains extra fields to kick user
939type KickChatMemberConfig struct {
940 ChatMemberConfig
941 UntilDate int64
942}
943
944func (config KickChatMemberConfig) method() string {
945 return "kickChatMember"
946}
947
948func (config KickChatMemberConfig) params() (Params, error) {
949 params := make(Params)
950
951 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
952 params.AddNonZero("user_id", config.UserID)
953 params.AddNonZero64("until_date", config.UntilDate)
954
955 return params, nil
956}
957
958// RestrictChatMemberConfig contains fields to restrict members of chat
959type RestrictChatMemberConfig struct {
960 ChatMemberConfig
961 UntilDate int64
962 Permissions *ChatPermissions
963}
964
965func (config RestrictChatMemberConfig) method() string {
966 return "restrictChatMember"
967}
968
969func (config RestrictChatMemberConfig) params() (Params, error) {
970 params := make(Params)
971
972 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
973 params.AddNonZero("user_id", config.UserID)
974
975 err := params.AddInterface("permissions", config.Permissions)
976 params.AddNonZero64("until_date", config.UntilDate)
977
978 return params, err
979}
980
981// PromoteChatMemberConfig contains fields to promote members of chat
982type PromoteChatMemberConfig struct {
983 ChatMemberConfig
984 CanChangeInfo bool
985 CanPostMessages bool
986 CanEditMessages bool
987 CanDeleteMessages bool
988 CanInviteUsers bool
989 CanRestrictMembers bool
990 CanPinMessages bool
991 CanPromoteMembers bool
992}
993
994func (config PromoteChatMemberConfig) method() string {
995 return "promoteChatMember"
996}
997
998func (config PromoteChatMemberConfig) params() (Params, error) {
999 params := make(Params)
1000
1001 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1002 params.AddNonZero("user_id", config.UserID)
1003
1004 params.AddBool("can_change_info", config.CanChangeInfo)
1005 params.AddBool("can_post_messages", config.CanPostMessages)
1006 params.AddBool("can_edit_messages", config.CanEditMessages)
1007 params.AddBool("can_delete_messages", config.CanDeleteMessages)
1008 params.AddBool("can_invite_users", config.CanInviteUsers)
1009 params.AddBool("can_restrict_members", config.CanRestrictMembers)
1010 params.AddBool("can_pin_messages", config.CanPinMessages)
1011 params.AddBool("can_promote_members", config.CanPromoteMembers)
1012
1013 return params, nil
1014}
1015
1016// SetChatAdministratorCustomTitle sets the title of an administrative user
1017// promoted by the bot for a chat.
1018type SetChatAdministratorCustomTitle struct {
1019 ChatMemberConfig
1020 CustomTitle string
1021}
1022
1023func (SetChatAdministratorCustomTitle) method() string {
1024 return "setChatAdministratorCustomTitle"
1025}
1026
1027func (config SetChatAdministratorCustomTitle) params() (Params, error) {
1028 params := make(Params)
1029
1030 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
1031 params.AddNonZero("user_id", config.UserID)
1032 params.AddNonEmpty("custom_title", config.CustomTitle)
1033
1034 return params, nil
1035}
1036
1037// ChatConfig contains information about getting information on a chat.
1038type ChatConfig struct {
1039 ChatID int64
1040 SuperGroupUsername string
1041}
1042
1043func (config ChatConfig) params() (Params, error) {
1044 params := make(Params)
1045
1046 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1047
1048 return params, nil
1049}
1050
1051// ChatInfoConfig contains information about getting chat information.
1052type ChatInfoConfig struct {
1053 ChatConfig
1054}
1055
1056func (ChatInfoConfig) method() string {
1057 return "getChat"
1058}
1059
1060// ChatMemberCountConfig contains information about getting the number of users in a chat.
1061type ChatMemberCountConfig struct {
1062 ChatConfig
1063}
1064
1065func (ChatMemberCountConfig) method() string {
1066 return "getChatMembersCount"
1067}
1068
1069// ChatAdministratorsConfig contains information about getting chat administrators.
1070type ChatAdministratorsConfig struct {
1071 ChatConfig
1072}
1073
1074func (ChatAdministratorsConfig) method() string {
1075 return "getChatAdministrators"
1076}
1077
1078// SetChatPermissionsConfig allows you to set default permissions for the
1079// members in a group. The bot must be an administrator and have rights to
1080// restrict members.
1081type SetChatPermissionsConfig struct {
1082 ChatConfig
1083 Permissions *ChatPermissions
1084}
1085
1086func (SetChatPermissionsConfig) method() string {
1087 return "setChatPermissions"
1088}
1089
1090func (config SetChatPermissionsConfig) params() (Params, error) {
1091 params := make(Params)
1092
1093 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1094 params.AddInterface("permissions", config.Permissions)
1095
1096 return params, nil
1097}
1098
1099// ChatInviteLinkConfig contains information about getting a chat link.
1100//
1101// Note that generating a new link will revoke any previous links.
1102type ChatInviteLinkConfig struct {
1103 ChatConfig
1104}
1105
1106func (ChatInviteLinkConfig) method() string {
1107 return "exportChatInviteLink"
1108}
1109
1110func (config ChatInviteLinkConfig) params() (Params, error) {
1111 params := make(Params)
1112
1113 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1114
1115 return params, nil
1116}
1117
1118// LeaveChatConfig allows you to leave a chat.
1119type LeaveChatConfig struct {
1120 ChatID int64
1121 ChannelUsername string
1122}
1123
1124func (config LeaveChatConfig) method() string {
1125 return "leaveChat"
1126}
1127
1128func (config LeaveChatConfig) params() (Params, error) {
1129 params := make(Params)
1130
1131 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1132
1133 return params, nil
1134}
1135
1136// ChatConfigWithUser contains information about a chat and a user.
1137type ChatConfigWithUser struct {
1138 ChatID int64
1139 SuperGroupUsername string
1140 UserID int
1141}
1142
1143func (config ChatConfigWithUser) params() (Params, error) {
1144 params := make(Params)
1145
1146 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1147 params.AddNonZero("user_id", config.UserID)
1148
1149 return params, nil
1150}
1151
1152// GetChatMemberConfig is information about getting a specific member in a chat.
1153type GetChatMemberConfig struct {
1154 ChatConfigWithUser
1155}
1156
1157func (GetChatMemberConfig) method() string {
1158 return "getChatMember"
1159}
1160
1161// InvoiceConfig contains information for sendInvoice request.
1162type InvoiceConfig struct {
1163 BaseChat
1164 Title string // required
1165 Description string // required
1166 Payload string // required
1167 ProviderToken string // required
1168 StartParameter string // required
1169 Currency string // required
1170 Prices []LabeledPrice // required
1171 ProviderData string
1172 PhotoURL string
1173 PhotoSize int
1174 PhotoWidth int
1175 PhotoHeight int
1176 NeedName bool
1177 NeedPhoneNumber bool
1178 NeedEmail bool
1179 NeedShippingAddress bool
1180 SendPhoneNumberToProvider bool
1181 SendEmailToProvider bool
1182 IsFlexible bool
1183}
1184
1185func (config InvoiceConfig) params() (Params, error) {
1186 params, err := config.BaseChat.params()
1187 if err != nil {
1188 return params, err
1189 }
1190
1191 params["title"] = config.Title
1192 params["description"] = config.Description
1193 params["payload"] = config.Payload
1194 params["provider_token"] = config.ProviderToken
1195 params["start_parameter"] = config.StartParameter
1196 params["currency"] = config.Currency
1197
1198 err = params.AddInterface("prices", config.Prices)
1199 params.AddNonEmpty("provider_data", config.ProviderData)
1200 params.AddNonEmpty("photo_url", config.PhotoURL)
1201 params.AddNonZero("photo_size", config.PhotoSize)
1202 params.AddNonZero("photo_width", config.PhotoWidth)
1203 params.AddNonZero("photo_height", config.PhotoHeight)
1204 params.AddBool("need_name", config.NeedName)
1205 params.AddBool("need_phone_number", config.NeedPhoneNumber)
1206 params.AddBool("need_email", config.NeedEmail)
1207 params.AddBool("need_shipping_address", config.NeedShippingAddress)
1208 params.AddBool("is_flexible", config.IsFlexible)
1209 params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider)
1210 params.AddBool("send_email_to_provider", config.SendEmailToProvider)
1211
1212 return params, err
1213}
1214
1215func (config InvoiceConfig) method() string {
1216 return "sendInvoice"
1217}
1218
1219// ShippingConfig contains information for answerShippingQuery request.
1220type ShippingConfig struct {
1221 ShippingQueryID string // required
1222 OK bool // required
1223 ShippingOptions []ShippingOption
1224 ErrorMessage string
1225}
1226
1227func (config ShippingConfig) method() string {
1228 return "answerShippingQuery"
1229}
1230
1231func (config ShippingConfig) params() (Params, error) {
1232 params := make(Params)
1233
1234 params["shipping_query_id"] = config.ShippingQueryID
1235 params.AddBool("ok", config.OK)
1236 err := params.AddInterface("shipping_options", config.ShippingOptions)
1237 params.AddNonEmpty("error_message", config.ErrorMessage)
1238
1239 return params, err
1240}
1241
1242// PreCheckoutConfig conatins information for answerPreCheckoutQuery request.
1243type PreCheckoutConfig struct {
1244 PreCheckoutQueryID string // required
1245 OK bool // required
1246 ErrorMessage string
1247}
1248
1249func (config PreCheckoutConfig) method() string {
1250 return "answerPreCheckoutQuery"
1251}
1252
1253func (config PreCheckoutConfig) params() (Params, error) {
1254 params := make(Params)
1255
1256 params["pre_checkout_query_id"] = config.PreCheckoutQueryID
1257 params.AddBool("ok", config.OK)
1258 params.AddNonEmpty("error_message", config.ErrorMessage)
1259
1260 return params, nil
1261}
1262
1263// DeleteMessageConfig contains information of a message in a chat to delete.
1264type DeleteMessageConfig struct {
1265 ChannelUsername string
1266 ChatID int64
1267 MessageID int
1268}
1269
1270func (config DeleteMessageConfig) method() string {
1271 return "deleteMessage"
1272}
1273
1274func (config DeleteMessageConfig) 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
1280 return params, nil
1281}
1282
1283// PinChatMessageConfig contains information of a message in a chat to pin.
1284type PinChatMessageConfig struct {
1285 ChatID int64
1286 ChannelUsername string
1287 MessageID int
1288 DisableNotification bool
1289}
1290
1291func (config PinChatMessageConfig) method() string {
1292 return "pinChatMessage"
1293}
1294
1295func (config PinChatMessageConfig) params() (Params, error) {
1296 params := make(Params)
1297
1298 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1299 params.AddNonZero("message_id", config.MessageID)
1300 params.AddBool("disable_notification", config.DisableNotification)
1301
1302 return params, nil
1303}
1304
1305// UnpinChatMessageConfig contains information of chat to unpin.
1306type UnpinChatMessageConfig struct {
1307 ChatID int64
1308 ChannelUsername string
1309}
1310
1311func (config UnpinChatMessageConfig) method() string {
1312 return "unpinChatMessage"
1313}
1314
1315func (config UnpinChatMessageConfig) params() (Params, error) {
1316 params := make(Params)
1317
1318 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1319
1320 return params, nil
1321}
1322
1323// SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
1324type SetChatPhotoConfig struct {
1325 BaseFile
1326}
1327
1328func (config SetChatPhotoConfig) method() string {
1329 return "setChatPhoto"
1330}
1331
1332func (config SetChatPhotoConfig) name() string {
1333 return "photo"
1334}
1335
1336func (config SetChatPhotoConfig) getFile() interface{} {
1337 return config.File
1338}
1339
1340func (config SetChatPhotoConfig) useExistingFile() bool {
1341 return config.UseExisting
1342}
1343
1344// DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
1345type DeleteChatPhotoConfig struct {
1346 ChatID int64
1347 ChannelUsername string
1348}
1349
1350func (config DeleteChatPhotoConfig) method() string {
1351 return "deleteChatPhoto"
1352}
1353
1354func (config DeleteChatPhotoConfig) params() (Params, error) {
1355 params := make(Params)
1356
1357 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1358
1359 return params, nil
1360}
1361
1362// SetChatTitleConfig allows you to set the title of something other than a private chat.
1363type SetChatTitleConfig struct {
1364 ChatID int64
1365 ChannelUsername string
1366
1367 Title string
1368}
1369
1370func (config SetChatTitleConfig) method() string {
1371 return "setChatTitle"
1372}
1373
1374func (config SetChatTitleConfig) params() (Params, error) {
1375 params := make(Params)
1376
1377 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1378 params["title"] = config.Title
1379
1380 return params, nil
1381}
1382
1383// SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
1384type SetChatDescriptionConfig struct {
1385 ChatID int64
1386 ChannelUsername string
1387
1388 Description string
1389}
1390
1391func (config SetChatDescriptionConfig) method() string {
1392 return "setChatDescription"
1393}
1394
1395func (config SetChatDescriptionConfig) params() (Params, error) {
1396 params := make(Params)
1397
1398 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1399 params["description"] = config.Description
1400
1401 return params, nil
1402}
1403
1404// GetStickerSetConfig allows you to get the stickers in a set.
1405type GetStickerSetConfig struct {
1406 Name string
1407}
1408
1409func (config GetStickerSetConfig) method() string {
1410 return "getStickerSet"
1411}
1412
1413func (config GetStickerSetConfig) params() (Params, error) {
1414 params := make(Params)
1415
1416 params["name"] = config.Name
1417
1418 return params, nil
1419}
1420
1421// UploadStickerConfig allows you to upload a sticker for use in a set later.
1422type UploadStickerConfig struct {
1423 UserID int64
1424 PNGSticker interface{}
1425}
1426
1427func (config UploadStickerConfig) method() string {
1428 return "uploadStickerFile"
1429}
1430
1431func (config UploadStickerConfig) params() (Params, error) {
1432 params := make(Params)
1433
1434 params.AddNonZero64("user_id", config.UserID)
1435
1436 return params, nil
1437}
1438
1439func (config UploadStickerConfig) name() string {
1440 return "png_sticker"
1441}
1442
1443func (config UploadStickerConfig) getFile() interface{} {
1444 return config.PNGSticker
1445}
1446
1447func (config UploadStickerConfig) useExistingFile() bool {
1448 _, ok := config.PNGSticker.(string)
1449
1450 return ok
1451}
1452
1453// NewStickerSetConfig allows creating a new sticker set.
1454//
1455// You must set either PNGSticker or TGSSticker.
1456type NewStickerSetConfig struct {
1457 UserID int64
1458 Name string
1459 Title string
1460 PNGSticker interface{}
1461 TGSSticker interface{}
1462 Emojis string
1463 ContainsMasks bool
1464 MaskPosition *MaskPosition
1465}
1466
1467func (config NewStickerSetConfig) method() string {
1468 return "createNewStickerSet"
1469}
1470
1471func (config NewStickerSetConfig) params() (Params, error) {
1472 params := make(Params)
1473
1474 params.AddNonZero64("user_id", config.UserID)
1475 params["name"] = config.Name
1476 params["title"] = config.Title
1477
1478 if sticker, ok := config.PNGSticker.(string); ok {
1479 params[config.name()] = sticker
1480 } else if sticker, ok := config.TGSSticker.(string); ok {
1481 params[config.name()] = sticker
1482 }
1483
1484 params["emojis"] = config.Emojis
1485
1486 params.AddBool("contains_masks", config.ContainsMasks)
1487
1488 err := params.AddInterface("mask_position", config.MaskPosition)
1489
1490 return params, err
1491}
1492
1493func (config NewStickerSetConfig) getFile() interface{} {
1494 return config.PNGSticker
1495}
1496
1497func (config NewStickerSetConfig) name() string {
1498 return "png_sticker"
1499}
1500
1501func (config NewStickerSetConfig) useExistingFile() bool {
1502 if config.PNGSticker != nil {
1503 _, ok := config.PNGSticker.(string)
1504 return ok
1505 }
1506
1507 if config.TGSSticker != nil {
1508 _, ok := config.TGSSticker.(string)
1509 return ok
1510 }
1511
1512 panic("NewStickerSetConfig had nil PNGSticker and TGSSticker")
1513}
1514
1515// AddStickerConfig allows you to add a sticker to a set.
1516type AddStickerConfig struct {
1517 UserID int64
1518 Name string
1519 PNGSticker interface{}
1520 TGSSticker interface{}
1521 Emojis string
1522 MaskPosition *MaskPosition
1523}
1524
1525func (config AddStickerConfig) method() string {
1526 return "addStickerToSet"
1527}
1528
1529func (config AddStickerConfig) params() (Params, error) {
1530 params := make(Params)
1531
1532 params.AddNonZero64("user_id", config.UserID)
1533 params["name"] = config.Name
1534 params["emojis"] = config.Emojis
1535
1536 if sticker, ok := config.PNGSticker.(string); ok {
1537 params[config.name()] = sticker
1538 } else if sticker, ok := config.TGSSticker.(string); ok {
1539 params[config.name()] = sticker
1540 }
1541
1542 err := params.AddInterface("mask_position", config.MaskPosition)
1543
1544 return params, err
1545}
1546
1547func (config AddStickerConfig) name() string {
1548 return "png_sticker"
1549}
1550
1551func (config AddStickerConfig) getFile() interface{} {
1552 return config.PNGSticker
1553}
1554
1555func (config AddStickerConfig) useExistingFile() bool {
1556 _, ok := config.PNGSticker.(string)
1557
1558 return ok
1559}
1560
1561// SetStickerPositionConfig allows you to change the position of a sticker in a set.
1562type SetStickerPositionConfig struct {
1563 Sticker string
1564 Position int
1565}
1566
1567func (config SetStickerPositionConfig) method() string {
1568 return "setStickerPositionInSet"
1569}
1570
1571func (config SetStickerPositionConfig) params() (Params, error) {
1572 params := make(Params)
1573
1574 params["sticker"] = config.Sticker
1575 params.AddNonZero("position", config.Position)
1576
1577 return params, nil
1578}
1579
1580// DeleteStickerConfig allows you to delete a sticker from a set.
1581type DeleteStickerConfig struct {
1582 Sticker string
1583}
1584
1585func (config DeleteStickerConfig) method() string {
1586 return "deleteStickerFromSet"
1587}
1588
1589func (config DeleteStickerConfig) params() (Params, error) {
1590 params := make(Params)
1591
1592 params["sticker"] = config.Sticker
1593
1594 return params, nil
1595}
1596
1597// SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
1598type SetStickerSetThumbConfig struct {
1599 Name string
1600 UserID int
1601 Thumb interface{}
1602}
1603
1604func (config SetStickerSetThumbConfig) method() string {
1605 return "setStickerSetThumb"
1606}
1607
1608func (config SetStickerSetThumbConfig) params() (Params, error) {
1609 params := make(Params)
1610
1611 params["name"] = config.Name
1612 params.AddNonZero("user_id", config.UserID)
1613
1614 if thumb, ok := config.Thumb.(string); ok {
1615 params["thumb"] = thumb
1616 }
1617
1618 return params, nil
1619}
1620
1621func (config SetStickerSetThumbConfig) name() string {
1622 return "thumb"
1623}
1624
1625func (config SetStickerSetThumbConfig) getFile() interface{} {
1626 return config.Thumb
1627}
1628
1629func (config SetStickerSetThumbConfig) useExistingFile() bool {
1630 _, ok := config.Thumb.(string)
1631 return ok
1632}
1633
1634// SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
1635type SetChatStickerSetConfig struct {
1636 ChatID int64
1637 SuperGroupUsername string
1638
1639 StickerSetName string
1640}
1641
1642func (config SetChatStickerSetConfig) method() string {
1643 return "setChatStickerSet"
1644}
1645
1646func (config SetChatStickerSetConfig) params() (Params, error) {
1647 params := make(Params)
1648
1649 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1650 params["sticker_set_name"] = config.StickerSetName
1651
1652 return params, nil
1653}
1654
1655// DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
1656type DeleteChatStickerSetConfig struct {
1657 ChatID int64
1658 SuperGroupUsername string
1659}
1660
1661func (config DeleteChatStickerSetConfig) method() string {
1662 return "deleteChatStickerSet"
1663}
1664
1665func (config DeleteChatStickerSetConfig) params() (Params, error) {
1666 params := make(Params)
1667
1668 params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1669
1670 return params, nil
1671}
1672
1673// MediaGroupConfig allows you to send a group of media.
1674//
1675// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
1676type MediaGroupConfig struct {
1677 ChatID int64
1678 ChannelUsername string
1679
1680 Media []interface{}
1681 DisableNotification bool
1682 ReplyToMessageID int
1683}
1684
1685func (config MediaGroupConfig) method() string {
1686 return "sendMediaGroup"
1687}
1688
1689func (config MediaGroupConfig) params() (Params, error) {
1690 params := make(Params)
1691
1692 params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
1693 if err := params.AddInterface("media", config.Media); err != nil {
1694 return params, nil
1695 }
1696 params.AddBool("disable_notification", config.DisableNotification)
1697 params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
1698
1699 return params, nil
1700}
1701
1702// GetMyCommandsConfig gets a list of the currently registered commands.
1703type GetMyCommandsConfig struct{}
1704
1705func (config GetMyCommandsConfig) method() string {
1706 return "getMyCommands"
1707}
1708
1709func (config GetMyCommandsConfig) params() (Params, error) {
1710 return nil, nil
1711}
1712
1713// SetMyCommandsConfig sets a list of commands the bot understands.
1714type SetMyCommandsConfig struct {
1715 commands []BotCommand
1716}
1717
1718func (config SetMyCommandsConfig) method() string {
1719 return "setMyCommands"
1720}
1721
1722func (config SetMyCommandsConfig) params() (Params, error) {
1723 params := make(Params)
1724
1725 err := params.AddInterface("commands", config.commands)
1726
1727 return params, err
1728}
1729
1730// DiceConfig contains information about a sendDice request.
1731type DiceConfig struct {
1732 BaseChat
1733 // Emoji on which the dice throw animation is based.
1734 // Currently, must be one of “🎲”, “🎯”, or “🏀”.
1735 // Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”.
1736 // Defaults to “🎲”
1737 Emoji string
1738}
1739
1740func (config DiceConfig) method() string {
1741 return "sendDice"
1742}
1743
1744func (config DiceConfig) params() (Params, error) {
1745 params, err := config.BaseChat.params()
1746 if err != nil {
1747 return params, err
1748 }
1749
1750 params.AddNonEmpty("emoji", config.Emoji)
1751
1752 return params, err
1753}