Skip to content

Commit 541b76b

Browse files
Merge pull request #301 from InsanusMokrassar/20.0.0
20.0.0
2 parents b7d53a7 + 5b580b5 commit 541b76b

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ fun InlineKeyboardBuilder.includePageButtons(page: Int, count: Int) {
4545
}
4646
}
4747
}
48+
row {
49+
copyTextButton("Command copy button", "/inline $page $count")
50+
}
4851

4952
row {
5053
if (page - 1 > 2) {
@@ -84,11 +87,13 @@ suspend fun activateKeyboardsBot(
8487

8588
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
8689
onCommandWithArgs("inline") { message, args ->
87-
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
90+
val numberArgs = args.mapNotNull { it.toIntOrNull() }
91+
val numberOfPages = numberArgs.getOrNull(1) ?: numberArgs.firstOrNull() ?: 10
92+
val page = numberArgs.firstOrNull() ?.takeIf { numberArgs.size > 1 } ?.coerceAtLeast(1) ?: 1
8893
reply(
8994
message,
9095
replyMarkup = inlineKeyboard {
91-
includePageButtons(1, numberOfPages)
96+
includePageButtons(page, numberOfPages)
9297
}
9398
) {
9499
regular("Your inline keyboard with $numberOfPages pages")

KeyboardsBot/jvm_launcher/src/main/kotlin/KeyboardsBotJvm.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
import dev.inmo.kslog.common.KSLog
2+
import dev.inmo.kslog.common.LogLevel
3+
import dev.inmo.kslog.common.defaultMessageFormatter
4+
import dev.inmo.kslog.common.setDefaultKSLog
15
import kotlinx.coroutines.Dispatchers
26
import kotlinx.coroutines.withContext
37

48
suspend fun main(args: Array<String>) {
9+
val isDebug = args.any { it == "debug" }
10+
11+
if (isDebug) {
12+
setDefaultKSLog(
13+
KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
14+
println(defaultMessageFormatter(level, tag, message, throwable))
15+
}
16+
)
17+
}
18+
519
withContext(Dispatchers.IO) { // IO for inheriting of it in side of activateKeyboardsBot
620
activateKeyboardsBot(args.first()) {
721
println(it)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ kotlin.daemon.jvmargs=-Xmx3g -Xms500m
66

77

88
kotlin_version=2.0.21
9-
telegram_bot_api_version=19.0.0
9+
telegram_bot_api_version=20.0.0
1010
micro_utils_version=0.23.0
1111
serialization_version=1.7.3
1212
ktor_version=3.0.1

0 commit comments

Comments
 (0)