11package dev.inmo.plagubot.plugins.captcha
22
33import com.benasher44.uuid.uuid4
4- import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
5- import dev.inmo.micro_utils.coroutines.runCatchingSafely
6- import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions
4+ import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
5+ import dev.inmo.micro_utils.coroutines.runCatchingLogging
76import dev.inmo.micro_utils.koin.singleWithRandomQualifier
87import dev.inmo.micro_utils.repos.create
98import dev.inmo.plagubot.Plugin
@@ -198,7 +197,7 @@ class CaptchaBotPlugin : Plugin {
198197 val settings = chat.settings()
199198 if (! settings.enabled) return
200199
201- safelyWithoutExceptions {
200+ runCatching {
202201 if (settings.autoRemoveEvents && msg != null ) {
203202 deleteMessage(msg)
204203 }
@@ -218,7 +217,7 @@ class CaptchaBotPlugin : Plugin {
218217 newUsers = if (settings.casEnabled) {
219218 newUsers.filterNot { user ->
220219 casChecker.isBanned(user.id).also { isBanned ->
221- runCatchingSafely {
220+ runCatchingLogging {
222221 if (isBanned) {
223222 val entities = buildEntities {
224223 + " User " + mention(user) + " is banned in " + link(" CAS System" , " https://cas.chat/query?u=${user.id.chatId} " )
@@ -229,7 +228,7 @@ class CaptchaBotPlugin : Plugin {
229228 } ? : send(chat, entities)
230229
231230 when {
232- joinRequest -> runCatchingSafely { declineChatJoinRequest(chat.id, user.id) }
231+ joinRequest -> runCatchingLogging { declineChatJoinRequest(chat.id, user.id) }
233232 settings.kickOnUnsuccess -> banChatMember(chat.id, user)
234233 }
235234 }
@@ -244,7 +243,7 @@ class CaptchaBotPlugin : Plugin {
244243 newUsers.filterNot { user ->
245244 usersPassInfoRepo.havePassedChats(user.id, settings.captchaProvider.complexity).also {
246245 if (it) {
247- runCatchingSafely {
246+ runCatchingLogging {
248247 val entities = buildEntities {
249248 + " User " + mention(user) + " has passed captcha earlier. Captcha has been cancelled"
250249 }
@@ -254,7 +253,7 @@ class CaptchaBotPlugin : Plugin {
254253 } ? : send(chat, entities)
255254
256255 when {
257- joinRequest -> runCatchingSafely { approveChatJoinRequest(chat.id, user.id) }
256+ joinRequest -> runCatchingLogging { approveChatJoinRequest(chat.id, user.id) }
258257 else -> restrictChatMember(chat.id, user, permissions = defaultChatPermissions)
259258 }
260259 }
@@ -315,7 +314,7 @@ class CaptchaBotPlugin : Plugin {
315314 it.doAfterVerification(adminsAPI) {
316315 val settings = it.chat.settings()
317316 if (settings.autoRemoveCommands) {
318- safelyWithoutExceptions { deleteMessage(it) }
317+ runCatching { deleteMessage(it) }
319318 }
320319 val commands = it.parseCommandsWithArgs()
321320 val changeCommand = commands.keys.first {
@@ -452,7 +451,7 @@ class CaptchaBotPlugin : Plugin {
452451 )
453452
454453 reply(message, " Ok, new users didn't pass captcha will be kicked" ).apply {
455- launchSafelyWithoutExceptions {
454+ launchLoggingDropExceptions {
456455 delay(5000L )
457456 delete(this @apply)
458457 }
@@ -474,7 +473,7 @@ class CaptchaBotPlugin : Plugin {
474473 )
475474
476475 reply(message, " Ok, new users didn't passed captcha will NOT be kicked" ).apply {
477- launchSafelyWithoutExceptions {
476+ launchLoggingDropExceptions {
478477 delay(5000L )
479478 delete(this @apply)
480479 }
@@ -496,7 +495,7 @@ class CaptchaBotPlugin : Plugin {
496495 )
497496
498497 reply(message, " Ok, CAS banned user will automatically fail captcha" ).apply {
499- launchSafelyWithoutExceptions {
498+ launchLoggingDropExceptions {
500499 delay(5000L )
501500 delete(this @apply)
502501 }
@@ -518,7 +517,7 @@ class CaptchaBotPlugin : Plugin {
518517 )
519518
520519 reply(message, " Ok, CAS banned user will NOT automatically fail captcha" ).apply {
521- launchSafelyWithoutExceptions {
520+ launchLoggingDropExceptions {
522521 delay(5000L )
523522 delete(this @apply)
524523 }
0 commit comments