mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-29 13:38:49 +00:00
commit
a8c5d403c6
@ -3,6 +3,7 @@ import dev.inmo.tgbotapi.types.webAppQueryIdField
|
|||||||
import dev.inmo.tgbotapi.webapps.*
|
import dev.inmo.tgbotapi.webapps.*
|
||||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackStyle
|
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackStyle
|
||||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackType
|
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackType
|
||||||
|
import dev.inmo.tgbotapi.webapps.popup.*
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
@ -68,6 +69,79 @@ fun main() {
|
|||||||
})
|
})
|
||||||
appendText("Example button")
|
appendText("Example button")
|
||||||
} ?: window.alert("Unable to load body")
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
|
document.body ?.appendElement("p", {})
|
||||||
|
document.body ?.appendText("Alerts:")
|
||||||
|
|
||||||
|
document.body ?.appendElement("button") {
|
||||||
|
addEventListener("click", {
|
||||||
|
webApp.showPopup(
|
||||||
|
PopupParams(
|
||||||
|
"It is sample title of default button",
|
||||||
|
"It is sample message of default button",
|
||||||
|
DefaultPopupButton("default", "Default button"),
|
||||||
|
OkPopupButton("ok"),
|
||||||
|
DestructivePopupButton("destructive", "Destructive button")
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
document.body ?.log(
|
||||||
|
when (it) {
|
||||||
|
"default" -> "You have clicked default button in popup"
|
||||||
|
"ok" -> "You have clicked ok button in popup"
|
||||||
|
"destructive" -> "You have clicked destructive button in popup"
|
||||||
|
else -> "I can't imagine where you take button with id $it"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
appendText("Popup")
|
||||||
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
|
document.body ?.appendElement("button") {
|
||||||
|
addEventListener("click", {
|
||||||
|
webApp.showAlert(
|
||||||
|
"This is alert message"
|
||||||
|
) {
|
||||||
|
document.body ?.log(
|
||||||
|
"You have closed alert"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
appendText("Alert")
|
||||||
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
|
document.body ?.appendElement("button") {
|
||||||
|
addEventListener("click", {
|
||||||
|
webApp.showConfirm(
|
||||||
|
"This is confirm message"
|
||||||
|
) {
|
||||||
|
document.body ?.log(
|
||||||
|
"You have pressed \"${if (it) "Ok" else "Cancel"}\" in confirm"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
appendText("Confirm")
|
||||||
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
|
document.body ?.appendElement("p", {})
|
||||||
|
|
||||||
|
document.body ?.appendElement("button") {
|
||||||
|
fun updateText() {
|
||||||
|
textContent = if (webApp.isClosingConfirmationEnabled) {
|
||||||
|
"Disable closing confirmation"
|
||||||
|
} else {
|
||||||
|
"Enable closing confirmation"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addEventListener("click", {
|
||||||
|
webApp.toggleClosingConfirmation()
|
||||||
|
updateText()
|
||||||
|
})
|
||||||
|
updateText()
|
||||||
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
|
document.body ?.appendElement("p", {})
|
||||||
|
|
||||||
webApp.apply {
|
webApp.apply {
|
||||||
onThemeChanged {
|
onThemeChanged {
|
||||||
document.body ?.log("Theme changed: ${webApp.themeParams}")
|
document.body ?.log("Theme changed: ${webApp.themeParams}")
|
||||||
|
@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
|
|||||||
|
|
||||||
|
|
||||||
kotlin_version=1.7.10
|
kotlin_version=1.7.10
|
||||||
telegram_bot_api_version=3.1.0
|
telegram_bot_api_version=3.1.1
|
||||||
micro_utils_version=0.12.1
|
micro_utils_version=0.12.1
|
||||||
serialization_version=1.4.0-RC
|
serialization_version=1.4.0-RC
|
||||||
ktor_version=2.1.0
|
ktor_version=2.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user