-
Notifications
You must be signed in to change notification settings - Fork 120
/
gen_methods.go
executable file
·6978 lines (6183 loc) · 311 KB
/
gen_methods.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
// Regen by running 'go generate' in the repo root.
package gotgbot
import (
"context"
"encoding/json"
"fmt"
"strconv"
)
// AddStickerToSetOpts is the set of optional fields for Bot.AddStickerToSet and Bot.AddStickerToSetWithContext.
type AddStickerToSetOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AddStickerToSet (https://core.telegram.org/bots/api#addstickertoset)
//
// Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success.
// - userId (type int64): User identifier of sticker set owner
// - name (type string): Sticker set name
// - sticker (type InputSticker): A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed.
// - opts (type AddStickerToSetOpts): All optional parameters.
func (bot *Bot) AddStickerToSet(userId int64, name string, sticker InputSticker, opts *AddStickerToSetOpts) (bool, error) {
return bot.AddStickerToSetWithContext(context.Background(), userId, name, sticker, opts)
}
// AddStickerToSetWithContext is the same as Bot.AddStickerToSet, but with a context.Context parameter
func (bot *Bot) AddStickerToSetWithContext(ctx context.Context, userId int64, name string, sticker InputSticker, opts *AddStickerToSetOpts) (bool, error) {
v := map[string]string{}
data := map[string]FileReader{}
v["user_id"] = strconv.FormatInt(userId, 10)
v["name"] = name
inputBs, err := sticker.InputParams("sticker", data)
if err != nil {
return false, fmt.Errorf("failed to marshal field sticker: %w", err)
}
v["sticker"] = string(inputBs)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "addStickerToSet", v, data, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// AnswerCallbackQueryOpts is the set of optional fields for Bot.AnswerCallbackQuery and Bot.AnswerCallbackQueryWithContext.
type AnswerCallbackQueryOpts struct {
// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
Text string
// If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
ShowAlert bool
// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
Url string
// The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
CacheTime int64
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AnswerCallbackQuery (https://core.telegram.org/bots/api#answercallbackquery)
//
// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
// - callbackQueryId (type string): Unique identifier for the query to be answered
// - opts (type AnswerCallbackQueryOpts): All optional parameters.
func (bot *Bot) AnswerCallbackQuery(callbackQueryId string, opts *AnswerCallbackQueryOpts) (bool, error) {
return bot.AnswerCallbackQueryWithContext(context.Background(), callbackQueryId, opts)
}
// AnswerCallbackQueryWithContext is the same as Bot.AnswerCallbackQuery, but with a context.Context parameter
func (bot *Bot) AnswerCallbackQueryWithContext(ctx context.Context, callbackQueryId string, opts *AnswerCallbackQueryOpts) (bool, error) {
v := map[string]string{}
v["callback_query_id"] = callbackQueryId
if opts != nil {
v["text"] = opts.Text
v["show_alert"] = strconv.FormatBool(opts.ShowAlert)
v["url"] = opts.Url
if opts.CacheTime != 0 {
v["cache_time"] = strconv.FormatInt(opts.CacheTime, 10)
}
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "answerCallbackQuery", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// AnswerInlineQueryOpts is the set of optional fields for Bot.AnswerInlineQuery and Bot.AnswerInlineQueryWithContext.
type AnswerInlineQueryOpts struct {
// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
CacheTime int64
// Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.
IsPersonal bool
// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
NextOffset string
// A JSON-serialized object describing a button to be shown above inline query results
Button *InlineQueryResultsButton
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AnswerInlineQuery (https://core.telegram.org/bots/api#answerinlinequery)
//
// Use this method to send answers to an inline query. On success, True is returned.
// No more than 50 results per query are allowed.
// - inlineQueryId (type string): Unique identifier for the answered query
// - results (type []InlineQueryResult): A JSON-serialized array of results for the inline query
// - opts (type AnswerInlineQueryOpts): All optional parameters.
func (bot *Bot) AnswerInlineQuery(inlineQueryId string, results []InlineQueryResult, opts *AnswerInlineQueryOpts) (bool, error) {
return bot.AnswerInlineQueryWithContext(context.Background(), inlineQueryId, results, opts)
}
// AnswerInlineQueryWithContext is the same as Bot.AnswerInlineQuery, but with a context.Context parameter
func (bot *Bot) AnswerInlineQueryWithContext(ctx context.Context, inlineQueryId string, results []InlineQueryResult, opts *AnswerInlineQueryOpts) (bool, error) {
v := map[string]string{}
v["inline_query_id"] = inlineQueryId
if results != nil {
bs, err := json.Marshal(results)
if err != nil {
return false, fmt.Errorf("failed to marshal field results: %w", err)
}
v["results"] = string(bs)
}
if opts != nil {
if opts.CacheTime != 0 {
v["cache_time"] = strconv.FormatInt(opts.CacheTime, 10)
}
v["is_personal"] = strconv.FormatBool(opts.IsPersonal)
v["next_offset"] = opts.NextOffset
if opts.Button != nil {
bs, err := json.Marshal(opts.Button)
if err != nil {
return false, fmt.Errorf("failed to marshal field button: %w", err)
}
v["button"] = string(bs)
}
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "answerInlineQuery", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// AnswerPreCheckoutQueryOpts is the set of optional fields for Bot.AnswerPreCheckoutQuery and Bot.AnswerPreCheckoutQueryWithContext.
type AnswerPreCheckoutQueryOpts struct {
// Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
ErrorMessage string
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AnswerPreCheckoutQuery (https://core.telegram.org/bots/api#answerprecheckoutquery)
//
// Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
// - preCheckoutQueryId (type string): Unique identifier for the query to be answered
// - ok (type bool): Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
// - opts (type AnswerPreCheckoutQueryOpts): All optional parameters.
func (bot *Bot) AnswerPreCheckoutQuery(preCheckoutQueryId string, ok bool, opts *AnswerPreCheckoutQueryOpts) (bool, error) {
return bot.AnswerPreCheckoutQueryWithContext(context.Background(), preCheckoutQueryId, ok, opts)
}
// AnswerPreCheckoutQueryWithContext is the same as Bot.AnswerPreCheckoutQuery, but with a context.Context parameter
func (bot *Bot) AnswerPreCheckoutQueryWithContext(ctx context.Context, preCheckoutQueryId string, ok bool, opts *AnswerPreCheckoutQueryOpts) (bool, error) {
v := map[string]string{}
v["pre_checkout_query_id"] = preCheckoutQueryId
v["ok"] = strconv.FormatBool(ok)
if opts != nil {
v["error_message"] = opts.ErrorMessage
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "answerPreCheckoutQuery", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// AnswerShippingQueryOpts is the set of optional fields for Bot.AnswerShippingQuery and Bot.AnswerShippingQueryWithContext.
type AnswerShippingQueryOpts struct {
// Required if ok is True. A JSON-serialized array of available shipping options.
ShippingOptions []ShippingOption
// Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
ErrorMessage string
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AnswerShippingQuery (https://core.telegram.org/bots/api#answershippingquery)
//
// If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
// - shippingQueryId (type string): Unique identifier for the query to be answered
// - ok (type bool): Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
// - opts (type AnswerShippingQueryOpts): All optional parameters.
func (bot *Bot) AnswerShippingQuery(shippingQueryId string, ok bool, opts *AnswerShippingQueryOpts) (bool, error) {
return bot.AnswerShippingQueryWithContext(context.Background(), shippingQueryId, ok, opts)
}
// AnswerShippingQueryWithContext is the same as Bot.AnswerShippingQuery, but with a context.Context parameter
func (bot *Bot) AnswerShippingQueryWithContext(ctx context.Context, shippingQueryId string, ok bool, opts *AnswerShippingQueryOpts) (bool, error) {
v := map[string]string{}
v["shipping_query_id"] = shippingQueryId
v["ok"] = strconv.FormatBool(ok)
if opts != nil {
if opts.ShippingOptions != nil {
bs, err := json.Marshal(opts.ShippingOptions)
if err != nil {
return false, fmt.Errorf("failed to marshal field shipping_options: %w", err)
}
v["shipping_options"] = string(bs)
}
v["error_message"] = opts.ErrorMessage
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "answerShippingQuery", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// AnswerWebAppQueryOpts is the set of optional fields for Bot.AnswerWebAppQuery and Bot.AnswerWebAppQueryWithContext.
type AnswerWebAppQueryOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// AnswerWebAppQuery (https://core.telegram.org/bots/api#answerwebappquery)
//
// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.
// - webAppQueryId (type string): Unique identifier for the query to be answered
// - result (type InlineQueryResult): A JSON-serialized object describing the message to be sent
// - opts (type AnswerWebAppQueryOpts): All optional parameters.
func (bot *Bot) AnswerWebAppQuery(webAppQueryId string, result InlineQueryResult, opts *AnswerWebAppQueryOpts) (*SentWebAppMessage, error) {
return bot.AnswerWebAppQueryWithContext(context.Background(), webAppQueryId, result, opts)
}
// AnswerWebAppQueryWithContext is the same as Bot.AnswerWebAppQuery, but with a context.Context parameter
func (bot *Bot) AnswerWebAppQueryWithContext(ctx context.Context, webAppQueryId string, result InlineQueryResult, opts *AnswerWebAppQueryOpts) (*SentWebAppMessage, error) {
v := map[string]string{}
v["web_app_query_id"] = webAppQueryId
bs, err := json.Marshal(result)
if err != nil {
return nil, fmt.Errorf("failed to marshal field result: %w", err)
}
v["result"] = string(bs)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "answerWebAppQuery", v, nil, reqOpts)
if err != nil {
return nil, err
}
var s SentWebAppMessage
return &s, json.Unmarshal(r, &s)
}
// ApproveChatJoinRequestOpts is the set of optional fields for Bot.ApproveChatJoinRequest and Bot.ApproveChatJoinRequestWithContext.
type ApproveChatJoinRequestOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// ApproveChatJoinRequest (https://core.telegram.org/bots/api#approvechatjoinrequest)
//
// Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
// - chatId (type int64): Unique identifier for the target chat
// - userId (type int64): Unique identifier of the target user
// - opts (type ApproveChatJoinRequestOpts): All optional parameters.
func (bot *Bot) ApproveChatJoinRequest(chatId int64, userId int64, opts *ApproveChatJoinRequestOpts) (bool, error) {
return bot.ApproveChatJoinRequestWithContext(context.Background(), chatId, userId, opts)
}
// ApproveChatJoinRequestWithContext is the same as Bot.ApproveChatJoinRequest, but with a context.Context parameter
func (bot *Bot) ApproveChatJoinRequestWithContext(ctx context.Context, chatId int64, userId int64, opts *ApproveChatJoinRequestOpts) (bool, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["user_id"] = strconv.FormatInt(userId, 10)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "approveChatJoinRequest", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// BanChatMemberOpts is the set of optional fields for Bot.BanChatMember and Bot.BanChatMemberWithContext.
type BanChatMemberOpts struct {
// Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
UntilDate int64
// Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
RevokeMessages bool
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// BanChatMember (https://core.telegram.org/bots/api#banchatmember)
//
// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
// - chatId (type int64): Unique identifier for the target group
// - userId (type int64): Unique identifier of the target user
// - opts (type BanChatMemberOpts): All optional parameters.
func (bot *Bot) BanChatMember(chatId int64, userId int64, opts *BanChatMemberOpts) (bool, error) {
return bot.BanChatMemberWithContext(context.Background(), chatId, userId, opts)
}
// BanChatMemberWithContext is the same as Bot.BanChatMember, but with a context.Context parameter
func (bot *Bot) BanChatMemberWithContext(ctx context.Context, chatId int64, userId int64, opts *BanChatMemberOpts) (bool, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["user_id"] = strconv.FormatInt(userId, 10)
if opts != nil {
if opts.UntilDate != 0 {
v["until_date"] = strconv.FormatInt(opts.UntilDate, 10)
}
v["revoke_messages"] = strconv.FormatBool(opts.RevokeMessages)
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "banChatMember", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// BanChatSenderChatOpts is the set of optional fields for Bot.BanChatSenderChat and Bot.BanChatSenderChatWithContext.
type BanChatSenderChatOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// BanChatSenderChat (https://core.telegram.org/bots/api#banchatsenderchat)
//
// Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.
// - chatId (type int64): Unique identifier for the target chat
// - senderChatId (type int64): Unique identifier of the target sender chat
// - opts (type BanChatSenderChatOpts): All optional parameters.
func (bot *Bot) BanChatSenderChat(chatId int64, senderChatId int64, opts *BanChatSenderChatOpts) (bool, error) {
return bot.BanChatSenderChatWithContext(context.Background(), chatId, senderChatId, opts)
}
// BanChatSenderChatWithContext is the same as Bot.BanChatSenderChat, but with a context.Context parameter
func (bot *Bot) BanChatSenderChatWithContext(ctx context.Context, chatId int64, senderChatId int64, opts *BanChatSenderChatOpts) (bool, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["sender_chat_id"] = strconv.FormatInt(senderChatId, 10)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "banChatSenderChat", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// CloseOpts is the set of optional fields for Bot.Close and Bot.CloseWithContext.
type CloseOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// Close (https://core.telegram.org/bots/api#close)
//
// Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.
// - opts (type CloseOpts): All optional parameters.
func (bot *Bot) Close(opts *CloseOpts) (bool, error) {
return bot.CloseWithContext(context.Background(), opts)
}
// CloseWithContext is the same as Bot.Close, but with a context.Context parameter
func (bot *Bot) CloseWithContext(ctx context.Context, opts *CloseOpts) (bool, error) {
v := map[string]string{}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "close", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// CloseForumTopicOpts is the set of optional fields for Bot.CloseForumTopic and Bot.CloseForumTopicWithContext.
type CloseForumTopicOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CloseForumTopic (https://core.telegram.org/bots/api#closeforumtopic)
//
// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
// - chatId (type int64): Unique identifier for the target chat
// - messageThreadId (type int64): Unique identifier for the target message thread of the forum topic
// - opts (type CloseForumTopicOpts): All optional parameters.
func (bot *Bot) CloseForumTopic(chatId int64, messageThreadId int64, opts *CloseForumTopicOpts) (bool, error) {
return bot.CloseForumTopicWithContext(context.Background(), chatId, messageThreadId, opts)
}
// CloseForumTopicWithContext is the same as Bot.CloseForumTopic, but with a context.Context parameter
func (bot *Bot) CloseForumTopicWithContext(ctx context.Context, chatId int64, messageThreadId int64, opts *CloseForumTopicOpts) (bool, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["message_thread_id"] = strconv.FormatInt(messageThreadId, 10)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "closeForumTopic", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// CloseGeneralForumTopicOpts is the set of optional fields for Bot.CloseGeneralForumTopic and Bot.CloseGeneralForumTopicWithContext.
type CloseGeneralForumTopicOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CloseGeneralForumTopic (https://core.telegram.org/bots/api#closegeneralforumtopic)
//
// Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
// - chatId (type int64): Unique identifier for the target chat
// - opts (type CloseGeneralForumTopicOpts): All optional parameters.
func (bot *Bot) CloseGeneralForumTopic(chatId int64, opts *CloseGeneralForumTopicOpts) (bool, error) {
return bot.CloseGeneralForumTopicWithContext(context.Background(), chatId, opts)
}
// CloseGeneralForumTopicWithContext is the same as Bot.CloseGeneralForumTopic, but with a context.Context parameter
func (bot *Bot) CloseGeneralForumTopicWithContext(ctx context.Context, chatId int64, opts *CloseGeneralForumTopicOpts) (bool, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "closeGeneralForumTopic", v, nil, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// CopyMessageOpts is the set of optional fields for Bot.CopyMessage and Bot.CopyMessageWithContext.
type CopyMessageOpts struct {
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
MessageThreadId int64
// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
Caption *string
// Mode for parsing entities in the new caption. See formatting options for more details.
ParseMode string
// A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode
CaptionEntities []MessageEntity
// Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified.
ShowCaptionAboveMedia bool
// Sends the message silently. Users will receive a notification with no sound.
DisableNotification bool
// Protects the contents of the sent message from forwarding and saving
ProtectContent bool
// Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
AllowPaidBroadcast bool
// Description of the message to reply to
ReplyParameters *ReplyParameters
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
ReplyMarkup ReplyMarkup
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CopyMessage (https://core.telegram.org/bots/api#copymessage)
//
// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
// - chatId (type int64): Unique identifier for the target chat
// - fromChatId (type int64): Unique identifier for the chat where the original message was sent
// - messageId (type int64): Message identifier in the chat specified in from_chat_id
// - opts (type CopyMessageOpts): All optional parameters.
func (bot *Bot) CopyMessage(chatId int64, fromChatId int64, messageId int64, opts *CopyMessageOpts) (*MessageId, error) {
return bot.CopyMessageWithContext(context.Background(), chatId, fromChatId, messageId, opts)
}
// CopyMessageWithContext is the same as Bot.CopyMessage, but with a context.Context parameter
func (bot *Bot) CopyMessageWithContext(ctx context.Context, chatId int64, fromChatId int64, messageId int64, opts *CopyMessageOpts) (*MessageId, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
v["message_id"] = strconv.FormatInt(messageId, 10)
if opts != nil {
if opts.MessageThreadId != 0 {
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
}
if opts.Caption != nil {
v["caption"] = *opts.Caption
}
v["parse_mode"] = opts.ParseMode
if opts.CaptionEntities != nil {
bs, err := json.Marshal(opts.CaptionEntities)
if err != nil {
return nil, fmt.Errorf("failed to marshal field caption_entities: %w", err)
}
v["caption_entities"] = string(bs)
}
v["show_caption_above_media"] = strconv.FormatBool(opts.ShowCaptionAboveMedia)
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
v["allow_paid_broadcast"] = strconv.FormatBool(opts.AllowPaidBroadcast)
if opts.ReplyParameters != nil {
bs, err := json.Marshal(opts.ReplyParameters)
if err != nil {
return nil, fmt.Errorf("failed to marshal field reply_parameters: %w", err)
}
v["reply_parameters"] = string(bs)
}
if opts.ReplyMarkup != nil {
bs, err := json.Marshal(opts.ReplyMarkup)
if err != nil {
return nil, fmt.Errorf("failed to marshal field reply_markup: %w", err)
}
v["reply_markup"] = string(bs)
}
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "copyMessage", v, nil, reqOpts)
if err != nil {
return nil, err
}
var m MessageId
return &m, json.Unmarshal(r, &m)
}
// CopyMessagesOpts is the set of optional fields for Bot.CopyMessages and Bot.CopyMessagesWithContext.
type CopyMessagesOpts struct {
// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
MessageThreadId int64
// Sends the messages silently. Users will receive a notification with no sound.
DisableNotification bool
// Protects the contents of the sent messages from forwarding and saving
ProtectContent bool
// Pass True to copy the messages without their captions
RemoveCaption bool
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CopyMessages (https://core.telegram.org/bots/api#copymessages)
//
// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned.
// - chatId (type int64): Unique identifier for the target chat
// - fromChatId (type int64): Unique identifier for the chat where the original messages were sent
// - messageIds (type []int64): A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
// - opts (type CopyMessagesOpts): All optional parameters.
func (bot *Bot) CopyMessages(chatId int64, fromChatId int64, messageIds []int64, opts *CopyMessagesOpts) ([]MessageId, error) {
return bot.CopyMessagesWithContext(context.Background(), chatId, fromChatId, messageIds, opts)
}
// CopyMessagesWithContext is the same as Bot.CopyMessages, but with a context.Context parameter
func (bot *Bot) CopyMessagesWithContext(ctx context.Context, chatId int64, fromChatId int64, messageIds []int64, opts *CopyMessagesOpts) ([]MessageId, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["from_chat_id"] = strconv.FormatInt(fromChatId, 10)
if messageIds != nil {
bs, err := json.Marshal(messageIds)
if err != nil {
return nil, fmt.Errorf("failed to marshal field message_ids: %w", err)
}
v["message_ids"] = string(bs)
}
if opts != nil {
if opts.MessageThreadId != 0 {
v["message_thread_id"] = strconv.FormatInt(opts.MessageThreadId, 10)
}
v["disable_notification"] = strconv.FormatBool(opts.DisableNotification)
v["protect_content"] = strconv.FormatBool(opts.ProtectContent)
v["remove_caption"] = strconv.FormatBool(opts.RemoveCaption)
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "copyMessages", v, nil, reqOpts)
if err != nil {
return nil, err
}
var m []MessageId
return m, json.Unmarshal(r, &m)
}
// CreateChatInviteLinkOpts is the set of optional fields for Bot.CreateChatInviteLink and Bot.CreateChatInviteLinkWithContext.
type CreateChatInviteLinkOpts struct {
// Invite link name; 0-32 characters
Name string
// Point in time (Unix timestamp) when the link will expire
ExpireDate int64
// The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
MemberLimit int64
// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
CreatesJoinRequest bool
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CreateChatInviteLink (https://core.telegram.org/bots/api#createchatinvitelink)
//
// Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
// - chatId (type int64): Unique identifier for the target chat
// - opts (type CreateChatInviteLinkOpts): All optional parameters.
func (bot *Bot) CreateChatInviteLink(chatId int64, opts *CreateChatInviteLinkOpts) (*ChatInviteLink, error) {
return bot.CreateChatInviteLinkWithContext(context.Background(), chatId, opts)
}
// CreateChatInviteLinkWithContext is the same as Bot.CreateChatInviteLink, but with a context.Context parameter
func (bot *Bot) CreateChatInviteLinkWithContext(ctx context.Context, chatId int64, opts *CreateChatInviteLinkOpts) (*ChatInviteLink, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
if opts != nil {
v["name"] = opts.Name
if opts.ExpireDate != 0 {
v["expire_date"] = strconv.FormatInt(opts.ExpireDate, 10)
}
if opts.MemberLimit != 0 {
v["member_limit"] = strconv.FormatInt(opts.MemberLimit, 10)
}
v["creates_join_request"] = strconv.FormatBool(opts.CreatesJoinRequest)
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "createChatInviteLink", v, nil, reqOpts)
if err != nil {
return nil, err
}
var c ChatInviteLink
return &c, json.Unmarshal(r, &c)
}
// CreateChatSubscriptionInviteLinkOpts is the set of optional fields for Bot.CreateChatSubscriptionInviteLink and Bot.CreateChatSubscriptionInviteLinkWithContext.
type CreateChatSubscriptionInviteLinkOpts struct {
// Invite link name; 0-32 characters
Name string
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CreateChatSubscriptionInviteLink (https://core.telegram.org/bots/api#createchatsubscriptioninvitelink)
//
// Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
// - chatId (type int64): Unique identifier for the target channel chat
// - subscriptionPeriod (type int64): The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
// - subscriptionPrice (type int64): The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
// - opts (type CreateChatSubscriptionInviteLinkOpts): All optional parameters.
func (bot *Bot) CreateChatSubscriptionInviteLink(chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
return bot.CreateChatSubscriptionInviteLinkWithContext(context.Background(), chatId, subscriptionPeriod, subscriptionPrice, opts)
}
// CreateChatSubscriptionInviteLinkWithContext is the same as Bot.CreateChatSubscriptionInviteLink, but with a context.Context parameter
func (bot *Bot) CreateChatSubscriptionInviteLinkWithContext(ctx context.Context, chatId int64, subscriptionPeriod int64, subscriptionPrice int64, opts *CreateChatSubscriptionInviteLinkOpts) (*ChatInviteLink, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["subscription_period"] = strconv.FormatInt(subscriptionPeriod, 10)
v["subscription_price"] = strconv.FormatInt(subscriptionPrice, 10)
if opts != nil {
v["name"] = opts.Name
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "createChatSubscriptionInviteLink", v, nil, reqOpts)
if err != nil {
return nil, err
}
var c ChatInviteLink
return &c, json.Unmarshal(r, &c)
}
// CreateForumTopicOpts is the set of optional fields for Bot.CreateForumTopic and Bot.CreateForumTopicWithContext.
type CreateForumTopicOpts struct {
// Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)
IconColor int64
// Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
IconCustomEmojiId string
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CreateForumTopic (https://core.telegram.org/bots/api#createforumtopic)
//
// Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.
// - chatId (type int64): Unique identifier for the target chat
// - name (type string): Topic name, 1-128 characters
// - opts (type CreateForumTopicOpts): All optional parameters.
func (bot *Bot) CreateForumTopic(chatId int64, name string, opts *CreateForumTopicOpts) (*ForumTopic, error) {
return bot.CreateForumTopicWithContext(context.Background(), chatId, name, opts)
}
// CreateForumTopicWithContext is the same as Bot.CreateForumTopic, but with a context.Context parameter
func (bot *Bot) CreateForumTopicWithContext(ctx context.Context, chatId int64, name string, opts *CreateForumTopicOpts) (*ForumTopic, error) {
v := map[string]string{}
v["chat_id"] = strconv.FormatInt(chatId, 10)
v["name"] = name
if opts != nil {
if opts.IconColor != 0 {
v["icon_color"] = strconv.FormatInt(opts.IconColor, 10)
}
v["icon_custom_emoji_id"] = opts.IconCustomEmojiId
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "createForumTopic", v, nil, reqOpts)
if err != nil {
return nil, err
}
var f ForumTopic
return &f, json.Unmarshal(r, &f)
}
// CreateInvoiceLinkOpts is the set of optional fields for Bot.CreateInvoiceLink and Bot.CreateInvoiceLinkWithContext.
type CreateInvoiceLinkOpts struct {
// Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only.
BusinessConnectionId string
// Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
ProviderToken string
// The number of seconds the subscription will be active for before the next payment. The currency must be set to "XTR" (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 2500 Telegram Stars.
SubscriptionPeriod int64
// The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.
MaxTipAmount int64
// A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
SuggestedTipAmounts []int64
// JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
ProviderData string
// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
PhotoUrl string
// Photo size in bytes
PhotoSize int64
// Photo width
PhotoWidth int64
// Photo height
PhotoHeight int64
// Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars.
NeedName bool
// Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars.
NeedPhoneNumber bool
// Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars.
NeedEmail bool
// Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars.
NeedShippingAddress bool
// Pass True if the user's phone number should be sent to the provider. Ignored for payments in Telegram Stars.
SendPhoneNumberToProvider bool
// Pass True if the user's email address should be sent to the provider. Ignored for payments in Telegram Stars.
SendEmailToProvider bool
// Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.
IsFlexible bool
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CreateInvoiceLink (https://core.telegram.org/bots/api#createinvoicelink)
//
// Use this method to create a link for an invoice. Returns the created invoice link as String on success.
// - title (type string): Product name, 1-32 characters
// - description (type string): Product description, 1-255 characters
// - payload (type string): Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
// - currency (type string): Three-letter ISO 4217 currency code, see more on currencies. Pass "XTR" for payments in Telegram Stars.
// - prices (type []LabeledPrice): Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
// - opts (type CreateInvoiceLinkOpts): All optional parameters.
func (bot *Bot) CreateInvoiceLink(title string, description string, payload string, currency string, prices []LabeledPrice, opts *CreateInvoiceLinkOpts) (string, error) {
return bot.CreateInvoiceLinkWithContext(context.Background(), title, description, payload, currency, prices, opts)
}
// CreateInvoiceLinkWithContext is the same as Bot.CreateInvoiceLink, but with a context.Context parameter
func (bot *Bot) CreateInvoiceLinkWithContext(ctx context.Context, title string, description string, payload string, currency string, prices []LabeledPrice, opts *CreateInvoiceLinkOpts) (string, error) {
v := map[string]string{}
v["title"] = title
v["description"] = description
v["payload"] = payload
v["currency"] = currency
if prices != nil {
bs, err := json.Marshal(prices)
if err != nil {
return "", fmt.Errorf("failed to marshal field prices: %w", err)
}
v["prices"] = string(bs)
}
if opts != nil {
v["business_connection_id"] = opts.BusinessConnectionId
v["provider_token"] = opts.ProviderToken
if opts.SubscriptionPeriod != 0 {
v["subscription_period"] = strconv.FormatInt(opts.SubscriptionPeriod, 10)
}
if opts.MaxTipAmount != 0 {
v["max_tip_amount"] = strconv.FormatInt(opts.MaxTipAmount, 10)
}
if opts.SuggestedTipAmounts != nil {
bs, err := json.Marshal(opts.SuggestedTipAmounts)
if err != nil {
return "", fmt.Errorf("failed to marshal field suggested_tip_amounts: %w", err)
}
v["suggested_tip_amounts"] = string(bs)
}
v["provider_data"] = opts.ProviderData
v["photo_url"] = opts.PhotoUrl
if opts.PhotoSize != 0 {
v["photo_size"] = strconv.FormatInt(opts.PhotoSize, 10)
}
if opts.PhotoWidth != 0 {
v["photo_width"] = strconv.FormatInt(opts.PhotoWidth, 10)
}
if opts.PhotoHeight != 0 {
v["photo_height"] = strconv.FormatInt(opts.PhotoHeight, 10)
}
v["need_name"] = strconv.FormatBool(opts.NeedName)
v["need_phone_number"] = strconv.FormatBool(opts.NeedPhoneNumber)
v["need_email"] = strconv.FormatBool(opts.NeedEmail)
v["need_shipping_address"] = strconv.FormatBool(opts.NeedShippingAddress)
v["send_phone_number_to_provider"] = strconv.FormatBool(opts.SendPhoneNumberToProvider)
v["send_email_to_provider"] = strconv.FormatBool(opts.SendEmailToProvider)
v["is_flexible"] = strconv.FormatBool(opts.IsFlexible)
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "createInvoiceLink", v, nil, reqOpts)
if err != nil {
return "", err
}
var s string
return s, json.Unmarshal(r, &s)
}
// CreateNewStickerSetOpts is the set of optional fields for Bot.CreateNewStickerSet and Bot.CreateNewStickerSetWithContext.
type CreateNewStickerSetOpts struct {
// Type of stickers in the set, pass "regular", "mask", or "custom_emoji". By default, a regular sticker set is created.
StickerType string
// Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only
NeedsRepainting bool
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}
// CreateNewStickerSet (https://core.telegram.org/bots/api#createnewstickerset)
//
// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.
// - userId (type int64): User identifier of created sticker set owner
// - name (type string): Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_<bot_username>". <bot_username> is case insensitive. 1-64 characters.
// - title (type string): Sticker set title, 1-64 characters
// - stickers (type []InputSticker): A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
// - opts (type CreateNewStickerSetOpts): All optional parameters.
func (bot *Bot) CreateNewStickerSet(userId int64, name string, title string, stickers []InputSticker, opts *CreateNewStickerSetOpts) (bool, error) {
return bot.CreateNewStickerSetWithContext(context.Background(), userId, name, title, stickers, opts)
}
// CreateNewStickerSetWithContext is the same as Bot.CreateNewStickerSet, but with a context.Context parameter
func (bot *Bot) CreateNewStickerSetWithContext(ctx context.Context, userId int64, name string, title string, stickers []InputSticker, opts *CreateNewStickerSetOpts) (bool, error) {
v := map[string]string{}
data := map[string]FileReader{}
v["user_id"] = strconv.FormatInt(userId, 10)
v["name"] = name
v["title"] = title
if stickers != nil {
var rawList []json.RawMessage
for idx, im := range stickers {
inputBs, err := im.InputParams("stickers"+strconv.Itoa(idx), data)
if err != nil {
return false, fmt.Errorf("failed to marshal list item %d for field stickers: %w", idx, err)
}
rawList = append(rawList, inputBs)
}
bs, err := json.Marshal(rawList)
if err != nil {
return false, fmt.Errorf("failed to marshal raw json list for field: stickers %w", err)
}
v["stickers"] = string(bs)
}
if opts != nil {
v["sticker_type"] = opts.StickerType
v["needs_repainting"] = strconv.FormatBool(opts.NeedsRepainting)
}
var reqOpts *RequestOpts
if opts != nil {
reqOpts = opts.RequestOpts
}
r, err := bot.RequestWithContext(ctx, "createNewStickerSet", v, data, reqOpts)
if err != nil {
return false, err
}
var b bool
return b, json.Unmarshal(r, &b)
}
// DeclineChatJoinRequestOpts is the set of optional fields for Bot.DeclineChatJoinRequest and Bot.DeclineChatJoinRequestWithContext.
type DeclineChatJoinRequestOpts struct {
// RequestOpts are an additional optional field to configure timeouts for individual requests
RequestOpts *RequestOpts
}