Skip to content

Commit

Permalink
several fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Jun 1, 2024
1 parent 41fc5a9 commit 3a35995
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,7 +40,8 @@ suspend fun activateResenderBot(
entities = quote ?.textSources ?: emptyList(),
quotePosition = quote ?.position
)
}
},
effectId = it.possiblyWithEffectMessageOrNull() ?.effectId
)
) {
it.forEach(print)
Expand Down
17 changes: 15 additions & 2 deletions StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 ->
Expand All @@ -100,5 +109,9 @@ suspend fun main(args: Array<String>) {
}
}
}

allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
println(it)
}
}.second.join()
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-branch_14.0.0-build2248
micro_utils_version=0.20.45
serialization_version=1.6.3
ktor_version=2.3.10

0 comments on commit 3a35995

Please sign in to comment.