mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
Update ChatIdentifierWithThreadId.kt
This commit is contained in:
parent
733ad34289
commit
304b281d80
@ -1,23 +1,23 @@
|
|||||||
package dev.inmo.tgbotapi.utils.extensions
|
package dev.inmo.tgbotapi.utils.extensions
|
||||||
|
|
||||||
sealed interface ChatIdWithThreadId {
|
sealed interface ChatIdWithThreadId {
|
||||||
val chatId: ChatId
|
val chatId: ChatIdentifier
|
||||||
val threadId: MessageThreadId?
|
val threadId: MessageThreadId?
|
||||||
|
|
||||||
// Light weight due to absence of any conversations
|
// Light weight due to absence of any conversations
|
||||||
value class ByMessage(
|
value class ByMessage(
|
||||||
val sourceMessage: Message
|
val sourceMessage: Message
|
||||||
) : ChatIdWithThreadId {
|
) : ChatIdWithThreadId {
|
||||||
override val chatId: ChatId
|
override val chatId: ChatIdentifier
|
||||||
get() = sourceMessage.chat.id
|
get() = sourceMessage.chat.id
|
||||||
override val threadId: MessageThreadId?
|
override val threadId: MessageThreadId?
|
||||||
get() = sourceMessage.threadIdOrNull
|
get() = sourceMessage.threadIdOrNull
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
value class ByPair(
|
value class ByPair(
|
||||||
val pair: Pair<ChatId, MessageThreadId?>
|
val pair: Pair<ChatIdentifier, MessageThreadId?>
|
||||||
) : ChatIdWithThreadId {
|
) : ChatIdWithThreadId {
|
||||||
override val chatId: ChatId
|
override val chatId: ChatIdentifier
|
||||||
get() = pair.first
|
get() = pair.first
|
||||||
override val threadId: MessageThreadId?
|
override val threadId: MessageThreadId?
|
||||||
get() = pair.second
|
get() = pair.second
|
||||||
@ -26,7 +26,7 @@ sealed interface ChatIdWithThreadId {
|
|||||||
companion {
|
companion {
|
||||||
inline operator fun invoke(message: Message) = ByMessage(message)
|
inline operator fun invoke(message: Message) = ByMessage(message)
|
||||||
inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull)
|
inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull)
|
||||||
inline fun serializable(pair: Pair<ChatId, MessageThreadId?>) = ByPair(pair)
|
inline fun serializable(pair: Pair<ChatIdentifier, MessageThreadId?>) = ByPair(pair)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user