mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-25 19:48:49 +00:00
commit
27790a2576
@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
|||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.utils.botCommand
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
@ -37,12 +38,11 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
strictlyOn<ExpectContentOrStopState> {
|
strictlyOn<ExpectContentOrStopState> {
|
||||||
sendMessage(
|
send(
|
||||||
it.context,
|
it.context
|
||||||
buildEntities {
|
) {
|
||||||
+"Send me some content or " + botCommand("stop") + " if you want to stop sending"
|
+"Send me some content or " + botCommand("stop") + " if you want to stop sending"
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
val contentMessage = waitContentMessage().first()
|
val contentMessage = waitContentMessage().first()
|
||||||
val content = contentMessage.content
|
val content = contentMessage.content
|
||||||
@ -56,7 +56,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
strictlyOn<StopState> {
|
strictlyOn<StopState> {
|
||||||
send(it.context, "You have stopped sending of content")
|
send(it.context) { +"You have stopped sending of content" }
|
||||||
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import dev.inmo.tgbotapi.types.chat.CommonBot
|
|||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
|
import dev.inmo.tgbotapi.utils.code
|
||||||
|
import dev.inmo.tgbotapi.utils.regular
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,9 +35,10 @@ suspend fun main(vararg args: String) {
|
|||||||
regular("User ")
|
regular("User ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is CommonBot,
|
is CommonBot,
|
||||||
is ExtendedBot -> regular("Bot ")
|
is ExtendedBot -> regular("Bot ")
|
||||||
} + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})"
|
} + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username?.username ?: "Without username"})"
|
||||||
}
|
}
|
||||||
is ForwardInfo.PublicChat.FromChannel -> regular("Channel (") + code(forwardInfo.channelChat.title) + ")"
|
is ForwardInfo.PublicChat.FromChannel -> regular("Channel (") + code(forwardInfo.channelChat.title) + ")"
|
||||||
is ForwardInfo.PublicChat.FromSupergroup -> regular("Supergroup (") + code(forwardInfo.group.title) + ")"
|
is ForwardInfo.PublicChat.FromSupergroup -> regular("Supergroup (") + code(forwardInfo.group.title) + ")"
|
||||||
|
@ -7,12 +7,11 @@ import dev.inmo.tgbotapi.extensions.api.edit.edit
|
|||||||
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.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
private const val nextPageData = "next"
|
private const val nextPageData = "next"
|
||||||
@ -71,13 +70,14 @@ suspend fun activateKeyboardsBot(
|
|||||||
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
|
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
|
||||||
reply(
|
reply(
|
||||||
message,
|
message,
|
||||||
"Your inline keyboard with $numberOfPages pages",
|
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
includePageButtons(1, numberOfPages)
|
includePageButtons(1, numberOfPages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
) {
|
||||||
|
regular("Your inline keyboard with $numberOfPages pages")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageDataCallbackQuery {
|
onMessageDataCallbackQuery {
|
||||||
@ -86,35 +86,33 @@ suspend fun activateKeyboardsBot(
|
|||||||
return@onMessageDataCallbackQuery
|
return@onMessageDataCallbackQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
val text = "This is $page of $count"
|
|
||||||
|
|
||||||
edit(
|
edit(
|
||||||
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
|
||||||
},
|
},
|
||||||
text,
|
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
includePageButtons(page, count)
|
includePageButtons(page, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
) {
|
||||||
|
regular("This is $page of $count")
|
||||||
|
}
|
||||||
answer(it)
|
answer(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnhandledCommand {
|
onUnhandledCommand {
|
||||||
reply(
|
reply(
|
||||||
it,
|
it,
|
||||||
buildEntities {
|
|
||||||
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
|
||||||
},
|
|
||||||
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
||||||
row {
|
row {
|
||||||
simpleButton("/inline")
|
simpleButton("/inline")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
) {
|
||||||
|
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
||||||
|
@ -7,10 +7,11 @@ import dev.inmo.tgbotapi.extensions.api.get.getStickerSet
|
|||||||
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.*
|
|
||||||
import dev.inmo.tgbotapi.types.StickerType
|
import dev.inmo.tgbotapi.types.StickerType
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
import dev.inmo.tgbotapi.utils.bold
|
||||||
|
import dev.inmo.tgbotapi.utils.buildEntities
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
fun StickerSet.buildInfo() = buildEntities {
|
fun StickerSet.buildInfo() = buildEntities {
|
||||||
|
@ -7,16 +7,13 @@ 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
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
||||||
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.*
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.call
|
import io.ktor.server.application.call
|
||||||
import io.ktor.server.http.content.*
|
import io.ktor.server.http.content.*
|
||||||
|
@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
|
|||||||
|
|
||||||
|
|
||||||
kotlin_version=1.7.10
|
kotlin_version=1.7.10
|
||||||
telegram_bot_api_version=3.2.4
|
telegram_bot_api_version=3.2.6
|
||||||
micro_utils_version=0.12.13
|
micro_utils_version=0.12.13
|
||||||
serialization_version=1.4.0
|
serialization_version=1.4.0
|
||||||
ktor_version=2.1.1
|
ktor_version=2.1.1
|
||||||
|
Loading…
Reference in New Issue
Block a user