mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-24 19:18:49 +00:00
update examples
This commit is contained in:
parent
e772cfda3b
commit
0489f217b3
@ -2,12 +2,16 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
|
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||||
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
@ -82,12 +86,14 @@ suspend fun activateKeyboardsBot(
|
|||||||
return@onMessageDataCallbackQuery
|
return@onMessageDataCallbackQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val text = "This is $page of $count"
|
||||||
|
|
||||||
editMessageText(
|
editMessageText(
|
||||||
it.message.withContent<TextContent>() ?: it.let {
|
it.message.withContent<TextContent>() ?: it.let {
|
||||||
answer(it, "Unsupported message type :(")
|
answer(it, "Unsupported message type :(")
|
||||||
return@onMessageDataCallbackQuery
|
return@onMessageDataCallbackQuery
|
||||||
},
|
},
|
||||||
"This is $page of $count",
|
text,
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
includePageButtons(page, count)
|
includePageButtons(page, count)
|
||||||
@ -96,6 +102,22 @@ suspend fun activateKeyboardsBot(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUnhandledCommand {
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
buildEntities {
|
||||||
|
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
||||||
|
},
|
||||||
|
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
||||||
|
row {
|
||||||
|
simpleButton("/inline")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
||||||
|
|
||||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
println(it)
|
println(it)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import dev.inmo.tgbotapi.extensions.api.send.*
|
|||||||
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||||
@ -85,7 +87,13 @@ suspend fun main(vararg args: String) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
onUnhandledCommand {
|
onUnhandledCommand {
|
||||||
println("Unhandled command: ${it.content}")
|
reply(
|
||||||
|
it,
|
||||||
|
buildEntities {
|
||||||
|
+"Use " + botCommand("inline") + " to get inline web app button\n"
|
||||||
|
+"Use " + botCommand("reply_markup") + " to get reply markup web app button\n"
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
setMyCommands(
|
setMyCommands(
|
||||||
BotCommand("reply_markup", "Use to get reply markup keyboard with web app trigger"),
|
BotCommand("reply_markup", "Use to get reply markup keyboard with web app trigger"),
|
||||||
|
Loading…
Reference in New Issue
Block a user