Skip to content

Commit 0a0bdce

Browse files
Merge pull request #63 from InsanusMokrassar/0.25.0
0.25.0
2 parents 58b9019 + dd94811 commit 0a0bdce

File tree

20 files changed

+118
-113
lines changed

20 files changed

+118
-113
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.25.0
4+
5+
* `Versions`:
6+
* `Kotlin`: `2.3.10`
7+
* `Serialization`: `1.10.0`
8+
* `PlaguBot`: `11.0.0`
9+
* `KSLog`: `1.6.0`
10+
* `MicroUtils`: `0.29.1`
11+
* `TelegramBotAPILibraries`: `0.29.0`
12+
313
## 0.24.7
414

515
* `Versions`:

bans/src/main/kotlin/BanPlugin.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dev.inmo.micro_utils.common.mapOnFirst
77
import dev.inmo.micro_utils.common.mapOnSecond
88
import dev.inmo.micro_utils.common.onFirst
99
import dev.inmo.micro_utils.common.onSecond
10-
import dev.inmo.micro_utils.coroutines.runCatchingSafely
10+
import dev.inmo.micro_utils.coroutines.runCatchingLogging
1111
import dev.inmo.micro_utils.koin.singleWithBinds
1212
import dev.inmo.micro_utils.repos.add
1313
import dev.inmo.micro_utils.repos.set
@@ -202,7 +202,7 @@ class BanPlugin : Plugin {
202202
if (warnings >= chatSettings.warningsUntilBan) {
203203
when {
204204
userInReply != null -> {
205-
val banned = runCatchingSafely {
205+
val banned = runCatchingLogging {
206206
banChatMember(commandMessage.chat, userInReply)
207207
}.isSuccess
208208
reply(
@@ -215,7 +215,7 @@ class BanPlugin : Plugin {
215215
}
216216
}
217217
channelInReply != null -> {
218-
val banned = runCatchingSafely {
218+
val banned = runCatchingLogging {
219219
banChatSenderChat(commandMessage.chat, channelInReply.id)
220220
}.isSuccess
221221
reply(
@@ -378,7 +378,7 @@ class BanPlugin : Plugin {
378378
}.either()
379379

380380

381-
val banned = runCatchingSafely {
381+
val banned = runCatchingLogging {
382382
userInReply.onFirst {
383383
banChatMember(commandMessage.chat, it.id)
384384
}.onSecond {

bans/src/main/kotlin/InlineButtonsDrawer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.inmo.plagubot.plugins.bans
22

3-
import dev.inmo.micro_utils.coroutines.runCatchingSafely
3+
import dev.inmo.micro_utils.coroutines.runCatchingLogging
44
import dev.inmo.micro_utils.repos.set
55
import dev.inmo.plagubot.plugins.bans.db.ChatsSettingsTable
66
import dev.inmo.plagubot.plugins.bans.models.ChatSettings
@@ -145,7 +145,7 @@ internal class BansInlineButtonsDrawer(
145145
reply(query.message, "Updated")
146146
}
147147

148-
runCatchingSafely { drawInlineButtons(chatId, query.user.id, query.message.messageId, InlineButtonsKeys.Settings) }
148+
runCatchingLogging { drawInlineButtons(chatId, query.user.id, query.message.messageId, InlineButtonsKeys.Settings) }
149149

150150
answer(query)
151151

@@ -165,7 +165,7 @@ internal class BansInlineButtonsDrawer(
165165
return
166166
}
167167

168-
runCatchingSafely {
168+
runCatchingLogging {
169169
editMessageReplyMarkup(
170170
userId,
171171
messageId,

bans/src/main/kotlin/db/ChatsSettingsTable.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import dev.inmo.plagubot.plugins.bans.utils.banPluginSerialFormat
88
import dev.inmo.tgbotapi.types.IdChatIdentifier
99
import dev.inmo.tgbotapi.types.MessageThreadId
1010
import dev.inmo.tgbotapi.types.RawChatId
11-
import org.jetbrains.exposed.sql.Database
12-
import org.jetbrains.exposed.sql.ISqlExpressionBuilder
13-
import org.jetbrains.exposed.sql.Op
14-
import org.jetbrains.exposed.sql.ResultRow
15-
import org.jetbrains.exposed.sql.and
16-
import org.jetbrains.exposed.sql.statements.InsertStatement
17-
import org.jetbrains.exposed.sql.statements.UpdateBuilder
11+
import org.jetbrains.exposed.v1.core.Op
12+
import org.jetbrains.exposed.v1.core.ResultRow
13+
import org.jetbrains.exposed.v1.core.and
14+
import org.jetbrains.exposed.v1.core.eq
15+
import org.jetbrains.exposed.v1.core.isNull
16+
import org.jetbrains.exposed.v1.core.statements.UpdateBuilder
17+
import org.jetbrains.exposed.v1.jdbc.Database
1818

1919
internal typealias ChatsSettingsTable = KeyValueRepo<IdChatIdentifier, ChatSettings>
2020

@@ -27,10 +27,10 @@ private class ExposedChatsSettingsTable(
2727
override val keyColumn = long("chatId")
2828
private val threadIdColumn = long("threadId").nullable().default(null)
2929
private val chatSettingsColumn = text("userId")
30-
override val selectById: ISqlExpressionBuilder.(IdChatIdentifier) -> Op<Boolean> = {
30+
override val selectById: (IdChatIdentifier) -> Op<Boolean> = {
3131
keyColumn.eq(it.chatId.long).and(it.threadId ?.long ?.let { threadIdColumn.eq(it) } ?: threadIdColumn.isNull())
3232
}
33-
override val selectByValue: ISqlExpressionBuilder.(ChatSettings) -> Op<Boolean> = {
33+
override val selectByValue: (ChatSettings) -> Op<Boolean> = {
3434
chatSettingsColumn.eq(banPluginSerialFormat.encodeToString(ChatSettings.serializer(), it))
3535
}
3636
override val ResultRow.asKey: IdChatIdentifier

bans/src/main/kotlin/db/WarningsTable.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import dev.inmo.micro_utils.repos.mappers.withMapper
66
import dev.inmo.plagubot.plugins.bans.utils.banPluginSerialFormat
77
import dev.inmo.tgbotapi.types.*
88
import kotlinx.serialization.Serializable
9-
import kotlinx.serialization.decodeFromString
10-
import kotlinx.serialization.encodeToString
11-
import org.jetbrains.exposed.sql.Database
9+
import org.jetbrains.exposed.v1.jdbc.Database
1210

1311
internal val Database.warningsTable: WarningsTable
1412
get() = ExposedKeyValuesRepo(

bans/src/main/kotlin/models/WorkMode.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import kotlinx.serialization.modules.polymorphic
77

88
@Serializable
99
sealed interface WorkMode {
10-
@Serializable
1110
sealed interface EnabledForAdmins : WorkMode {
1211
@Serializable
1312
companion object Default : EnabledForAdmins
1413
}
15-
@Serializable
1614
sealed interface EnabledForUsers : WorkMode {
1715
@Serializable
1816
companion object Default : EnabledForUsers

captcha/src/main/kotlin/Plugin.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package dev.inmo.plagubot.plugins.captcha
22

33
import 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
76
import dev.inmo.micro_utils.koin.singleWithRandomQualifier
87
import dev.inmo.micro_utils.repos.create
98
import 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
}

captcha/src/main/kotlin/db/CaptchaChatsSettingsRepo.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import dev.inmo.tgbotapi.types.MessageThreadId
1010
import dev.inmo.tgbotapi.types.RawChatId
1111
import dev.inmo.tgbotapi.types.toChatId
1212
import kotlinx.serialization.json.Json
13-
import org.jetbrains.exposed.sql.Database
14-
import org.jetbrains.exposed.sql.ISqlExpressionBuilder
15-
import org.jetbrains.exposed.sql.Op
16-
import org.jetbrains.exposed.sql.ResultRow
17-
import org.jetbrains.exposed.sql.and
18-
import org.jetbrains.exposed.sql.or
19-
import org.jetbrains.exposed.sql.statements.InsertStatement
20-
import org.jetbrains.exposed.sql.statements.UpdateBuilder
13+
import org.jetbrains.exposed.v1.core.Op
14+
import org.jetbrains.exposed.v1.core.ResultRow
15+
import org.jetbrains.exposed.v1.core.and
16+
import org.jetbrains.exposed.v1.core.eq
17+
import org.jetbrains.exposed.v1.core.isNull
18+
import org.jetbrains.exposed.v1.core.or
19+
import org.jetbrains.exposed.v1.core.statements.InsertStatement
20+
import org.jetbrains.exposed.v1.core.statements.UpdateBuilder
21+
import org.jetbrains.exposed.v1.jdbc.Database
2122

2223
private val captchaProviderSerialFormat = Json {
2324
ignoreUnknownKeys = true
@@ -45,7 +46,7 @@ class CaptchaChatsSettingsRepo(
4546

4647
override val primaryKey = PrimaryKey(chatIdColumn)
4748

48-
override val selectByIds: ISqlExpressionBuilder.(List<IdChatIdentifier>) -> Op<Boolean> = {
49+
override val selectByIds: (List<IdChatIdentifier>) -> Op<Boolean> = {
4950
fun IdChatIdentifier.createEq() = chatIdColumn.eq(chatId.long).and(
5051
threadId ?.let { threadIdColumn.eq(it.long) } ?: threadIdColumn.isNull()
5152
)
@@ -85,7 +86,7 @@ class CaptchaChatsSettingsRepo(
8586
autoPassKnown = get(autoPassKnownColumn),
8687
)
8788

88-
override val selectById: ISqlExpressionBuilder.(IdChatIdentifier) -> Op<Boolean> = { chatIdColumn.eq(it.chatId.long) }
89+
override val selectById: (IdChatIdentifier) -> Op<Boolean> = { chatIdColumn.eq(it.chatId.long) }
8990
override val ResultRow.asObject: ChatSettings
9091
get() = ChatSettings(
9192
chatId = asId,

captcha/src/main/kotlin/db/UsersPassInfoRepo.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ import dev.inmo.tgbotapi.types.RawChatId
88
import dev.inmo.tgbotapi.types.UserId
99
import dev.inmo.tgbotapi.types.toChatId
1010
import kotlinx.serialization.Serializable
11-
import org.jetbrains.exposed.sql.Column
12-
import org.jetbrains.exposed.sql.Database
13-
import org.jetbrains.exposed.sql.ISqlExpressionBuilder
14-
import org.jetbrains.exposed.sql.Op
15-
import org.jetbrains.exposed.sql.ResultRow
16-
import org.jetbrains.exposed.sql.and
17-
import org.jetbrains.exposed.sql.select
18-
import org.jetbrains.exposed.sql.statements.InsertStatement
19-
import org.jetbrains.exposed.sql.statements.UpdateBuilder
20-
import org.jetbrains.exposed.sql.transactions.transaction
11+
import org.jetbrains.exposed.v1.core.Column
12+
import org.jetbrains.exposed.v1.core.Op
13+
import org.jetbrains.exposed.v1.core.ResultRow
14+
import org.jetbrains.exposed.v1.core.and
15+
import org.jetbrains.exposed.v1.core.eq
16+
import org.jetbrains.exposed.v1.core.greaterEq
17+
import org.jetbrains.exposed.v1.core.statements.UpdateBuilder
18+
import org.jetbrains.exposed.v1.jdbc.Database
19+
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
2120

2221
class UsersPassInfoRepo(database: Database) : AbstractExposedKeyValuesRepo<UserId, UsersPassInfoRepo.PassInfo>(
2322
database,
@@ -37,10 +36,10 @@ class UsersPassInfoRepo(database: Database) : AbstractExposedKeyValuesRepo<UserI
3736

3837
override val keyColumn: Column<Long>
3938
get() = userIdColumn
40-
override val selectById: ISqlExpressionBuilder.(UserId) -> Op<Boolean> = {
39+
override val selectById: (UserId) -> Op<Boolean> = {
4140
userIdColumn.eq(it.chatId.long)
4241
}
43-
override val selectByValue: ISqlExpressionBuilder.(PassInfo) -> Op<Boolean> = {
42+
override val selectByValue: (PassInfo) -> Op<Boolean> = {
4443
chatIdColumn.eq(it.chatId.chatId.long).and(passedColumn.eq(it.passed))
4544
}
4645
override val ResultRow.asKey: UserId

0 commit comments

Comments
 (0)