mirror of
https://github.com/InsanusMokrassar/TelegramBotTutorial.git
synced 2024-12-22 14:17:12 +00:00
update fixes
This commit is contained in:
parent
7ae5a158bb
commit
5646b2f581
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -3,8 +3,10 @@ package db
|
|||||||
import dev.inmo.micro_utils.repos.exposed.ExposedRepo
|
import dev.inmo.micro_utils.repos.exposed.ExposedRepo
|
||||||
import dev.inmo.micro_utils.repos.exposed.initTable
|
import dev.inmo.micro_utils.repos.exposed.initTable
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
import model.ChatSettings
|
import model.ChatSettings
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
internal class WelcomeTable(
|
internal class WelcomeTable(
|
||||||
@ -19,7 +21,7 @@ internal class WelcomeTable(
|
|||||||
initTable()
|
initTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun get(chatId: ChatId): ChatSettings? = transaction(database) {
|
fun get(chatId: IdChatIdentifier): ChatSettings? = transaction(database) {
|
||||||
select { targetChatIdColumn.eq(chatId.chatId) }.limit(1).firstOrNull() ?.let {
|
select { targetChatIdColumn.eq(chatId.chatId) }.limit(1).firstOrNull() ?.let {
|
||||||
ChatSettings(
|
ChatSettings(
|
||||||
ChatId(it[targetChatIdColumn]),
|
ChatId(it[targetChatIdColumn]),
|
||||||
@ -38,7 +40,7 @@ internal class WelcomeTable(
|
|||||||
}.insertedCount > 0
|
}.insertedCount > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unset(chatId: ChatId): Boolean = transaction(database) {
|
fun unset(chatId: IdChatIdentifier): Boolean = transaction(database) {
|
||||||
deleteWhere { targetChatIdColumn.eq(chatId.chatId) } > 0
|
deleteWhere { targetChatIdColumn.eq(chatId.chatId) } > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
|
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
internal data class ChatSettings(
|
internal data class ChatSettings(
|
||||||
val targetChatId: ChatId,
|
val targetChatId: IdChatIdentifier,
|
||||||
val sourceChatId: ChatId,
|
val sourceChatId: IdChatIdentifier,
|
||||||
val sourceMessageId: MessageIdentifier
|
val sourceMessageId: MessageIdentifier
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user