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.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
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.shortcuts.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlin.coroutines.coroutineContext
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
|
|
||||||
suspend fun activateResenderBot(
|
suspend fun activateResenderBot(
|
||||||
token: String,
|
token: String,
|
||||||
@ -18,26 +16,24 @@ suspend fun activateResenderBot(
|
|||||||
|
|
||||||
print(bot.getMe())
|
print(bot.getMe())
|
||||||
|
|
||||||
supervisorScope {
|
bot.buildBehaviour(CoroutineScope(coroutineContext + SupervisorJob())) {
|
||||||
val scope = this
|
onContentMessage(
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
additionalFilter = { it !is MediaGroupMessage<*> }
|
||||||
filterContentMessages<MessageContent>(scope).onEach {
|
) {
|
||||||
it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach {
|
it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach {
|
||||||
bot.executeUnsafe(it) {
|
executeUnsafe(it) {
|
||||||
it.forEach(print)
|
it.forEach(print)
|
||||||
} ?.also {
|
} ?.also(print)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
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
|
org.gradle.parallel=true
|
||||||
|
|
||||||
kotlin_version=1.4.21
|
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
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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