Skip to content

Commit

Permalink
Merge branch 'main' into prefix-session-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf authored Nov 22, 2024
2 parents f541242 + f4a7f95 commit 051801f
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<!-- deno-fmt-ignore-start -->

[![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-)
Expand Down Expand Up @@ -319,6 +319,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center" valign="top" width="11.11%"><a href="https://www.vorant94.io/"><img src="https://avatars.githubusercontent.com/u/9719319?v=4?s=100" width="100px;" alt="Mordechai Dror"/><br /><sub><b>Mordechai Dror</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Avorant94" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mahovich"><img src="https://avatars.githubusercontent.com/u/2377626?v=4?s=100" width="100px;" alt="mahovich"/><br /><sub><b>mahovich</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=mahovich" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grammy",
"description": "The Telegram Bot Framework.",
"version": "1.31.3",
"version": "1.32.0",
"author": "KnorpelSenf",
"license": "MIT",
"engines": {
Expand All @@ -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"
Expand Down
85 changes: 85 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
91 changes: 91 additions & 0 deletions src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,23 @@ export class Api<R extends RawApi = RawApi> {
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<R, "setUserEmojiStatus", "user_id">,
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.
*
Expand Down Expand Up @@ -2463,6 +2480,36 @@ export class Api<R extends RawApi = RawApi> {
}, 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<R, "sendGift", "user_id" | "gift_id">,
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.
Expand Down Expand Up @@ -2505,6 +2552,28 @@ export class Api<R extends RawApi = RawApi> {
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<R, "savePreparedInlineMessage", "user_id" | "result">,
signal?: AbortSignal,
) {
return this.raw.savePreparedInlineMessage(
{ user_id, result, ...other },
signal,
);
}

/**
* Use this method to send invoices. On success, the sent Message is returned.
*
Expand Down Expand Up @@ -2676,6 +2745,28 @@ export class Api<R extends RawApi = RawApi> {
);
}

/**
* 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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/types.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 | (() => T | Promise<T>);
Expand Down
4 changes: 2 additions & 2 deletions src/types.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 051801f

Please sign in to comment.