diff --git a/README.md b/README.md index a6fffcc9..4e1727d4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ -[![Bot API](https://img.shields.io/badge/Bot%20API-7.10-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) +[![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) [![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-) diff --git a/package.json b/package.json index 4ba27986..37797edd 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "backport": "deno2node tsconfig.json" }, "dependencies": { - "@grammyjs/types": "3.14.0", + "@grammyjs/types": "3.15.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 2961bd81..4fe02a7c 100644 --- a/src/context.ts +++ b/src/context.ts @@ -2632,7 +2632,7 @@ export class Context implements RenamedUpdate { } /** - * Context-aware alias for `api.editMessageMedia`. Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * Context-aware alias for `api.editMessageMedia`. Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. * * @param media An object for a new media content of the message * @param other Optional remaining parameters, confer the official reference below diff --git a/src/convenience/keyboard.ts b/src/convenience/keyboard.ts index 619e3708..77177bff 100644 --- a/src/convenience/keyboard.ts +++ b/src/convenience/keyboard.ts @@ -1,4 +1,5 @@ import { + type CopyTextButton, type InlineKeyboardButton, type KeyboardButton, type KeyboardButtonPollType, @@ -6,6 +7,7 @@ import { type KeyboardButtonRequestUsers, type LoginUrl, type SwitchInlineQueryChosenChat, + type WebAppInfo, } from "../types.ts"; type KeyboardButtonSource = string | KeyboardButton; @@ -624,7 +626,7 @@ export class InlineKeyboard { * @param text The text to display * @param url An HTTPS URL of a Web App to be opened with additional data */ - webApp(text: string, url: string) { + webApp(text: string, url: string | WebAppInfo) { return this.add(InlineKeyboard.webApp(text, url)); } /** @@ -635,9 +637,9 @@ export class InlineKeyboard { */ static webApp( text: string, - url: string, + url: string | WebAppInfo, ): InlineKeyboardButton.WebAppButton { - return { text, web_app: { url } }; + return { text, web_app: typeof url === "string" ? { url } : url }; } /** * Adds a new login button. This can be used as a replacement for the @@ -789,6 +791,34 @@ export class InlineKeyboard { ): InlineKeyboardButton.SwitchInlineChosenChatButton { return { text, switch_inline_query_chosen_chat: query }; } + /** + * Adds a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display + * @param copyText The text to be copied to the clipboard + */ + copyText(text: string, copyText: string | CopyTextButton) { + return this.add(InlineKeyboard.copyText(text, copyText)); + } + /** + * Creates a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display + * @param copyText The text to be copied to the clipboard + */ + static copyText( + text: string, + copyText: string | CopyTextButton, + ): InlineKeyboardButton.CopyTextButtonButton { + return { + text, + copy_text: typeof copyText === "string" + ? { text: copyText } + : copyText, + }; + } /** * Adds a new game query button, confer * https://core.telegram.org/bots/api#games diff --git a/src/core/api.ts b/src/core/api.ts index 32640080..92ab986d 100644 --- a/src/core/api.ts +++ b/src/core/api.ts @@ -2002,7 +2002,7 @@ export class Api { } /** - * Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param message_id Identifier of the message to edit @@ -2030,7 +2030,7 @@ export class Api { } /** - * Use this method to edit animation, audio, document, photo, or video inline messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * Use this method to edit animation, audio, document, photo, or video inline messages, or to add media to text inline messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. * * @param inline_message_id Identifier of the inline message * @param media An object for a new media content of the message diff --git a/src/types.deno.ts b/src/types.deno.ts index 8effdf3e..06ea9dc9 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.14.0/mod.ts"; +} from "https://deno.land/x/grammy_types@v3.15.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.14.0/mod.ts"; +export * from "https://deno.land/x/grammy_types@v3.15.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 9f52ab55..3d18f427 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.14.0/mod.ts"; +} from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; // === Export all API types -export * from "https://deno.land/x/grammy_types@v3.14.0/mod.ts"; +export * from "https://deno.land/x/grammy_types@v3.15.0/mod.ts"; /** Something that looks like a URL. */ interface URLLike {