update readmes

This commit is contained in:
2026-08-21 15:51:06 +06:00
parent 016400a821
commit ce48393895
104 changed files with 2615 additions and 333 deletions

View File

@@ -25,6 +25,11 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.currentCoroutineContext
/**
* Parses pagination callback data whose first two space-separated fields are the page and total page count.
*
* @return the parsed page and count, or `null` when either field is missing or is not an integer
*/
fun String.parsePageAndCount(): Pair<Int, Int>? {
val (pageString, countString) = split(" ").takeIf { it.count() > 1 } ?: return null
return Pair(
@@ -33,6 +38,15 @@ fun String.parsePageAndCount(): Pair<Int, Int>? {
)
}
/**
* Adds the pagination controls used by command replies and inline-query results.
*
* The controls include nearby page callbacks, first/last-page jumps when applicable, a button that copies the
* corresponding `/inline` command, and a button that starts inline mode for a user-selected chat.
*
* @param page the current page; callers should keep it within `1..count`
* @param count the total number of pages; callers should pass a positive value
*/
fun InlineKeyboardBuilder.includePageButtons(page: Int, count: Int) {
val numericButtons = listOfNotNull(
page - 1,
@@ -78,6 +92,15 @@ fun InlineKeyboardBuilder.includePageButtons(page: Int, count: Int) {
}
}
/**
* Creates and runs the shared KeyboardsBot behavior using long polling.
*
* The bot serves `/inline` pagination keyboards, edits them in response to callback queries, answers compatible
* inline queries, offers an `/inline` reply-keyboard button for unhandled commands, and logs every received update.
*
* @param token the Telegram bot token
* @param print receives the bot information returned by the startup `getMe` request
*/
@OptIn(PreviewFeature::class)
suspend fun activateKeyboardsBot(
token: String,

View File

@@ -4,6 +4,12 @@ import org.w3c.dom.*
private val scope = CoroutineScope(Dispatchers.Default)
/**
* Installs the browser launch form after `DOMContentLoaded`.
*
* Every submission reads the token from `bot_token`, appends a result container under `bots_container`, and launches
* [activateKeyboardsBot]. The result of its startup `getMe` request is rendered in that new container.
*/
fun main() {
document.addEventListener(
"DOMContentLoaded",