mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-09-13 11:34:13 +00:00
update readmes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
|
||||
/** Fixed sample custom emoji used by both the Web App and its bot-assisted route. */
|
||||
val CustomEmojiIdToSet = CustomEmojiId("5424939566278649034")
|
||||
|
||||
@@ -3,4 +3,5 @@ import dev.inmo.tgbotapi.types.request.RequestId
|
||||
import kotlin.random.Random
|
||||
import kotlin.random.nextUInt
|
||||
|
||||
/** Process-local request ID used when the bot saves its sample managed-bot button. */
|
||||
val preparedSampleKeyboardRequestId = RequestId(Random.nextUInt().toUShort())
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* JSON body used by server routes that validate Telegram Web App initialization.
|
||||
*
|
||||
* @property data raw `initData` received by the browser Web App.
|
||||
* @property hash hash exposed by the parsed, unsafe initialization data.
|
||||
*/
|
||||
@Serializable
|
||||
data class WebAppDataWrapper(
|
||||
val data: String,
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.w3c.dom.*
|
||||
import kotlin.random.Random
|
||||
import kotlin.random.nextUBytes
|
||||
|
||||
/** Appends [text] and a paragraph break to this HTML element. */
|
||||
fun HTMLElement.log(text: String) {
|
||||
appendText(text)
|
||||
appendElement("p", {})
|
||||
@@ -50,6 +51,10 @@ private object RootStyleSheet : StyleSheet() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Telegram Web App showcase and connects its controls to the JVM
|
||||
* server's same-origin validation and bot-helper routes.
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
fun main() {
|
||||
console.log("Web app started")
|
||||
|
||||
@@ -38,13 +38,13 @@ import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Accepts two parameters:
|
||||
* Starts the static Web App server and long-polling bot.
|
||||
*
|
||||
* * Telegram Token
|
||||
* * URL where will be placed
|
||||
* * Port (default 8080)
|
||||
*
|
||||
* Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080
|
||||
* The first element of [args] must be the bot token and the second the public Web
|
||||
* App URL used in Telegram buttons. The optional third element is parsed as the
|
||||
* listening port and defaults to `8080`. Exact `debug` and `testServer` values
|
||||
* enable diagnostic logging and Telegram's test environment, respectively.
|
||||
* Production JS output is served when present, otherwise development output.
|
||||
*/
|
||||
@OptIn(PreviewFeature::class)
|
||||
suspend fun main(vararg args: String) {
|
||||
|
||||
Reference in New Issue
Block a user