mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-09-06 08:40:22 +00:00
add keyboards and update tgbotapi up to 0.38.12
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import kotlinx.browser.document
|
||||
import kotlinx.coroutines.*
|
||||
import org.w3c.dom.*
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
fun main() {
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
{
|
||||
val botsContainer = document.getElementById("bots_container") ?: return@addEventListener
|
||||
|
||||
(document.getElementById("bot_token_form") as? HTMLFormElement) ?.onsubmit = {
|
||||
(document.getElementById("bot_token") as? HTMLInputElement) ?.value ?.let { token ->
|
||||
val botContainer = document.createElement("div") as HTMLDivElement
|
||||
botsContainer.append(botContainer)
|
||||
|
||||
val infoDiv = document.createElement("div") as HTMLDivElement
|
||||
botContainer.append(infoDiv)
|
||||
|
||||
scope.launch {
|
||||
activateKeyboardsBot(token) {
|
||||
infoDiv.innerHTML = it.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
16
KeyboardsBot/KeyboardsBotLib/src/jsMain/resources/index.html
Normal file
16
KeyboardsBot/KeyboardsBotLib/src/jsMain/resources/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Keyboards bot</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="bot_token_form">
|
||||
<input type="text" id="bot_token">
|
||||
<input type="submit" value="Start bot">
|
||||
</form>
|
||||
<div id="start_offer">Type your bot token to the input above to start its work</div>
|
||||
<script type="text/javascript" src="KeyboardsBotLib.js"></script>
|
||||
<div id="bots_container"></div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user