From 69da206ffbab09b4aeb9b7c9e585b215ca281dee Mon Sep 17 00:00:00 2001 From: Dmitry <56270217+DavisDmitry@users.noreply.github.com> Date: Fri, 2 Aug 2024 18:01:10 +0500 Subject: [PATCH] Bot API 7.8 (#21) - Added the option for bots to set a Main Mini App, which can be previewed and launched directly from a button in the bot's profile or a link. - Added the method shareToStory to the class WebApp. --- README.md | 4 ++-- package.json | 2 +- src/index.d.ts | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5247770..50273c5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ npm

-Telegram Bot API Version 7.7 +Telegram Bot API Version 7.8

CI Lint @@ -47,7 +47,7 @@ Include the types file inside your [ `tsconfig.json` ](https://www.typescriptlan ```diff { "compilerOptions": { - "typeRoots": [ + "types": [ + "./node_modules/telegram-webapps" ] } diff --git a/package.json b/package.json index bea95a4..73a1d2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram-webapps", - "version": "7.7.0", + "version": "7.8.0", "description": "Typings for Telegram Mini Apps", "keywords": [ "telegram", diff --git a/src/index.d.ts b/src/index.d.ts index 06603cc..13dffa1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -445,6 +445,12 @@ export declare namespace TelegramWebApps { * invoice status will be passed as the first argument. */ openInvoice(url: string, callback?: InvoiceClosedEventHandler): void + /** + * `Bot API 7.8+` A method that opens the native story editor with the media specified + * in the *media_url* parameter as an HTTPS URL. An optional *params* argument of the + * type StoryShareParams describes additional sharing settings. + */ + shareToStory(media_url: string, params?: StoryShareParams): void /** * `Bot API 6.2+` A method that shows a native popup described by the *params* * argument of the type PopupParams. The Web App will receive the event *popupClosed* @@ -642,6 +648,37 @@ export declare namespace TelegramWebApps { destructive_text_color?: string } + /** + * This object describes additional sharing settings for the native story editor. + */ + interface StoryShareParams { + /** + * The caption to be added to the media, 0-200 characters for regular users and 0-2048 + * characters for premium subscribers. + */ + text?: string + /** + * An object that describes a widget link to be included in the story. Note that only + * premium subscribers can post stories with links. + */ + widget_link?: StoryWidgetLink + } + + /** + * This object describes a widget link to be included in the story. + */ + + interface StoryWidgetLink { + /** + * The URL to be included in the story. + */ + url: string + /** + * The name to be displayed for the widget link, 0-48 characters. + */ + name?: string + } + /** * This object describes the native popup. */