update examples for ktgbotapi 38.0.0

This commit is contained in:
InsanusMokrassar committed 2026-11-26 12:28:56 +06:00
1 parent d0da6c851b
commit 97b4391495
86 files changed
+888 -370

No files matched your search

+2 -3
View File
@@ -5,9 +5,8 @@ message addresses the bot by username.
## Trigger and replies
There are no slash commands. The bot handles a content message only when its
text contains the bot's full username. This is a case-sensitive substring
check; messages without text or without the username are ignored.
The bot greets messages whose text contains its primary username or an active alias
returned by `getMe`. The match includes the leading `@` and ignores case.
- In a private chat, it replies with a MarkdownV2 text mention of the user.
- In a group or supergroup, it greets the group and links its title to a public
+1 -1
View File
@@ -11,7 +11,7 @@ buildscript {
apply plugin: 'kotlin'
apply plugin: 'application'
mainClassName="HelloBotKt"
application.mainClass = "HelloBotKt"
dependencies {
+4 -1
View File
@@ -32,8 +32,11 @@ suspend fun main(vararg args: String) {
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
val me = getMe()
val usernames = listOfNotNull(me.username) + me.activeUsernames
onContentMessage(
initialFilter = initialFilter@{ it.text ?.contains(me.username ?.full ?: return@initialFilter false) == true }
initialFilter = { message ->
usernames.any { message.text?.contains(it.full, ignoreCase = true) == true }
}
) { message ->
val answerText = when (val chat = message.chat) {
is PreviewChannelChat -> {