mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-22 16:23:54 +00:00
Merge pull request #168 from InsanusMokrassar/renovate/telegram_bot_api_version
Update telegram_bot_api_version to v4.1.0
This commit is contained in:
commit
4186ab8270
@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sameThread
|
import dev.inmo.tgbotapi.extensions.utils.extensions.sameThread
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
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
|
||||||
@ -19,8 +19,8 @@ import kotlinx.coroutines.flow.filter
|
|||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
sealed interface BotState : State
|
sealed interface BotState : State
|
||||||
data class ExpectContentOrStopState(override val context: Pair<ChatId, MessageThreadId?>, val sourceMessage: CommonMessage<TextContent>) : BotState
|
data class ExpectContentOrStopState(override val context: IdChatIdentifier, val sourceMessage: CommonMessage<TextContent>) : BotState
|
||||||
data class StopState(override val context: Pair<ChatId, MessageThreadId?>) : BotState
|
data class StopState(override val context: IdChatIdentifier) : BotState
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
@ -43,8 +43,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
) {
|
) {
|
||||||
strictlyOn<ExpectContentOrStopState> {
|
strictlyOn<ExpectContentOrStopState> {
|
||||||
send(
|
send(
|
||||||
it.context.first,
|
it.context,
|
||||||
threadId = it.context.second
|
|
||||||
) {
|
) {
|
||||||
+"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"
|
||||||
}
|
}
|
||||||
@ -57,13 +56,13 @@ suspend fun main(args: Array<String>) {
|
|||||||
when {
|
when {
|
||||||
content is TextContent && content.parseCommandsWithParams().keys.contains("stop") -> StopState(it.context)
|
content is TextContent && content.parseCommandsWithParams().keys.contains("stop") -> StopState(it.context)
|
||||||
else -> {
|
else -> {
|
||||||
execute(content.createResend(it.context.first, messageThreadId = it.context.second))
|
execute(content.createResend(it.context))
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strictlyOn<StopState> {
|
strictlyOn<StopState> {
|
||||||
send(it.context.first, threadId = it.context.second) { +"You have stopped sending of content" }
|
send(it.context) { +"You have stopped sending of content" }
|
||||||
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@ -71,7 +70,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
command(
|
command(
|
||||||
"start"
|
"start"
|
||||||
) {
|
) {
|
||||||
startChain(ExpectContentOrStopState(it.chat.id to it.threadIdOrNull, it))
|
startChain(ExpectContentOrStopState(it.chat.id, it))
|
||||||
}
|
}
|
||||||
}.second.join()
|
}.second.join()
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
|
|||||||
|
|
||||||
|
|
||||||
kotlin_version=1.7.21
|
kotlin_version=1.7.21
|
||||||
telegram_bot_api_version=4.0.0
|
telegram_bot_api_version=4.1.0
|
||||||
micro_utils_version=0.14.1
|
micro_utils_version=0.14.1
|
||||||
serialization_version=1.4.1
|
serialization_version=1.4.1
|
||||||
ktor_version=2.1.3
|
ktor_version=2.1.3
|
||||||
|
Loading…
Reference in New Issue
Block a user