mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-09-03 14:49:05 +00:00
Compare commits
2 Commits
4eb80ea53c
...
4.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| f54a05b3e9 | |||
| d4ceafaa3d |
@@ -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.sameThread
|
||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
@@ -19,8 +19,8 @@ import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
sealed interface BotState : State
|
||||
data class ExpectContentOrStopState(override val context: IdChatIdentifier, val sourceMessage: CommonMessage<TextContent>) : BotState
|
||||
data class StopState(override val context: IdChatIdentifier) : BotState
|
||||
data class ExpectContentOrStopState(override val context: Pair<ChatId, MessageThreadId?>, val sourceMessage: CommonMessage<TextContent>) : BotState
|
||||
data class StopState(override val context: Pair<ChatId, MessageThreadId?>) : BotState
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
val botToken = args.first()
|
||||
@@ -43,7 +43,8 @@ suspend fun main(args: Array<String>) {
|
||||
) {
|
||||
strictlyOn<ExpectContentOrStopState> {
|
||||
send(
|
||||
it.context,
|
||||
it.context.first,
|
||||
threadId = it.context.second
|
||||
) {
|
||||
+"Send me some content or " + botCommand("stop") + " if you want to stop sending"
|
||||
}
|
||||
@@ -56,13 +57,13 @@ suspend fun main(args: Array<String>) {
|
||||
when {
|
||||
content is TextContent && content.parseCommandsWithParams().keys.contains("stop") -> StopState(it.context)
|
||||
else -> {
|
||||
execute(content.createResend(it.context))
|
||||
execute(content.createResend(it.context.first, messageThreadId = it.context.second))
|
||||
it
|
||||
}
|
||||
}
|
||||
}
|
||||
strictlyOn<StopState> {
|
||||
send(it.context) { +"You have stopped sending of content" }
|
||||
send(it.context.first, threadId = it.context.second) { +"You have stopped sending of content" }
|
||||
|
||||
null
|
||||
}
|
||||
@@ -70,7 +71,7 @@ suspend fun main(args: Array<String>) {
|
||||
command(
|
||||
"start"
|
||||
) {
|
||||
startChain(ExpectContentOrStopState(it.chat.id, it))
|
||||
startChain(ExpectContentOrStopState(it.chat.id to it.threadIdOrNull, it))
|
||||
}
|
||||
}.second.join()
|
||||
}
|
||||
|
||||
@@ -22,7 +22,5 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maven { url "https://git.inmo.dev/api/packages/InsanusMokrassar/maven" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx768m
|
||||
|
||||
|
||||
kotlin_version=1.7.22
|
||||
telegram_bot_api_version=5.0.0-branch_5.0.0-build1340
|
||||
micro_utils_version=0.16.4
|
||||
kotlin_version=1.7.21
|
||||
telegram_bot_api_version=4.1.0
|
||||
micro_utils_version=0.14.1
|
||||
serialization_version=1.4.1
|
||||
ktor_version=2.2.1
|
||||
ktor_version=2.1.3
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
|
||||
Reference in New Issue
Block a user