diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt index 47465ef96b..f205ae37e9 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.webapps.cloud.CloudStorage import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo import dev.inmo.tgbotapi.webapps.popup.* +import dev.inmo.tgbotapi.webapps.stories.StoryShareParams external class WebApp { val version: String @@ -101,6 +102,8 @@ external class WebApp { fun openTelegramLink(url: String) fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally) + fun shareToStory(mediaUrl: String, params: StoryShareParams?) + fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally) fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally) } diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt new file mode 100644 index 0000000000..2ecb275909 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.webapps.stories + +external interface StoryShareParams { + val text: String + @JsName("widget_link") + val widgetLink: StoryWidgetLink? +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt new file mode 100644 index 0000000000..61ee95a034 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt @@ -0,0 +1,18 @@ +package dev.inmo.tgbotapi.webapps.stories + +import kotlin.js.json + +external interface StoryWidgetLink { + val url: String + val name: String? +} + +fun StoryWidgetLink( + url: String, + name: String? +): StoryWidgetLink { + val result: dynamic = js("{}") + result["url"] = url + name ?.let { result["name"] = it } + return result.unsafeCast() +}