From 9e0f43dcc0013363e39accf54f11dc7934df91ce Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Mar 2021 15:48:31 +0600 Subject: [PATCH] update --- FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt | 4 ++-- .../src/main/kotlin/ForwardInfoSenderBot.kt | 5 ++--- HelloBot/src/main/kotlin/HelloBot.kt | 4 ++-- .../ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt | 6 +----- .../src/main/kotlin/SlotMachineDetectorBot.kt | 4 ++-- build.gradle | 9 +++++++++ gradle.properties | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt b/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt index af0cbe8..a3acbec 100644 --- a/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt +++ b/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.extensions.api.downloadFile import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo import dev.inmo.tgbotapi.extensions.utils.flatMap import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent import dev.inmo.tgbotapi.utils.filenameFromUrl import kotlinx.coroutines.* @@ -22,7 +22,7 @@ suspend fun main(args: Array) { val bot = telegramBot(botToken) val scope = CoroutineScope(Dispatchers.Default) - bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { + bot.longPolling(scope = scope) { val flow = merge ( filterContentMessages(), mediaGroupMessages().flatMap() diff --git a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt index 1e8f632..04230e4 100644 --- a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt +++ b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt @@ -7,10 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.formatting.codeMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.formatting.regularMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.shortcuts.mediaGroupMessages import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2 import dev.inmo.tgbotapi.types.message.* -import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage import kotlinx.coroutines.* import kotlinx.coroutines.flow.* @@ -25,7 +24,7 @@ suspend fun main(vararg args: String) { val scope = CoroutineScope(Dispatchers.Default) - bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { + bot.longPolling(scope = scope) { (merge(messageFlow.asContentMessagesFlow(), mediaGroupMessages(scope).flatMap())).mapNotNull { it.asPossiblyForwardedMessage() }.onEach { message -> safely({ it.printStackTrace() }) { val toAnswer = when (val forwardInfo = message.forwardInfo) { diff --git a/HelloBot/src/main/kotlin/HelloBot.kt b/HelloBot/src/main/kotlin/HelloBot.kt index 2c34453..52eaebf 100644 --- a/HelloBot/src/main/kotlin/HelloBot.kt +++ b/HelloBot/src/main/kotlin/HelloBot.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.extensions.utils.asChannelChat import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2 -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2 import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.abstracts.* @@ -25,7 +25,7 @@ suspend fun main(vararg args: String) { val scope = CoroutineScope(Dispatchers.Default) - bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { + bot.longPolling(scope = scope) { messageFlow.onEach { safely { val message = it.data diff --git a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt index 929630e..8eeaf23 100644 --- a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt +++ b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt @@ -20,11 +20,7 @@ suspend fun activateResenderBot( onContentMessage( additionalFilter = { it !is MediaGroupMessage<*> } ) { - it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach { - executeUnsafe(it) { - it.forEach(print) - } ?.also(print) - } + executeUnsafe(it.content.createResend(it.chat.id, replyToMessageId = it.messageId)) } onVisualGallery { sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() }) diff --git a/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt b/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt index 3c0802f..4e7d425 100644 --- a/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt +++ b/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt @@ -3,7 +3,7 @@ import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.extensions.utils.shortcuts.filterContentMessages -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType import dev.inmo.tgbotapi.types.message.content.DiceContent import kotlinx.coroutines.* @@ -14,7 +14,7 @@ suspend fun main(args: Array) { val bot = telegramBot(args.first()) val scope = CoroutineScope(Dispatchers.Default) - bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { + bot.longPolling(scope = scope) { filterContentMessages(scope).onEach { val content = it.content val dice = content.dice diff --git a/build.gradle b/build.gradle index 37bd9c7..a909fa1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,5 +2,14 @@ allprojects { repositories { mavenLocal() jcenter() + if (project.hasProperty("GITHUB_USER") && project.hasProperty("GITHUB_TOKEN")) { + maven { + url "https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI" + credentials { + username = project.getProperty("GITHUB_USER") + password = project.getProperty("GITHUB_TOKEN") + } + } + } } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7eccd8e..e36803e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ kotlin.code.style=official org.gradle.parallel=true kotlin_version=1.4.31 -telegram_bot_api_version=0.32.8 +telegram_bot_api_version=0.33.0