several fixes and improvements

This commit is contained in:
2024-06-01 13:19:00 +06:00
parent 41fc5a9a4c
commit 3a35995bc7
3 changed files with 19 additions and 4 deletions

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,10 +78,18 @@ suspend fun main(args: Array<String>) {
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<String>) {
}
}
}
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
println(it)
}
}.second.join()
}