diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index f333ce0ee4..8f63bf469c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -40,6 +40,12 @@ value class GiftId( val string: String ) +@Serializable +@JvmInline +value class PreparedMessageId( + val string: String +) + val usernameRegex = Regex("@[\\w\\d_]+") val degreesLimit = 1 .. 360 diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt new file mode 100644 index 0000000000..e39ca9f371 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/HomeScreenStatus.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.webapps + +enum class HomeScreenStatus(val value: String) { + Unsupported("unsupported"), + Unknown("unknown"), + Added("added"), + Missed("missed"), +} 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 c782c821cd..1f8ad2407c 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 @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.webapps +import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.PreparedMessageId import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.webapps.biometric.BiometricManager import dev.inmo.tgbotapi.webapps.cloud.CloudStorage @@ -13,6 +15,8 @@ external class WebApp { val platform: String + val isActive: Boolean + val initData: String val initDataUnsafe: WebAppInitData @@ -52,6 +56,19 @@ external class WebApp { fun closeScanQrPopup() fun readTextFromClipboard(callback: TextReceivedCallback? = definedExternally) + val isFullscreen: Boolean + fun requestFullscreen() + fun exitFullscreen() + + val isOrientationLocked: Boolean + fun lockOrientation() + fun unlockOrientation() + + fun addToHomeScreen() + fun checkHomeScreenStatus(callback: (HomeScreenStatus) -> Unit = definedExternally) + + fun shareMessage(messageId: PreparedMessageId, callback: (Boolean) -> Unit = definedExternally) + @JsName("MainButton") val mainButton: BottomButton @JsName("SecondaryButton") diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt index 78c7528233..960a4360e5 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebAppInitData.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.webapps import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.ChatType external interface WebAppInitData { @JsName("query_id") @@ -9,6 +10,14 @@ external interface WebAppInitData { val user: WebAppUser? val receiver: WebAppUser? + val chat: WebAppChat + + @JsName("chat_type") + val chatType: ChatType? + + @JsName("chat_instance") + val chatInstance: String? + @JsName("start_param") val startParam: String? @@ -16,9 +25,9 @@ external interface WebAppInitData { val authDate: MilliSeconds @JsName("can_send_after") - val canSendAfter: MilliSeconds - - val chat: WebAppChat + val canSendAfter: MilliSeconds? val hash: String + + val signature: String }