1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 11:08:43 +00:00

add shareToStory in WebApp

This commit is contained in:
InsanusMokrassar 2024-08-01 17:26:18 +06:00
parent 88008b7cfc
commit 010c52adeb
3 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.webapps.cloud.CloudStorage
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback import dev.inmo.tgbotapi.webapps.haptic.HapticFeedback
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
import dev.inmo.tgbotapi.webapps.popup.* import dev.inmo.tgbotapi.webapps.popup.*
import dev.inmo.tgbotapi.webapps.stories.StoryShareParams
external class WebApp { external class WebApp {
val version: String val version: String
@ -101,6 +102,8 @@ external class WebApp {
fun openTelegramLink(url: String) fun openTelegramLink(url: String)
fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally) fun openInvoice(url: String, callback: (InvoiceClosedInfo) -> Unit = definedExternally)
fun shareToStory(mediaUrl: String, params: StoryShareParams?)
fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally) fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally)
fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally) fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally)
} }

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.webapps.stories
external interface StoryShareParams {
val text: String
@JsName("widget_link")
val widgetLink: StoryWidgetLink?
}

View File

@ -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<StoryWidgetLink>()
}