several fixes and improvements

This commit is contained in:
InsanusMokrassar 2024-06-01 13:19:00 +06:00
parent 41fc5a9a4c
commit 3a35995bc7
3 changed files with 19 additions and 4 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.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
@ -39,7 +40,8 @@ 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,4 +1,5 @@
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
@ -77,12 +78,20 @@ 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( reply(
it, it,
getStickerSet(stickerSetName).stickers.last() getStickerSet(stickerSetName).stickers.last()
) )
} }
}.onFailure { exception ->
exception.printStackTrace()
reply(
it,
"Unable to add sticker in stickerset"
)
}
}.onFailure { exception -> }.onFailure { exception ->
createNewStickerSet( createNewStickerSet(
it.chat.id.toChatId(), it.chat.id.toChatId(),
@ -100,5 +109,9 @@ suspend fun main(args: Array<String>) {
} }
} }
} }
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
println(it)
}
}.second.join() }.second.join()
} }

View File

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