Compare commits

..

2 Commits

Author SHA1 Message Date
renovate[bot]
327562a97e Merge 8cde2d8bc6 into 41fc5a9a4c 2024-05-10 14:57:26 +00:00
renovate[bot]
8cde2d8bc6 Update dependency dev.inmo:micro_utils.ktor.server to v0.20.49 2024-05-10 14:57:23 +00:00
4 changed files with 14 additions and 44 deletions

View File

@@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups 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.filters.MessageFilterByChat
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* 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.shortcuts.*
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.ReplyParameters
@@ -40,8 +39,7 @@ suspend fun activateResenderBot(
entities = quote ?.textSources ?: emptyList(), entities = quote ?.textSources ?: emptyList(),
quotePosition = quote ?.position quotePosition = quote ?.position
) )
}, }
effectId = it.possiblyWithEffectMessageOrNull() ?.effectId
) )
) { ) {
it.forEach(print) it.forEach(print)

View File

@@ -1,5 +1,4 @@
import dev.inmo.micro_utils.coroutines.runCatchingSafely 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.bot.getMe
import dev.inmo.tgbotapi.extensions.api.files.downloadFile import dev.inmo.tgbotapi.extensions.api.files.downloadFile
import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp
@@ -78,18 +77,10 @@ suspend fun main(args: Array<String>) {
runCatchingSafely { runCatchingSafely {
getStickerSet(stickerSetName) getStickerSet(stickerSetName)
}.onSuccess { stickerSet -> }.onSuccess { stickerSet ->
runCatching { addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ ->
addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ ->
reply(
it,
getStickerSet(stickerSetName).stickers.last()
)
}
}.onFailure { exception ->
exception.printStackTrace()
reply( reply(
it, it,
"Unable to add sticker in stickerset" getStickerSet(stickerSetName).stickers.last()
) )
} }
}.onFailure { exception -> }.onFailure { exception ->
@@ -109,9 +100,5 @@ suspend fun main(args: Array<String>) {
} }
} }
} }
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
println(it)
}
}.second.join() }.second.join()
} }

View File

@@ -1,4 +1,7 @@
import dev.inmo.kslog.common.* 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.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
import dev.inmo.micro_utils.ktor.server.createKtorServer import dev.inmo.micro_utils.ktor.server.createKtorServer
import dev.inmo.tgbotapi.extensions.api.answers.answer import dev.inmo.tgbotapi.extensions.api.answers.answer
@@ -37,7 +40,6 @@ import java.nio.charset.Charset
* *
* * Telegram Token * * Telegram Token
* * URL where will be placed * * 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 * Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080
*/ */
@@ -56,7 +58,6 @@ suspend fun main(vararg args: String) {
} }
) )
} }
val initiationLogger = KSLog("Initialization")
val bot = telegramBot(telegramBotAPIUrlsKeeper) val bot = telegramBot(telegramBotAPIUrlsKeeper)
createKtorServer( createKtorServer(
@@ -68,28 +69,12 @@ suspend fun main(vararg args: String) {
) { ) {
routing { routing {
val baseJsFolder = File("WebApp/build/dist/js/") val baseJsFolder = File("WebApp/build/dist/js/")
val prodSubFolder = File(baseJsFolder, "productionExecutable") baseJsFolder.list() ?.forEach {
val devSubFolder = File(baseJsFolder, "developmentExecutable") if (it == "productionExecutable" || it == "developmentExecutable") {
staticFiles("", File(baseJsFolder, it)) {
val staticFolder = when { default("WebApp/build/dist/js/$it/index.html")
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") { post("inline") {
val requestBody = call.receiveText() val requestBody = call.receiveText()

View File

@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2344m
kotlin_version=1.9.23 kotlin_version=1.9.23
telegram_bot_api_version=14.0.0 telegram_bot_api_version=13.0.0
micro_utils_version=0.20.45 micro_utils_version=0.20.49
serialization_version=1.6.3 serialization_version=1.6.3
ktor_version=2.3.10 ktor_version=2.3.10