Merge pull request #268 from InsanusMokrassar/14.0.0

14.0.0
This commit is contained in:
InsanusMokrassar 2024-06-01 20:32:53 +06:00 committed by GitHub
commit ad57e4142c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 13 deletions

View File

@ -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)

View File

@ -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,12 +78,20 @@ suspend fun main(args: Array<String>) {
runCatchingSafely {
getStickerSet(stickerSetName)
}.onSuccess { stickerSet ->
runCatching {
addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ ->
reply(
it,
getStickerSet(stickerSetName).stickers.last()
)
}
}.onFailure { exception ->
exception.printStackTrace()
reply(
it,
"Unable to add sticker in stickerset"
)
}
}.onFailure { exception ->
createNewStickerSet(
it.chat.id.toChatId(),
@ -100,5 +109,9 @@ suspend fun main(args: Array<String>) {
}
}
}
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
println(it)
}
}.second.join()
}

View File

@ -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()

View File

@ -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