mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-22 08:13:53 +00:00
update tgbotapi version up to 0.32.1, gradle wrapper and resender bot logic according to update of tgbotapi
This commit is contained in:
parent
f5b526e0c5
commit
ccb29d6977
@ -1,14 +1,12 @@
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
suspend fun activateResenderBot(
|
||||
token: String,
|
||||
@ -18,26 +16,24 @@ suspend fun activateResenderBot(
|
||||
|
||||
print(bot.getMe())
|
||||
|
||||
supervisorScope {
|
||||
val scope = this
|
||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
||||
filterContentMessages<MessageContent>(scope).onEach {
|
||||
it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach {
|
||||
bot.executeUnsafe(it) {
|
||||
it.forEach(print)
|
||||
} ?.also {
|
||||
print(it)
|
||||
}
|
||||
}
|
||||
}.launchIn(scope)
|
||||
mediaGroupMessages(scope).onEach {
|
||||
safely({ print(it.stackTraceToString()) }) {
|
||||
println(it.chat)
|
||||
bot.execute(it.createResend(it.chat ?: return@safely, replyTo = it.first().messageId)).also {
|
||||
print(it)
|
||||
}
|
||||
}
|
||||
}.launchIn(scope)
|
||||
bot.buildBehaviour(CoroutineScope(coroutineContext + SupervisorJob())) {
|
||||
onContentMessage(
|
||||
additionalFilter = { it !is MediaGroupMessage<*> }
|
||||
) {
|
||||
it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach {
|
||||
executeUnsafe(it) {
|
||||
it.forEach(print)
|
||||
} ?.also(print)
|
||||
}
|
||||
}
|
||||
}
|
||||
onVisualGallery {
|
||||
sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
||||
}
|
||||
onPlaylist {
|
||||
sendPlaylist(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
||||
}
|
||||
onDocumentsGroup {
|
||||
sendDocumentsGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
||||
}
|
||||
}.join()
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ kotlin.code.style=official
|
||||
org.gradle.parallel=true
|
||||
|
||||
kotlin_version=1.4.21
|
||||
telegram_bot_api_version=0.31.0
|
||||
telegram_bot_api_version=0.32.1
|
||||
|
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-6.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
|
||||
|
Loading…
Reference in New Issue
Block a user