mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-30 03:15:42 +00:00
add flag sentByBusinessConnectionOwner
This commit is contained in:
@@ -19,7 +19,7 @@ data class GetChat(
|
||||
@Transient
|
||||
override val resultDeserializer: DeserializationStrategy<ExtendedChat> = when {
|
||||
chatId is ChatIdWithThreadId -> ExtendedChatSerializer.BasedOnForumThread(chatId.threadId)
|
||||
chatId is BusinessChatId -> ExtendedChatSerializer.BasedOnBusinessConnection(chatId.businessId)
|
||||
chatId is BusinessChatId -> ExtendedChatSerializer.BasedOnBusinessConnection(chatId.businessConnectionId)
|
||||
else -> ExtendedChatSerializer.Companion
|
||||
}
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
|
||||
@@ -30,7 +30,7 @@ sealed interface IdChatIdentifier : ChatIdentifier {
|
||||
abstract val chatId: RawChatId
|
||||
val threadId: MessageThreadId?
|
||||
get() = null
|
||||
val businessId: BusinessConnectionId?
|
||||
val businessConnectionId: BusinessConnectionId?
|
||||
get() = null
|
||||
|
||||
companion object {
|
||||
@@ -63,7 +63,7 @@ value class ChatIdWithThreadId(val chatIdWithThreadId: Pair<RawChatId, MessageTh
|
||||
value class BusinessChatId(val chatIdWithBusinessConnectionId: Pair<RawChatId, BusinessConnectionId>) : IdChatIdentifier {
|
||||
override val chatId: RawChatId
|
||||
get() = chatIdWithBusinessConnectionId.first
|
||||
override val businessId: BusinessConnectionId
|
||||
override val businessConnectionId: BusinessConnectionId
|
||||
get() = chatIdWithBusinessConnectionId.second
|
||||
|
||||
constructor(chatId: RawChatId, businessConnectionId: BusinessConnectionId): this(chatId to businessConnectionId)
|
||||
@@ -196,7 +196,7 @@ object FullChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
when (value) {
|
||||
is ChatId -> encoder.encodeLong(value.chatId.long)
|
||||
is ChatIdWithThreadId -> encoder.encodeString("${value.chatId}/${value.threadId}")
|
||||
is BusinessChatId -> encoder.encodeString("${value.chatId}//${value.businessId}")
|
||||
is BusinessChatId -> encoder.encodeString("${value.chatId}//${value.businessConnectionId}")
|
||||
is Username -> encoder.encodeString(value.full)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chat.Bot
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewBot
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewBusinessChat
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
|
||||
interface BusinessContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, FromUserMessage,
|
||||
@@ -12,4 +12,11 @@ interface BusinessContentMessage<T: MessageContent> : PossiblySentViaBotCommonMe
|
||||
override val chat: PreviewBusinessChat
|
||||
override val businessConnectionId: BusinessConnectionId
|
||||
val senderBusinessBot: PreviewBot?
|
||||
|
||||
/**
|
||||
* Currently, there are only 1-1 business chats and any message in the [chat] sent not by [PreviewBusinessChat.original]
|
||||
* must be sent by bot or user
|
||||
*/
|
||||
val sentByBusinessConnectionOwner: Boolean
|
||||
get() = chat.original.id != from.id && from !is Bot
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user