diff --git a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt index 4bbf65b..215bc4b 100644 --- a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt +++ b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* +import dev.inmo.tgbotapi.extensions.utils.possiblyWithEffectMessageOrNull import dev.inmo.tgbotapi.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.extensions.utils.withContentOrNull import dev.inmo.tgbotapi.types.ReplyParameters @@ -39,7 +40,8 @@ suspend fun activateResenderBot( entities = quote ?.textSources ?: emptyList(), quotePosition = quote ?.position ) - } + }, + effectId = it.possiblyWithEffectMessageOrNull() ?.effectId ) ) { it.forEach(print) diff --git a/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt b/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt index db0c802..bb6312f 100644 --- a/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt +++ b/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt @@ -1,4 +1,5 @@ import dev.inmo.micro_utils.coroutines.runCatchingSafely +import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.files.downloadFile import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp @@ -77,10 +78,18 @@ suspend fun main(args: Array) { runCatchingSafely { getStickerSet(stickerSetName) }.onSuccess { stickerSet -> - addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ -> + runCatching { + addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ -> + reply( + it, + getStickerSet(stickerSetName).stickers.last() + ) + } + }.onFailure { exception -> + exception.printStackTrace() reply( it, - getStickerSet(stickerSetName).stickers.last() + "Unable to add sticker in stickerset" ) } }.onFailure { exception -> @@ -100,5 +109,9 @@ suspend fun main(args: Array) { } } } + + allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + println(it) + } }.second.join() } diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index f603bf6..9b73204 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -1,7 +1,4 @@ -import dev.inmo.kslog.common.KSLog -import dev.inmo.kslog.common.LogLevel -import dev.inmo.kslog.common.defaultMessageFormatter -import dev.inmo.kslog.common.setDefaultKSLog +import dev.inmo.kslog.common.* import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.ktor.server.createKtorServer import dev.inmo.tgbotapi.extensions.api.answers.answer @@ -40,6 +37,7 @@ import java.nio.charset.Charset * * * Telegram Token * * URL where will be placed + * * Port (default 8080) * * Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080 */ @@ -58,6 +56,7 @@ suspend fun main(vararg args: String) { } ) } + val initiationLogger = KSLog("Initialization") val bot = telegramBot(telegramBotAPIUrlsKeeper) createKtorServer( @@ -69,12 +68,28 @@ suspend fun main(vararg args: String) { ) { routing { val baseJsFolder = File("WebApp/build/dist/js/") - baseJsFolder.list() ?.forEach { - if (it == "productionExecutable" || it == "developmentExecutable") { - staticFiles("", File(baseJsFolder, it)) { - default("WebApp/build/dist/js/$it/index.html") - } + val prodSubFolder = File(baseJsFolder, "productionExecutable") + val devSubFolder = File(baseJsFolder, "developmentExecutable") + + val staticFolder = when { + prodSubFolder.exists() -> { + initiationLogger.i("Folder for static is ${prodSubFolder.absolutePath}") + prodSubFolder } + devSubFolder.exists() -> { + initiationLogger.i("Folder for static is ${devSubFolder.absolutePath}") + devSubFolder + } + else -> error(""" + Unable to detect any folder with static. Current working directory: ${File("").absolutePath}. + Searched paths: + * ${prodSubFolder.absolutePath} + * ${devSubFolder.absolutePath} + """.trimIndent()) + } + + staticFiles("", staticFolder) { + default("${staticFolder.absolutePath}${File.separator}index.html") } post("inline") { val requestBody = call.receiveText() diff --git a/gradle.properties b/gradle.properties index 613a32e..cf3ad81 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2344m kotlin_version=1.9.23 -telegram_bot_api_version=13.0.0 +telegram_bot_api_version=14.0.0 micro_utils_version=0.20.45 serialization_version=1.6.3 ktor_version=2.3.10