mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2025-09-15 21:19:30 +00:00
update dependencies && add opportunity to use several targetChatIds instead of one
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package dev.inmo.plaguposter.common
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.FullChatIdentifierSerializer
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import kotlinx.serialization.SerialName
|
||||
@@ -10,14 +9,26 @@ import kotlinx.serialization.Serializable
|
||||
data class ChatConfig(
|
||||
@SerialName("targetChat")
|
||||
@Serializable(FullChatIdentifierSerializer::class)
|
||||
val targetChatId: IdChatIdentifier,
|
||||
val targetChatId: IdChatIdentifier? = null,
|
||||
@SerialName("sourceChat")
|
||||
@Serializable(FullChatIdentifierSerializer::class)
|
||||
val sourceChatId: IdChatIdentifier,
|
||||
@SerialName("cacheChat")
|
||||
@Serializable(FullChatIdentifierSerializer::class)
|
||||
val cacheChatId: IdChatIdentifier
|
||||
val cacheChatId: IdChatIdentifier,
|
||||
@SerialName("targetChats")
|
||||
val targetChatIds: List<@Serializable(FullChatIdentifierSerializer::class) IdChatIdentifier> = emptyList(),
|
||||
) {
|
||||
val allTargetChatIds by lazy {
|
||||
listOfNotNull(targetChatId) + targetChatIds
|
||||
}
|
||||
|
||||
init {
|
||||
require(targetChatId != null || targetChatIds.isNotEmpty()) {
|
||||
"One of fields, 'targetChat' or 'targetChats' should be presented"
|
||||
}
|
||||
}
|
||||
|
||||
fun check(chatId: IdChatIdentifier) = when (chatId) {
|
||||
targetChatId,
|
||||
sourceChatId,
|
||||
|
Reference in New Issue
Block a user