1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 08:37:12 +00:00

add a lot of things in web apps

This commit is contained in:
InsanusMokrassar 2024-12-05 09:41:31 +06:00
parent 4ac5e405ac
commit 1c6359f041
4 changed files with 43 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.webapps
enum class HomeScreenStatus(val value: String) {
Unsupported("unsupported"),
Unknown("unknown"),
Added("added"),
Missed("missed"),
}

View File

@ -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")

View File

@ -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
}