@zero-bot.net/tg-bot-api 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/telegram.js CHANGED
@@ -3114,6 +3114,1017 @@ class TelegramBot extends EventEmitter {
3114
3114
  return this._request('deleteMessages', { form });
3115
3115
  }
3116
3116
 
3117
+ // ==========================================
3118
+ // Bot API 7.4
3119
+ // ==========================================
3120
+
3121
+ /**
3122
+ * Use this method to issue a refund for a payment made via Telegram Stars.
3123
+ *
3124
+ * @param {Number} userId Identifier of the user whose payment will be refunded
3125
+ * @param {String} telegramPaymentChargeId Telegram payment identifier of the payment to refund
3126
+ * @param {Object} [options] Additional Telegram query options
3127
+ * @return {Promise} On success, True is returned
3128
+ * @see https://core.telegram.org/bots/api#refundstarpayment
3129
+ */
3130
+ refundStarPayment(userId, telegramPaymentChargeId, form = {}) {
3131
+ form.user_id = userId;
3132
+ form.telegram_payment_charge_id = telegramPaymentChargeId;
3133
+ return this._request('refundStarPayment', { form });
3134
+ }
3135
+
3136
+ // ==========================================
3137
+ // Bot API 7.5
3138
+ // ==========================================
3139
+
3140
+ /**
3141
+ * Use this method to get the current status of the balance of Telegram Stars
3142
+ * that can be withdrawn by the bot or transferred to another business account.
3143
+ *
3144
+ * @param {Object} [options] Additional Telegram query options
3145
+ * @return {Promise} On success, returns a StarTransactions object
3146
+ * @see https://core.telegram.org/bots/api#getstartransactions
3147
+ */
3148
+ getStarTransactions(form = {}) {
3149
+ return this._request('getStarTransactions', { form });
3150
+ }
3151
+
3152
+ // ==========================================
3153
+ // Bot API 7.6
3154
+ // ==========================================
3155
+
3156
+ /**
3157
+ * Use this method to send paid media.
3158
+ *
3159
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3160
+ * @param {Number} starCount The number of Telegram Stars that must be paid to buy access to the media
3161
+ * @param {Array} media A JSON-serialized array describing the media to be sent; currently supports photos and videos
3162
+ * @param {Object} [options] Additional Telegram query options
3163
+ * @return {Promise} On success, the sent Message object is returned
3164
+ * @see https://core.telegram.org/bots/api#sendpaidmedia
3165
+ */
3166
+ sendPaidMedia(chatId, starCount, media, form = {}) {
3167
+ form.chat_id = chatId;
3168
+ form.star_count = starCount;
3169
+ form.media = stringify(media);
3170
+ return this._request('sendPaidMedia', { form });
3171
+ }
3172
+
3173
+ // ==========================================
3174
+ // Bot API 7.9
3175
+ // ==========================================
3176
+
3177
+ /**
3178
+ * Use this method to create a subscription invite link for a channel chat.
3179
+ *
3180
+ * @param {Number|String} chatId Unique identifier for the target channel chat or username of the target channel (in the format `@channelusername`)
3181
+ * @param {Object} [options] Additional Telegram query options
3182
+ * @return {Promise} On success, the new invite link as a ChatInviteLink object is returned
3183
+ * @see https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
3184
+ */
3185
+ createChatSubscriptionInviteLink(chatId, form = {}) {
3186
+ form.chat_id = chatId;
3187
+ return this._request('createChatSubscriptionInviteLink', { form });
3188
+ }
3189
+
3190
+ /**
3191
+ * Use this method to edit a subscription invite link created by the bot.
3192
+ *
3193
+ * @param {Number|String} chatId Unique identifier for the target channel chat or username of the target channel (in the format `@channelusername`)
3194
+ * @param {String} inviteLink The invite link to edit
3195
+ * @param {Object} [options] Additional Telegram query options
3196
+ * @return {Promise} On success, the edited invite link as a ChatInviteLink object is returned
3197
+ * @see https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
3198
+ */
3199
+ editChatSubscriptionInviteLink(chatId, inviteLink, form = {}) {
3200
+ form.chat_id = chatId;
3201
+ form.invite_link = inviteLink;
3202
+ return this._request('editChatSubscriptionInviteLink', { form });
3203
+ }
3204
+
3205
+ // ==========================================
3206
+ // Bot API 8.0
3207
+ // ==========================================
3208
+
3209
+ /**
3210
+ * Use this method to get the list of gifts that can be sent by the bot.
3211
+ *
3212
+ * @param {Object} [options] Additional Telegram query options
3213
+ * @return {Promise} On success, returns a Gifts object
3214
+ * @see https://core.telegram.org/bots/api#getavailablegifts
3215
+ */
3216
+ getAvailableGifts(form = {}) {
3217
+ return this._request('getAvailableGifts', { form });
3218
+ }
3219
+
3220
+ /**
3221
+ * Use this method to send a gift to a user.
3222
+ *
3223
+ * @param {Number} userId Unique identifier of the target user that will receive the gift
3224
+ * @param {String} giftId Identifier of the gift
3225
+ * @param {Object} [options] Additional Telegram query options
3226
+ * @return {Promise} On success, True is returned
3227
+ * @see https://core.telegram.org/bots/api#sendgift
3228
+ */
3229
+ sendGift(userId, giftId, form = {}) {
3230
+ form.user_id = userId;
3231
+ form.gift_id = giftId;
3232
+ return this._request('sendGift', { form });
3233
+ }
3234
+
3235
+ /**
3236
+ * Use this method to edit a subscription paid through Telegram Stars.
3237
+ *
3238
+ * @param {Number} userId Identifier of the user whose subscription will be edited
3239
+ * @param {String} telegramPaymentChargeId Telegram payment identifier of the subscription payment
3240
+ * @param {Boolean} isCanceled Pass True to cancel the user's subscription
3241
+ * @param {Object} [options] Additional Telegram query options
3242
+ * @return {Promise} On success, True is returned
3243
+ * @see https://core.telegram.org/bots/api#edituserstarsubscription
3244
+ */
3245
+ editUserStarSubscription(userId, telegramPaymentChargeId, isCanceled, form = {}) {
3246
+ form.user_id = userId;
3247
+ form.telegram_payment_charge_id = telegramPaymentChargeId;
3248
+ form.is_canceled = isCanceled;
3249
+ return this._request('editUserStarSubscription', { form });
3250
+ }
3251
+
3252
+ /**
3253
+ * Use this method to store an inline message that can be sent on behalf of a user.
3254
+ *
3255
+ * @param {Number} userId Unique identifier of the target user
3256
+ * @param {Object} result An object describing the message to be sent
3257
+ * @param {Object} [options] Additional Telegram query options
3258
+ * @return {Promise} On success, returns a PreparedInlineMessage object
3259
+ * @see https://core.telegram.org/bots/api#savepreparedinlinemessage
3260
+ */
3261
+ savePreparedInlineMessage(userId, result, form = {}) {
3262
+ form.user_id = userId;
3263
+ form.result = stringify(result);
3264
+ return this._request('savePreparedInlineMessage', { form });
3265
+ }
3266
+
3267
+ // ==========================================
3268
+ // Bot API 8.2
3269
+ // ==========================================
3270
+
3271
+ /**
3272
+ * Use this method to verify a user that is managed by the bot.
3273
+ *
3274
+ * @param {Number} userId Unique identifier of the target user
3275
+ * @param {Object} [options] Additional Telegram query options
3276
+ * @return {Promise} On success, True is returned
3277
+ * @see https://core.telegram.org/bots/api#verifyuser
3278
+ */
3279
+ verifyUser(userId, form = {}) {
3280
+ form.user_id = userId;
3281
+ return this._request('verifyUser', { form });
3282
+ }
3283
+
3284
+ /**
3285
+ * Use this method to verify a chat that is managed by the bot.
3286
+ *
3287
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3288
+ * @param {Object} [options] Additional Telegram query options
3289
+ * @return {Promise} On success, True is returned
3290
+ * @see https://core.telegram.org/bots/api#verifychat
3291
+ */
3292
+ verifyChat(chatId, form = {}) {
3293
+ form.chat_id = chatId;
3294
+ return this._request('verifyChat', { form });
3295
+ }
3296
+
3297
+ /**
3298
+ * Use this method to remove verification for a user that is managed by the bot.
3299
+ *
3300
+ * @param {Number} userId Unique identifier of the target user
3301
+ * @param {Object} [options] Additional Telegram query options
3302
+ * @return {Promise} On success, True is returned
3303
+ * @see https://core.telegram.org/bots/api#removeuserverification
3304
+ */
3305
+ removeUserVerification(userId, form = {}) {
3306
+ form.user_id = userId;
3307
+ return this._request('removeUserVerification', { form });
3308
+ }
3309
+
3310
+ /**
3311
+ * Use this method to remove verification for a chat that is managed by the bot.
3312
+ *
3313
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3314
+ * @param {Object} [options] Additional Telegram query options
3315
+ * @return {Promise} On success, True is returned
3316
+ * @see https://core.telegram.org/bots/api#removechatverification
3317
+ */
3318
+ removeChatVerification(chatId, form = {}) {
3319
+ form.chat_id = chatId;
3320
+ return this._request('removeChatVerification', { form });
3321
+ }
3322
+
3323
+ // ==========================================
3324
+ // Bot API 9.0: Business Accounts + Gifts
3325
+ // ==========================================
3326
+
3327
+ /**
3328
+ * Use this method to mark incoming messages as read on behalf of a business account.
3329
+ *
3330
+ * @param {String} businessConnectionId Unique identifier of the business connection
3331
+ * @param {Number} messageId Unique identifier of the message to mark as read
3332
+ * @param {Object} [options] Additional Telegram query options
3333
+ * @return {Promise} True on success
3334
+ * @see https://core.telegram.org/bots/api#readbusinessmessage
3335
+ */
3336
+ readBusinessMessage(businessConnectionId, messageId, form = {}) {
3337
+ form.business_connection_id = businessConnectionId;
3338
+ form.message_id = messageId;
3339
+ return this._request('readBusinessMessage', { form });
3340
+ }
3341
+
3342
+ /**
3343
+ * Use this method to delete messages on behalf of a business account.
3344
+ *
3345
+ * @param {String} businessConnectionId Unique identifier of the business connection
3346
+ * @param {Array<Number>} messageIds Unique identifiers of 1-100 messages to delete
3347
+ * @param {Object} [options] Additional Telegram query options
3348
+ * @return {Promise} True on success
3349
+ * @see https://core.telegram.org/bots/api#deletebusinessmessages
3350
+ */
3351
+ deleteBusinessMessages(businessConnectionId, messageIds, form = {}) {
3352
+ form.business_connection_id = businessConnectionId;
3353
+ form.message_ids = stringify(messageIds);
3354
+ return this._request('deleteBusinessMessages', { form });
3355
+ }
3356
+
3357
+ /**
3358
+ * Use this method to change the first and last name of a managed business account.
3359
+ *
3360
+ * @param {String} businessConnectionId Unique identifier of the business connection
3361
+ * @param {Object} [options] Additional Telegram query options
3362
+ * @return {Promise} True on success
3363
+ * @see https://core.telegram.org/bots/api#setbusinessaccountname
3364
+ */
3365
+ setBusinessAccountName(businessConnectionId, form = {}) {
3366
+ form.business_connection_id = businessConnectionId;
3367
+ return this._request('setBusinessAccountName', { form });
3368
+ }
3369
+
3370
+ /**
3371
+ * Use this method to change the username of a managed business account.
3372
+ *
3373
+ * @param {String} businessConnectionId Unique identifier of the business connection
3374
+ * @param {Object} [options] Additional Telegram query options
3375
+ * @return {Promise} True on success
3376
+ * @see https://core.telegram.org/bots/api#setbusinessaccountusername
3377
+ */
3378
+ setBusinessAccountUsername(businessConnectionId, form = {}) {
3379
+ form.business_connection_id = businessConnectionId;
3380
+ return this._request('setBusinessAccountUsername', { form });
3381
+ }
3382
+
3383
+ /**
3384
+ * Use this method to change the bio of a managed business account.
3385
+ *
3386
+ * @param {String} businessConnectionId Unique identifier of the business connection
3387
+ * @param {Object} [options] Additional Telegram query options
3388
+ * @return {Promise} True on success
3389
+ * @see https://core.telegram.org/bots/api#setbusinessaccountbio
3390
+ */
3391
+ setBusinessAccountBio(businessConnectionId, form = {}) {
3392
+ form.business_connection_id = businessConnectionId;
3393
+ return this._request('setBusinessAccountBio', { form });
3394
+ }
3395
+
3396
+ /**
3397
+ * Use this method to change the profile photo of a managed business account.
3398
+ *
3399
+ * @param {String} businessConnectionId Unique identifier of the business connection
3400
+ * @param {Object} photo InputProfilePhoto object
3401
+ * @param {Object} [options] Additional Telegram query options
3402
+ * @return {Promise} True on success
3403
+ * @see https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
3404
+ */
3405
+ setBusinessAccountProfilePhoto(businessConnectionId, photo, form = {}) {
3406
+ form.business_connection_id = businessConnectionId;
3407
+ form.photo = stringify(photo);
3408
+ return this._request('setBusinessAccountProfilePhoto', { form });
3409
+ }
3410
+
3411
+ /**
3412
+ * Use this method to remove the profile photo of a managed business account.
3413
+ *
3414
+ * @param {String} businessConnectionId Unique identifier of the business connection
3415
+ * @param {Object} [options] Additional Telegram query options
3416
+ * @return {Promise} True on success
3417
+ * @see https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
3418
+ */
3419
+ removeBusinessAccountProfilePhoto(businessConnectionId, form = {}) {
3420
+ form.business_connection_id = businessConnectionId;
3421
+ return this._request('removeBusinessAccountProfilePhoto', { form });
3422
+ }
3423
+
3424
+ /**
3425
+ * Use this method to change the gift settings of a managed business account.
3426
+ *
3427
+ * @param {String} businessConnectionId Unique identifier of the business connection
3428
+ * @param {Object} [options] Additional Telegram query options
3429
+ * @return {Promise} True on success
3430
+ * @see https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
3431
+ */
3432
+ setBusinessAccountGiftSettings(businessConnectionId, form = {}) {
3433
+ form.business_connection_id = businessConnectionId;
3434
+ if (form.accepted_gift_types) {
3435
+ form.accepted_gift_types = stringify(form.accepted_gift_types);
3436
+ }
3437
+ return this._request('setBusinessAccountGiftSettings', { form });
3438
+ }
3439
+
3440
+ /**
3441
+ * Use this method to get the current Star balance of a managed business account.
3442
+ *
3443
+ * @param {String} businessConnectionId Unique identifier of the business connection
3444
+ * @param {Object} [options] Additional Telegram query options
3445
+ * @return {Promise} Returns a StarAmount object
3446
+ * @see https://core.telegram.org/bots/api#getbusinessaccountstarbalance
3447
+ */
3448
+ getBusinessAccountStarBalance(businessConnectionId, form = {}) {
3449
+ form.business_connection_id = businessConnectionId;
3450
+ return this._request('getBusinessAccountStarBalance', { form });
3451
+ }
3452
+
3453
+ /**
3454
+ * Use this method to transfer Stars from the business account balance to the bot owner's balance.
3455
+ *
3456
+ * @param {String} businessConnectionId Unique identifier of the business connection
3457
+ * @param {Number} starCount Number of Telegram Stars to transfer, 1-10000
3458
+ * @param {Object} [options] Additional Telegram query options
3459
+ * @return {Promise} Returns a StarAmount object
3460
+ * @see https://core.telegram.org/bots/api#transferbusinessaccountstars
3461
+ */
3462
+ transferBusinessAccountStars(businessConnectionId, starCount, form = {}) {
3463
+ form.business_connection_id = businessConnectionId;
3464
+ form.star_count = starCount;
3465
+ return this._request('transferBusinessAccountStars', { form });
3466
+ }
3467
+
3468
+ /**
3469
+ * Use this method to get the list of gifts received by a managed business account.
3470
+ *
3471
+ * @param {String} businessConnectionId Unique identifier of the business connection
3472
+ * @param {Object} [options] Additional Telegram query options
3473
+ * @return {Promise} Returns an Array of OwnedGift objects
3474
+ * @see https://core.telegram.org/bots/api#getbusinessaccountgifts
3475
+ */
3476
+ getBusinessAccountGifts(businessConnectionId, form = {}) {
3477
+ form.business_connection_id = businessConnectionId;
3478
+ return this._request('getBusinessAccountGifts', { form });
3479
+ }
3480
+
3481
+ /**
3482
+ * Use this method to convert a given regular gift to Telegram Stars.
3483
+ *
3484
+ * @param {String} businessConnectionId Unique identifier of the business connection
3485
+ * @param {String} ownedGiftId Identifier of the regular gift
3486
+ * @param {Object} [options] Additional Telegram query options
3487
+ * @return {Promise} Returns a StarAmount object
3488
+ * @see https://core.telegram.org/bots/api#convertgifttostars
3489
+ */
3490
+ convertGiftToStars(businessConnectionId, ownedGiftId, form = {}) {
3491
+ form.business_connection_id = businessConnectionId;
3492
+ form.owned_gift_id = ownedGiftId;
3493
+ return this._request('convertGiftToStars', { form });
3494
+ }
3495
+
3496
+ /**
3497
+ * Use this method to upgrade a regular gift to a unique or upgrade a unique gift to an upgraded collectible gift.
3498
+ *
3499
+ * @param {String} businessConnectionId Unique identifier of the business connection
3500
+ * @param {String} ownedGiftId Identifier of the regular gift to upgrade
3501
+ * @param {Object} [options] Additional Telegram query options
3502
+ * @return {Promise} Returns the updated OwnedGift object
3503
+ * @see https://core.telegram.org/bots/api#upgradegift
3504
+ */
3505
+ upgradeGift(businessConnectionId, ownedGiftId, form = {}) {
3506
+ form.business_connection_id = businessConnectionId;
3507
+ form.owned_gift_id = ownedGiftId;
3508
+ return this._request('upgradeGift', { form });
3509
+ }
3510
+
3511
+ /**
3512
+ * Use this method to transfer a regular gift to another user.
3513
+ *
3514
+ * @param {String} businessConnectionId Unique identifier of the business connection
3515
+ * @param {String} ownedGiftId Identifier of the gift to transfer
3516
+ * @param {Number|String} newOwnerChatId Unique identifier of the new owner of the gift
3517
+ * @param {Object} [options] Additional Telegram query options
3518
+ * @return {Promise} True on success
3519
+ * @see https://core.telegram.org/bots/api#transfergift
3520
+ */
3521
+ transferGift(businessConnectionId, ownedGiftId, newOwnerChatId, form = {}) {
3522
+ form.business_connection_id = businessConnectionId;
3523
+ form.owned_gift_id = ownedGiftId;
3524
+ form.new_owner_chat_id = newOwnerChatId;
3525
+ return this._request('transferGift', { form });
3526
+ }
3527
+
3528
+ /**
3529
+ * Use this method to post a story on behalf of a managed business account.
3530
+ *
3531
+ * @param {String} businessConnectionId Unique identifier of the business connection
3532
+ * @param {Object} content InputStoryContent object
3533
+ * @param {Object} [options] Additional Telegram query options
3534
+ * @return {Promise} Returns a Story object
3535
+ * @see https://core.telegram.org/bots/api#poststory
3536
+ */
3537
+ postStory(businessConnectionId, content, form = {}) {
3538
+ form.business_connection_id = businessConnectionId;
3539
+ form.content = stringify(content);
3540
+ return this._request('postStory', { form });
3541
+ }
3542
+
3543
+ /**
3544
+ * Use this method to edit a story previously posted on behalf of a managed business account.
3545
+ *
3546
+ * @param {String} businessConnectionId Unique identifier of the business connection
3547
+ * @param {Number} storyId Identifier of the story to edit
3548
+ * @param {Object} [options] Additional Telegram query options
3549
+ * @return {Promise} Returns the edited Story object
3550
+ * @see https://core.telegram.org/bots/api#editstory
3551
+ */
3552
+ editStory(businessConnectionId, storyId, form = {}) {
3553
+ form.business_connection_id = businessConnectionId;
3554
+ form.story_id = storyId;
3555
+ if (form.content) {
3556
+ form.content = stringify(form.content);
3557
+ }
3558
+ return this._request('editStory', { form });
3559
+ }
3560
+
3561
+ /**
3562
+ * Use this method to delete a story previously posted on behalf of a managed business account.
3563
+ *
3564
+ * @param {String} businessConnectionId Unique identifier of the business connection
3565
+ * @param {Number} storyId Identifier of the story to delete
3566
+ * @param {Object} [options] Additional Telegram query options
3567
+ * @return {Promise} True on success
3568
+ * @see https://core.telegram.org/bots/api#deletestory
3569
+ */
3570
+ deleteStory(businessConnectionId, storyId, form = {}) {
3571
+ form.business_connection_id = businessConnectionId;
3572
+ form.story_id = storyId;
3573
+ return this._request('deleteStory', { form });
3574
+ }
3575
+
3576
+ /**
3577
+ * Use this method to gift a Telegram Premium subscription to a user.
3578
+ *
3579
+ * @param {Number|String} userId Unique identifier of the target user
3580
+ * @param {Number} monthCount Number of months the subscription will be active for, 1-36
3581
+ * @param {Number} starCount Number of Telegram Stars that will be paid for the subscription, 1-10000
3582
+ * @param {Object} [options] Additional Telegram query options
3583
+ * @return {Promise} Returns the Gift object that was paid for
3584
+ * @see https://core.telegram.org/bots/api#giftpremiumsubscription
3585
+ */
3586
+ giftPremiumSubscription(userId, monthCount, starCount, form = {}) {
3587
+ form.user_id = userId;
3588
+ form.month_count = monthCount;
3589
+ form.star_count = starCount;
3590
+ return this._request('giftPremiumSubscription', { form });
3591
+ }
3592
+
3593
+ /**
3594
+ * Use this method to set the emoji status of a user.
3595
+ *
3596
+ * @param {Number|String} userId Unique identifier of the target user
3597
+ * @param {Object} [options] Additional Telegram query options
3598
+ * @return {Promise} True on success
3599
+ * @see https://core.telegram.org/bots/api#setuseremojistatus
3600
+ */
3601
+ setUserEmojiStatus(userId, form = {}) {
3602
+ form.user_id = userId;
3603
+ return this._request('setUserEmojiStatus', { form });
3604
+ }
3605
+
3606
+ // ==========================================
3607
+ // Bot API 9.1: Checklists
3608
+ // ==========================================
3609
+
3610
+ /**
3611
+ * Use this method to send a checklist on behalf of a managed business account.
3612
+ *
3613
+ * @param {String} businessConnectionId Unique identifier of the business connection
3614
+ * @param {String} title Title of the checklist, 1-255 characters after entities parsing
3615
+ * @param {Array} tasks List of 1-100 tasks in the checklist
3616
+ * @param {Object} [options] Additional Telegram query options
3617
+ * @return {Promise} On success, the sent Message is returned
3618
+ * @see https://core.telegram.org/bots/api#sendchecklist
3619
+ */
3620
+ sendChecklist(businessConnectionId, title, tasks, form = {}) {
3621
+ form.business_connection_id = businessConnectionId;
3622
+ form.title = title;
3623
+ form.tasks = stringify(tasks);
3624
+ return this._request('sendChecklist', { form });
3625
+ }
3626
+
3627
+ /**
3628
+ * Use this method to edit a checklist message on behalf of a managed business account.
3629
+ *
3630
+ * @param {String} businessConnectionId Unique identifier of the business connection
3631
+ * @param {Number} messageId Unique identifier of the message to edit
3632
+ * @param {Object} [options] Additional Telegram query options
3633
+ * @return {Promise} On success, the edited Message is returned
3634
+ * @see https://core.telegram.org/bots/api#editmessagechecklist
3635
+ */
3636
+ editMessageChecklist(businessConnectionId, messageId, form = {}) {
3637
+ form.business_connection_id = businessConnectionId;
3638
+ form.message_id = messageId;
3639
+ if (form.tasks) {
3640
+ form.tasks = stringify(form.tasks);
3641
+ }
3642
+ return this._request('editMessageChecklist', { form });
3643
+ }
3644
+
3645
+ /**
3646
+ * Use this method to get the current number of Telegram Stars owned by the bot.
3647
+ *
3648
+ * @param {Object} [options] Additional Telegram query options
3649
+ * @return {Promise} Returns a StarAmount object
3650
+ * @see https://core.telegram.org/bots/api#getmystarbalance
3651
+ */
3652
+ getMyStarBalance(form = {}) {
3653
+ return this._request('getMyStarBalance', { form });
3654
+ }
3655
+
3656
+ // ==========================================
3657
+ // Bot API 9.2: Suggested Posts
3658
+ // ==========================================
3659
+
3660
+ /**
3661
+ * Use this method to approve a suggested post in a channel chat.
3662
+ *
3663
+ * @param {String} businessConnectionId Unique identifier of the business connection
3664
+ * @param {Number} messageId Unique identifier of the suggested post message
3665
+ * @param {Object} [options] Additional Telegram query options
3666
+ * @return {Promise} True on success
3667
+ * @see https://core.telegram.org/bots/api#approvesuggestedpost
3668
+ */
3669
+ approveSuggestedPost(businessConnectionId, messageId, form = {}) {
3670
+ form.business_connection_id = businessConnectionId;
3671
+ form.message_id = messageId;
3672
+ return this._request('approveSuggestedPost', { form });
3673
+ }
3674
+
3675
+ /**
3676
+ * Use this method to decline a suggested post in a channel chat.
3677
+ *
3678
+ * @param {String} businessConnectionId Unique identifier of the business connection
3679
+ * @param {Number} messageId Unique identifier of the suggested post message
3680
+ * @param {Object} [options] Additional Telegram query options
3681
+ * @return {Promise} True on success
3682
+ * @see https://core.telegram.org/bots/api#declinesuggestedpost
3683
+ */
3684
+ declineSuggestedPost(businessConnectionId, messageId, form = {}) {
3685
+ form.business_connection_id = businessConnectionId;
3686
+ form.message_id = messageId;
3687
+ return this._request('declineSuggestedPost', { form });
3688
+ }
3689
+
3690
+ // ==========================================
3691
+ // Bot API 9.3: Draft Messages, Gifts, Stories
3692
+ // ==========================================
3693
+
3694
+ /**
3695
+ * Use this method to send a draft message to the bot's user in private chat.
3696
+ *
3697
+ * @param {Number|String} chatId Unique identifier of the target private chat
3698
+ * @param {String} text Text of the message, 1-4096 characters after entities parsing
3699
+ * @param {Object} [options] Additional Telegram query options
3700
+ * @return {Promise} On success, the sent Message is returned
3701
+ * @see https://core.telegram.org/bots/api#sendmessagedraft
3702
+ */
3703
+ sendMessageDraft(chatId, text, form = {}) {
3704
+ form.chat_id = chatId;
3705
+ form.text = text;
3706
+ if (form.entities) {
3707
+ form.entities = stringify(form.entities);
3708
+ }
3709
+ if (form.link_preview_options) {
3710
+ form.link_preview_options = stringify(form.link_preview_options);
3711
+ }
3712
+ return this._request('sendMessageDraft', { form });
3713
+ }
3714
+
3715
+ /**
3716
+ * Use this method to get gifts received by a user in a private chat.
3717
+ *
3718
+ * @param {Number|String} userId Unique identifier of the target user
3719
+ * @param {Object} [options] Additional Telegram query options
3720
+ * @return {Promise} Array of OwnedGift objects
3721
+ * @see https://core.telegram.org/bots/api#getusergifts
3722
+ */
3723
+ getUserGifts(userId, form = {}) {
3724
+ form.user_id = userId;
3725
+ return this._request('getUserGifts', { form });
3726
+ }
3727
+
3728
+ /**
3729
+ * Use this method to get gifts received by a chat.
3730
+ *
3731
+ * @param {Number|String} chatId Unique identifier of the target chat
3732
+ * @param {Object} [options] Additional Telegram query options
3733
+ * @return {Promise} Array of OwnedGift objects
3734
+ * @see https://core.telegram.org/bots/api#getchatgifts
3735
+ */
3736
+ getChatGifts(chatId, form = {}) {
3737
+ form.chat_id = chatId;
3738
+ return this._request('getChatGifts', { form });
3739
+ }
3740
+
3741
+ /**
3742
+ * Use this method to repost a story on behalf of a managed business account.
3743
+ *
3744
+ * @param {String} businessConnectionId Unique identifier of the business connection
3745
+ * @param {Number} storyId Identifier of the story to repost
3746
+ * @param {Array<Number|String>} targetBusinessConnectionIds Identifiers of the business connections to post the story to
3747
+ * @param {Object} [options] Additional Telegram query options
3748
+ * @return {Promise} Array of Story objects
3749
+ * @see https://core.telegram.org/bots/api#repoststory
3750
+ */
3751
+ repostStory(businessConnectionId, storyId, targetBusinessConnectionIds, form = {}) {
3752
+ form.business_connection_id = businessConnectionId;
3753
+ form.story_id = storyId;
3754
+ form.target_business_connection_ids = stringify(targetBusinessConnectionIds);
3755
+ return this._request('repostStory', { form });
3756
+ }
3757
+
3758
+ // ==========================================
3759
+ // Bot API 9.4: Profile Photos, Audio Stories
3760
+ // ==========================================
3761
+
3762
+ /**
3763
+ * Use this method to set the profile photo of the bot.
3764
+ *
3765
+ * @param {Object} photo InputProfilePhoto object
3766
+ * @param {Object} [options] Additional Telegram query options
3767
+ * @return {Promise} True on success
3768
+ * @see https://core.telegram.org/bots/api#setmyprofilephoto
3769
+ */
3770
+ setMyProfilePhoto(photo, form = {}) {
3771
+ form.photo = stringify(photo);
3772
+ return this._request('setMyProfilePhoto', { form });
3773
+ }
3774
+
3775
+ /**
3776
+ * Use this method to remove the profile photo of the bot.
3777
+ *
3778
+ * @param {Object} [options] Additional Telegram query options
3779
+ * @return {Promise} True on success
3780
+ * @see https://core.telegram.org/bots/api#removemyprofilephoto
3781
+ */
3782
+ removeMyProfilePhoto(form = {}) {
3783
+ return this._request('removeMyProfilePhoto', { form });
3784
+ }
3785
+
3786
+ /**
3787
+ * Use this method to get the profile audios of a user.
3788
+ *
3789
+ * @param {Number|String} userId Unique identifier of the target user
3790
+ * @param {Object} [options] Additional Telegram query options
3791
+ * @return {Promise} Array of Audio objects
3792
+ * @see https://core.telegram.org/bots/api#getuserprofileaudios
3793
+ */
3794
+ getUserProfileAudios(userId, form = {}) {
3795
+ form.user_id = userId;
3796
+ return this._request('getUserProfileAudios', { form });
3797
+ }
3798
+
3799
+ // ==========================================
3800
+ // Bot API 9.5: Chat Member Tags
3801
+ // ==========================================
3802
+
3803
+ /**
3804
+ * Use this method to set the tag that is applied to a specific user in a specific group chat.
3805
+ *
3806
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target group
3807
+ * @param {Number|String} userId Unique identifier of the target user
3808
+ * @param {Object} [options] Additional Telegram query options
3809
+ * @return {Promise} True on success
3810
+ * @see https://core.telegram.org/bots/api#setchatmembertag
3811
+ */
3812
+ setChatMemberTag(chatId, userId, form = {}) {
3813
+ form.chat_id = chatId;
3814
+ form.user_id = userId;
3815
+ return this._request('setChatMemberTag', { form });
3816
+ }
3817
+
3818
+ // ==========================================
3819
+ // Bot API 9.6: Managed Bot Tokens
3820
+ // ==========================================
3821
+
3822
+ /**
3823
+ * Use this method to get the current managable bot token for the bot.
3824
+ *
3825
+ * @param {Number} botId Identifier of the bot to get the token for
3826
+ * @param {Object} [options] Additional Telegram query options
3827
+ * @return {Promise} Returns a ManagedBotToken object
3828
+ * @see https://core.telegram.org/bots/api#getmanagedbottoken
3829
+ */
3830
+ getManagedBotToken(botId, form = {}) {
3831
+ form.bot_id = botId;
3832
+ return this._request('getManagedBotToken', { form });
3833
+ }
3834
+
3835
+ /**
3836
+ * Use this method to replace the managable bot token for the bot with a new one.
3837
+ *
3838
+ * @param {Number} botId Identifier of the bot whose token will be replaced
3839
+ * @param {Object} [options] Additional Telegram query options
3840
+ * @return {Promise} Returns a ManagedBotToken object
3841
+ * @see https://core.telegram.org/bots/api#replacemanagedbottoken
3842
+ */
3843
+ replaceManagedBotToken(botId, form = {}) {
3844
+ form.bot_id = botId;
3845
+ return this._request('replaceManagedBotToken', { form });
3846
+ }
3847
+
3848
+ /**
3849
+ * Use this method to save a prepared keyboard button for later use.
3850
+ *
3851
+ * @param {Object} button KeyboardButton object to save
3852
+ * @param {Object} [options] Additional Telegram query options
3853
+ * @return {Promise} Returns a PreparedKeyboardButton object
3854
+ * @see https://core.telegram.org/bots/api#savepreparedkeyboardbutton
3855
+ */
3856
+ savePreparedKeyboardButton(button, form = {}) {
3857
+ form.button = stringify(button);
3858
+ return this._request('savePreparedKeyboardButton', { form });
3859
+ }
3860
+
3861
+ // ==========================================
3862
+ // Bot API 10.0: Guest Mode, Live Photos, Reactions
3863
+ // ==========================================
3864
+
3865
+ /**
3866
+ * Use this method to answer a guest query in a Telegram Web App.
3867
+ *
3868
+ * @param {String} guestQueryId Unique identifier for the query to be answered
3869
+ * @param {String} text Text of the message
3870
+ * @param {Object} [options] Additional Telegram query options
3871
+ * @return {Promise} True on success
3872
+ * @see https://core.telegram.org/bots/api#answerguestquery
3873
+ */
3874
+ answerGuestQuery(guestQueryId, text, form = {}) {
3875
+ form.guest_query_id = guestQueryId;
3876
+ form.text = text;
3877
+ return this._request('answerGuestQuery', { form });
3878
+ }
3879
+
3880
+ /**
3881
+ * Use this method to remove multiple reactions from a message.
3882
+ *
3883
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3884
+ * @param {Number} messageId Unique identifier of the target message
3885
+ * @param {Object} [options] Additional Telegram query options
3886
+ * @return {Promise} True on success
3887
+ * @see https://core.telegram.org/bots/api#deletemessagereactions
3888
+ */
3889
+ deleteAllMessageReactions(chatId, messageId, form = {}) {
3890
+ form.chat_id = chatId;
3891
+ form.message_id = messageId;
3892
+ return this._request('deleteAllMessageReactions', { form });
3893
+ }
3894
+
3895
+ /**
3896
+ * Use this method to remove a reaction from a message.
3897
+ *
3898
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3899
+ * @param {Number} messageId Unique identifier of the target message
3900
+ * @param {Object} [options] Additional Telegram query options
3901
+ * @return {Promise} True on success
3902
+ * @see https://core.telegram.org/bots/api#deletemessagereaction
3903
+ */
3904
+ deleteMessageReaction(chatId, messageId, form = {}) {
3905
+ form.chat_id = chatId;
3906
+ form.message_id = messageId;
3907
+ if (form.reaction_type) {
3908
+ form.reaction_type = stringify(form.reaction_type);
3909
+ }
3910
+ return this._request('deleteMessageReaction', { form });
3911
+ }
3912
+
3913
+ /**
3914
+ * Use this method to send a live photo.
3915
+ *
3916
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3917
+ * @param {String|stream.Stream|Buffer} photo A file path, Stream, Buffer, or file_id
3918
+ * @param {String|stream.Stream|Buffer} video A file path, Stream, Buffer, or file_id
3919
+ * @param {Object} [options] Additional Telegram query options
3920
+ * @param {Object} [fileOptions] Optional file related meta-data
3921
+ * @return {Promise} On success, the sent Message object is returned
3922
+ * @see https://core.telegram.org/bots/api#sendlivephoto
3923
+ */
3924
+ sendLivePhoto(chatId, photo, video, form = {}, fileOptions = {}) {
3925
+ const opts = {
3926
+ qs: form,
3927
+ };
3928
+ opts.qs.chat_id = chatId;
3929
+ try {
3930
+ const sendDataPhoto = this._formatSendData('photo', photo, fileOptions);
3931
+ const sendDataVideo = this._formatSendData('video', video, fileOptions);
3932
+ opts.formData = Object.assign({}, sendDataPhoto[0], sendDataVideo[0]);
3933
+ opts.qs.photo = sendDataPhoto[1];
3934
+ opts.qs.video = sendDataVideo[1];
3935
+ } catch (ex) {
3936
+ return Promise.reject(ex);
3937
+ }
3938
+ return this._request('sendLivePhoto', opts);
3939
+ }
3940
+
3941
+ /**
3942
+ * Use this method to get the current access settings of the bot for managed bots.
3943
+ *
3944
+ * @param {Object} [options] Additional Telegram query options
3945
+ * @return {Promise} Returns a ManagedBotAccessSettings object
3946
+ * @see https://core.telegram.org/bots/api#getmanagedbotaccesssettings
3947
+ */
3948
+ getManagedBotAccessSettings(form = {}) {
3949
+ return this._request('getManagedBotAccessSettings', { form });
3950
+ }
3951
+
3952
+ /**
3953
+ * Use this method to change the access settings of the bot for managed bots.
3954
+ *
3955
+ * @param {Object} [options] Additional Telegram query options
3956
+ * @return {Promise} True on success
3957
+ * @see https://core.telegram.org/bots/api#setmanagedbotaccesssettings
3958
+ */
3959
+ setManagedBotAccessSettings(form = {}) {
3960
+ if (form.restricted_channels) {
3961
+ form.restricted_channels = stringify(form.restricted_channels);
3962
+ }
3963
+ return this._request('setManagedBotAccessSettings', { form });
3964
+ }
3965
+
3966
+ /**
3967
+ * Use this method to get messages from a user's personal chat with the bot.
3968
+ *
3969
+ * @param {Number} userId Unique identifier of the target user
3970
+ * @param {Object} [options] Additional Telegram query options
3971
+ * @return {Promise} Array of Message objects
3972
+ * @see https://core.telegram.org/bots/api#getuserpersonalchatmessages
3973
+ */
3974
+ getUserPersonalChatMessages(userId, form = {}) {
3975
+ form.user_id = userId;
3976
+ return this._request('getUserPersonalChatMessages', { form });
3977
+ }
3978
+
3979
+ // ==========================================
3980
+ // Bot API 10.1: Rich Messages, Join Request Queries
3981
+ // ==========================================
3982
+
3983
+ /**
3984
+ * Use this method to send a rich message.
3985
+ *
3986
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3987
+ * @param {Object} content An InputRichMessageContent object
3988
+ * @param {Object} [options] Additional Telegram query options
3989
+ * @return {Promise} On success, the sent Message object is returned
3990
+ * @see https://core.telegram.org/bots/api#sendrichmessage
3991
+ */
3992
+ sendRichMessage(chatId, content, form = {}) {
3993
+ form.chat_id = chatId;
3994
+ form.content = stringify(content);
3995
+ return this._request('sendRichMessage', { form });
3996
+ }
3997
+
3998
+ /**
3999
+ * Use this method to send a rich message draft.
4000
+ *
4001
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4002
+ * @param {Object} content An InputRichMessageContent object
4003
+ * @param {Object} [options] Additional Telegram query options
4004
+ * @return {Promise} On success, a Message object is returned
4005
+ * @see https://core.telegram.org/bots/api#sendrichmessagedraft
4006
+ */
4007
+ sendRichMessageDraft(chatId, content, form = {}) {
4008
+ form.chat_id = chatId;
4009
+ form.content = stringify(content);
4010
+ return this._request('sendRichMessageDraft', { form });
4011
+ }
4012
+
4013
+ /**
4014
+ * Use this method to answer a chat join request query.
4015
+ *
4016
+ * @param {Number} chatJoinRequestId Unique identifier of the chat join request
4017
+ * @param {String} queryId Unique identifier for the query to be answered
4018
+ * @param {Object} [options] Additional Telegram query options
4019
+ * @return {Promise} True on success
4020
+ * @see https://core.telegram.org/bots/api#answerchatjoinrequestquery
4021
+ */
4022
+ answerChatJoinRequestQuery(chatJoinRequestId, queryId, form = {}) {
4023
+ form.chat_join_request_id = chatJoinRequestId;
4024
+ form.query_id = queryId;
4025
+ return this._request('answerChatJoinRequestQuery', { form });
4026
+ }
4027
+
4028
+ /**
4029
+ * Use this method to send a Web App message to a chat join request.
4030
+ *
4031
+ * @param {Number} chatJoinRequestId Unique identifier of the chat join request
4032
+ * @param {Object} webApp A SentWebAppMessage object
4033
+ * @param {Object} [options] Additional Telegram query options
4034
+ * @return {Promise} True on success
4035
+ * @see https://core.telegram.org/bots/api#sendchatjoinrequestwebapp
4036
+ */
4037
+ sendChatJoinRequestWebApp(chatJoinRequestId, webApp, form = {}) {
4038
+ form.chat_join_request_id = chatJoinRequestId;
4039
+ form.web_app = stringify(webApp);
4040
+ return this._request('sendChatJoinRequestWebApp', { form });
4041
+ }
4042
+
4043
+ // ==========================================
4044
+ // Bot API 10.2: Ephemeral Messages
4045
+ // ==========================================
4046
+
4047
+ /**
4048
+ * Use this method to edit the text of an ephemeral message.
4049
+ *
4050
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4051
+ * @param {String} ephemeralMessageId Unique identifier of the ephemeral message
4052
+ * @param {String} text New text of the message
4053
+ * @param {Object} [options] Additional Telegram query options
4054
+ * @return {Promise} On success, the edited Message object is returned
4055
+ * @see https://core.telegram.org/bots/api#editephemeralmessagetext
4056
+ */
4057
+ editEphemeralMessageText(chatId, ephemeralMessageId, text, form = {}) {
4058
+ form.chat_id = chatId;
4059
+ form.ephemeral_message_id = ephemeralMessageId;
4060
+ form.text = text;
4061
+ return this._request('editEphemeralMessageText', { form });
4062
+ }
4063
+
4064
+ /**
4065
+ * Use this method to edit the media of an ephemeral message.
4066
+ *
4067
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4068
+ * @param {String} ephemeralMessageId Unique identifier of the ephemeral message
4069
+ * @param {Object} media An InputMedia object
4070
+ * @param {Object} [options] Additional Telegram query options
4071
+ * @param {Object} [fileOptions] Optional file related meta-data
4072
+ * @return {Promise} On success, the edited Message object is returned
4073
+ * @see https://core.telegram.org/bots/api#editephemeralmessagemedia
4074
+ */
4075
+ editEphemeralMessageMedia(chatId, ephemeralMessageId, media, form = {}, fileOptions = {}) {
4076
+ form.chat_id = chatId;
4077
+ form.ephemeral_message_id = ephemeralMessageId;
4078
+ form.media = stringify(media);
4079
+ return this._request('editEphemeralMessageMedia', { form });
4080
+ }
4081
+
4082
+ /**
4083
+ * Use this method to edit the caption of an ephemeral message.
4084
+ *
4085
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4086
+ * @param {String} ephemeralMessageId Unique identifier of the ephemeral message
4087
+ * @param {Object} [options] Additional Telegram query options
4088
+ * @return {Promise} On success, the edited Message object is returned
4089
+ * @see https://core.telegram.org/bots/api#editephemeralmessagecaption
4090
+ */
4091
+ editEphemeralMessageCaption(chatId, ephemeralMessageId, form = {}) {
4092
+ form.chat_id = chatId;
4093
+ form.ephemeral_message_id = ephemeralMessageId;
4094
+ this._fixEntitiesField(form);
4095
+ return this._request('editEphemeralMessageCaption', { form });
4096
+ }
4097
+
4098
+ /**
4099
+ * Use this method to edit the reply markup of an ephemeral message.
4100
+ *
4101
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4102
+ * @param {String} ephemeralMessageId Unique identifier of the ephemeral message
4103
+ * @param {Object} [options] Additional Telegram query options
4104
+ * @return {Promise} On success, the edited Message object is returned
4105
+ * @see https://core.telegram.org/bots/api#editephemeralmessagereplymarkup
4106
+ */
4107
+ editEphemeralMessageReplyMarkup(chatId, ephemeralMessageId, form = {}) {
4108
+ form.chat_id = chatId;
4109
+ form.ephemeral_message_id = ephemeralMessageId;
4110
+ return this._request('editEphemeralMessageReplyMarkup', { form });
4111
+ }
4112
+
4113
+ /**
4114
+ * Use this method to delete an ephemeral message.
4115
+ *
4116
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4117
+ * @param {String} ephemeralMessageId Unique identifier of the ephemeral message
4118
+ * @param {Object} [options] Additional Telegram query options
4119
+ * @return {Promise} True on success
4120
+ * @see https://core.telegram.org/bots/api#deleteephemeralmessage
4121
+ */
4122
+ deleteEphemeralMessage(chatId, ephemeralMessageId, form = {}) {
4123
+ form.chat_id = chatId;
4124
+ form.ephemeral_message_id = ephemeralMessageId;
4125
+ return this._request('deleteEphemeralMessage', { form });
4126
+ }
4127
+
3117
4128
  }
3118
4129
 
3119
4130
  module.exports = TelegramBot;