diff --git a/.all-contributorsrc b/.all-contributorsrc index fc902246..b5e620cd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1495,6 +1495,15 @@ "contributions": [ "review" ] + }, + { + "login": "mahovich", + "name": "mahovich", + "avatar_url": "https://avatars.githubusercontent.com/u/2377626?v=4", + "profile": "https://github.com/mahovich", + "contributions": [ + "doc" + ] } ] } diff --git a/README.md b/README.md index ade7f1b1..4a285392 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ -[![Bot API](https://img.shields.io/badge/Bot%20API-7.11-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) +[![Bot API](https://img.shields.io/badge/Bot%20API-8.0-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) [![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy) [![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy) [![All Contributors](https://img.shields.io/github/all-contributors/grammyjs/grammy?style=flat&labelColor=000&color=3b82f6)](#contributors-) @@ -319,6 +319,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Mordechai Dror
Mordechai Dror

👀 + mahovich
mahovich

📖 diff --git a/package.json b/package.json index ffd3e6cb..968bc3c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grammy", "description": "The Telegram Bot Framework.", - "version": "1.31.3", + "version": "1.32.0", "author": "KnorpelSenf", "license": "MIT", "engines": { @@ -17,7 +17,7 @@ "backport": "deno2node tsconfig.json" }, "dependencies": { - "@grammyjs/types": "3.15.0", + "@grammyjs/types": "3.16.0", "abort-controller": "^3.0.0", "debug": "^4.3.4", "node-fetch": "^2.7.0" diff --git a/src/context.ts b/src/context.ts index 4fe02a7c..4ce86ef3 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1590,6 +1590,25 @@ export class Context implements RenamedUpdate { ); } + /** + * Contex-aware alias for `api.serUserEmojiStatus`. Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus( + other?: Other<"setUserEmojiStatus", "user_id">, + signal?: AbortSignal, + ) { + return this.api.setUserEmojiStatus( + orThrow(this.from, "setUserEmojiStatus").id, + other, + signal, + ); + } + /** * Context-aware alias for `api.getUserChatBoosts`. Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. * @@ -2802,6 +2821,28 @@ export class Context implements RenamedUpdate { ); } + /** + * Context-aware alias for `api.sendGift`. Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success. + * + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + replyWithGift( + gift_id: string, + other?: Other<"sendGift", "user_id" | "gift_id">, + signal?: AbortSignal, + ) { + return this.api.sendGift( + orThrow(this.from, "sendGift").id, + gift_id, + other, + signal, + ); + } + /** * Context-aware alias for `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. @@ -2827,6 +2868,28 @@ export class Context implements RenamedUpdate { ); } + /** + * Context-aware alias for `api.savePreparedInlineMessage`. Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage( + result: InlineQueryResult, + other?: Other<"savePreparedInlineMessage", "user_id" | "result">, + signal?: AbortSignal, + ) { + return this.api.savePreparedInlineMessage( + orThrow(this.from, "savePreparedInlineMessage").id, + result, + other, + signal, + ); + } + /** * Context-aware alias for `api.sendInvoice`. Use this method to send invoices. On success, the sent Message is returned. * @@ -2932,6 +2995,28 @@ export class Context implements RenamedUpdate { ); } + /** + * Context-aware alias for `api.editUserStarSubscription`. Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription( + telegram_payment_charge_id: string, + is_canceled: boolean, + signal?: AbortSignal, + ) { + return this.api.editUserStarSubscription( + orThrow(this.from, "editUserStarSubscription").id, + telegram_payment_charge_id, + is_canceled, + signal, + ); + } + /** * Context-aware alias for `api.setPassportDataErrors`. Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. * diff --git a/src/core/api.ts b/src/core/api.ts index 92ab986d..95d62316 100644 --- a/src/core/api.ts +++ b/src/core/api.ts @@ -869,6 +869,23 @@ export class Api { return this.raw.getUserProfilePhotos({ user_id, ...other }, signal); } + /** + * Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus( + user_id: number, + other?: Other, + signal?: AbortSignal, + ) { + return this.raw.setUserEmojiStatus({ user_id, ...other }, signal); + } + /** * Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. * @@ -2463,6 +2480,36 @@ export class Api { }, signal); } + /** + * Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getavailablegifts + */ + getAvailableGifts(signal?: AbortSignal) { + return this.raw.getAvailableGifts(signal); + } + + /** + * Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success. + * + * @param user_id Unique identifier of the target user that will receive the gift + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + sendGift( + user_id: number, + gift_id: string, + other?: Other, + signal?: AbortSignal, + ) { + return this.raw.sendGift({ user_id, gift_id, ...other }, signal); + } + /** * Use this method to send answers to an inline query. On success, True is returned. * No more than 50 results per query are allowed. @@ -2505,6 +2552,28 @@ export class Api { return this.raw.answerWebAppQuery({ web_app_query_id, result }, signal); } + /** + * Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param user_id Unique identifier of the target user that can use the prepared message + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage( + user_id: number, + result: InlineQueryResult, + other?: Other, + signal?: AbortSignal, + ) { + return this.raw.savePreparedInlineMessage( + { user_id, result, ...other }, + signal, + ); + } + /** * Use this method to send invoices. On success, the sent Message is returned. * @@ -2676,6 +2745,28 @@ export class Api { ); } + /** + * Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param user_id Identifier of the user whose subscription will be edited + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription( + user_id: number, + telegram_payment_charge_id: string, + is_canceled: boolean, + signal?: AbortSignal, + ) { + return this.raw.editUserStarSubscription( + { user_id, telegram_payment_charge_id, is_canceled }, + signal, + ); + } + /** * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. * diff --git a/src/types.deno.ts b/src/types.deno.ts index 06ea9dc9..cfdb6776 100644 --- a/src/types.deno.ts +++ b/src/types.deno.ts @@ -14,13 +14,13 @@ import { type InputPaidMediaVideo as InputPaidMediaVideoF, type InputSticker as InputStickerF, type Opts as OptsF, -} from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; +} from "https://deno.land/x/grammy_types@v3.16.0/mod.ts"; import { debug as d, isDeno } from "./platform.deno.ts"; const debug = d("grammy:warn"); // === Export all API types -export * from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; +export * from "https://deno.land/x/grammy_types@v3.16.0/mod.ts"; /** A value, or a potentially async function supplying that value */ type MaybeSupplier = T | (() => T | Promise); diff --git a/src/types.web.ts b/src/types.web.ts index 3d18f427..79be74be 100644 --- a/src/types.web.ts +++ b/src/types.web.ts @@ -13,10 +13,10 @@ import { type InputPaidMediaVideo as InputPaidMediaVideoF, type InputSticker as InputStickerF, type Opts as OptsF, -} from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; +} from "https://deno.land/x/grammy_types@v3.16.0/mod.ts"; // === Export all API types -export * from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; +export * from "https://deno.land/x/grammy_types@v3.16.0/mod.ts"; /** Something that looks like a URL. */ interface URLLike {