mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add support of forum chats
This commit is contained in:
parent
8f4eb74e39
commit
867a46d397
@ -11,6 +11,7 @@ import kotlin.jvm.JvmInline
|
||||
|
||||
typealias Identifier = Long
|
||||
typealias MessageId = Long
|
||||
typealias MessageThreadId = Long
|
||||
typealias MessageIdentifier = MessageId
|
||||
typealias InlineQueryIdentifier = String
|
||||
typealias UpdateIdentifier = Long
|
||||
@ -148,6 +149,7 @@ const val tgWebAppStartParamField = "tgWebAppStartParam"
|
||||
const val chatIdField = "chat_id"
|
||||
const val senderChatIdField = "sender_chat_id"
|
||||
const val messageIdField = "message_id"
|
||||
const val messageThreadIdField = "message_thread_id"
|
||||
const val updateIdField = "update_id"
|
||||
const val fromChatIdField = "from_chat_id"
|
||||
const val disableWebPagePreviewField = "disable_web_page_preview"
|
||||
@ -313,6 +315,7 @@ const val botCommandsField = "commands"
|
||||
const val scopeField = "scope"
|
||||
|
||||
const val isMemberField = "is_member"
|
||||
const val isForumField = "is_forum"
|
||||
const val canSendMessagesField = "can_send_messages"
|
||||
const val canSendMediaMessagesField = "can_send_media_messages"
|
||||
const val canSendOtherMessagesField = "can_send_other_messages"
|
||||
|
@ -5,10 +5,9 @@ import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface ChannelChat : SuperPublicChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface GroupChat : PublicChat
|
||||
sealed interface UsernameChat : Chat {
|
||||
val username: Username?
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface PrivateChat : Chat, UsernameChat {
|
||||
@ -22,16 +21,20 @@ sealed interface PublicChat : Chat {
|
||||
val title: String
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface SupergroupChat : GroupChat, SuperPublicChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface SuperPublicChat : PublicChat, UsernameChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface UsernameChat : Chat {
|
||||
val username: Username?
|
||||
}
|
||||
sealed interface ChannelChat : SuperPublicChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface GroupChat : PublicChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface SupergroupChat : GroupChat, SuperPublicChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface ForumChat : SupergroupChat
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface PossiblyPremiumChat : Chat {
|
||||
|
@ -57,11 +57,16 @@ object PreviewChatSerializer : KSerializer<Chat> {
|
||||
val decodedJson = JsonObject.serializer().deserialize(decoder)
|
||||
|
||||
val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson")
|
||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||
|
||||
return when (type) {
|
||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.SupergroupChatType -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownChatType(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
@ -77,6 +82,7 @@ object PreviewChatSerializer : KSerializer<Chat> {
|
||||
is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, value)
|
||||
is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, value)
|
||||
is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ForumChatImpl -> ForumChatImpl.serializer().serialize(encoder, value)
|
||||
is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, value)
|
||||
is CommonBot -> CommonBot.serializer().serialize(encoder, value)
|
||||
is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, value)
|
||||
@ -95,12 +101,17 @@ object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
val decodedJson = JsonObject.serializer().deserialize(decoder)
|
||||
|
||||
val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson")
|
||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||
|
||||
return when (type) {
|
||||
// else -> throw IllegalArgumentException("Unknown type of chat")
|
||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.SupergroupChatType -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownExtendedChat(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
@ -115,6 +126,7 @@ object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedForumChatImpl -> ExtendedForumChatImpl.serializer().serialize(encoder, value)
|
||||
is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, value)
|
||||
is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson)
|
||||
}
|
||||
|
@ -104,6 +104,41 @@ data class ExtendedSupergroupChatImpl(
|
||||
override val requireAdminApproveToJoin: Boolean = false
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
data class ExtendedForumChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(usernameField)
|
||||
override val username: Username? = null,
|
||||
@SerialName(photoField)
|
||||
override val chatPhoto: ChatPhoto? = null,
|
||||
@SerialName(permissionsField)
|
||||
override val permissions: ChatPermissions,
|
||||
@SerialName(descriptionField)
|
||||
override val description: String = "",
|
||||
@SerialName(inviteLinkField)
|
||||
override val inviteLink: String? = null,
|
||||
@SerialName(pinnedMessageField)
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
override val pinnedMessage: Message? = null,
|
||||
@SerialName(stickerSetNameFullField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(slowModeDelayField)
|
||||
override val slowModeDelay: Long? = null,
|
||||
@SerialName(canSetStickerSetField)
|
||||
override val canSetStickerSet: Boolean = false,
|
||||
@SerialName(linkedChatIdField)
|
||||
override val linkedChannelChatId: ChatId? = null,
|
||||
@SerialName(locationField)
|
||||
override val location: ChatLocation? = null,
|
||||
@SerialName(joinToSendMessagesField)
|
||||
override val requiresJoinForMessaging: Boolean = false,
|
||||
@SerialName(joinByRequestField)
|
||||
override val requireAdminApproveToJoin: Boolean = false
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
data class ExtendedBot(
|
||||
override val id: UserId,
|
||||
|
@ -51,6 +51,9 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat {
|
||||
val requireAdminApproveToJoin: Boolean
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer::class)
|
||||
sealed interface ExtendedForumChat : ExtendedSupergroupChat
|
||||
|
||||
@Serializable(ExtendedChatSerializer::class)
|
||||
sealed interface ExtendedChat : Chat {
|
||||
val chatPhoto: ChatPhoto?
|
||||
|
@ -37,6 +37,16 @@ data class SupergroupChatImpl(
|
||||
override val username: Username? = null
|
||||
) : SupergroupChat
|
||||
|
||||
@Serializable
|
||||
data class ForumChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(usernameField)
|
||||
override val username: Username? = null
|
||||
) : ForumChat
|
||||
|
||||
@Serializable
|
||||
data class ChannelChatImpl(
|
||||
@SerialName(idField)
|
||||
|
@ -66,3 +66,49 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?
|
||||
) : CommonGroupContentMessage<T>
|
||||
|
||||
data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val chat: ForumChat,
|
||||
override val channel: ChannelChat,
|
||||
override val messageId: MessageId,
|
||||
override val threadId: MessageThreadId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : FromChannelForumContentMessage<T>
|
||||
|
||||
data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
override val chat: ForumChat,
|
||||
override val messageId: MessageId,
|
||||
override val threadId: MessageThreadId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : AnonymousForumContentMessage<T>
|
||||
|
||||
data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val chat: ForumChat,
|
||||
override val messageId: MessageId,
|
||||
override val threadId: MessageThreadId,
|
||||
override val from: User,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?
|
||||
) : CommonForumContentMessage<T>
|
||||
|
@ -34,6 +34,8 @@ internal data class RawMessage(
|
||||
val messageId: MessageId,
|
||||
val date: TelegramDate,
|
||||
private val chat: Chat,
|
||||
@SerialName(messageThreadIdField)
|
||||
private val messageThreadId: MessageThreadId? = null,
|
||||
private val from: User? = null,
|
||||
private val sender_chat: PublicChat? = null,
|
||||
private val forward_from: User? = null,
|
||||
@ -307,6 +309,113 @@ internal data class RawMessage(
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
is ForumChat -> if (messageThreadId != null) {
|
||||
when (sender_chat) {
|
||||
is ChannelChat -> FromChannelForumContentMessageImpl(
|
||||
chat,
|
||||
sender_chat,
|
||||
messageId,
|
||||
messageThreadId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
is GroupChat -> AnonymousForumContentMessageImpl(
|
||||
chat,
|
||||
messageId,
|
||||
messageThreadId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
null -> CommonForumContentMessageImpl(
|
||||
chat,
|
||||
messageId,
|
||||
messageThreadId,
|
||||
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot
|
||||
)
|
||||
}
|
||||
} else {
|
||||
when (sender_chat) {
|
||||
is ChannelChat -> if (is_automatic_forward == true) {
|
||||
ConnectedFromChannelGroupContentMessageImpl(
|
||||
chat,
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
} else {
|
||||
UnconnectedFromChannelGroupContentMessageImpl(
|
||||
chat,
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
}
|
||||
is GroupChat -> AnonymousGroupContentMessageImpl(
|
||||
chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
null -> CommonGroupContentMessageImpl(
|
||||
chat,
|
||||
messageId,
|
||||
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot
|
||||
)
|
||||
}
|
||||
}
|
||||
is GroupChat -> when (sender_chat) {
|
||||
is ChannelChat -> if (is_automatic_forward == true) {
|
||||
ConnectedFromChannelGroupContentMessageImpl(
|
||||
@ -365,9 +474,7 @@ internal data class RawMessage(
|
||||
content,
|
||||
via_bot
|
||||
)
|
||||
else -> error("Currently in groups supported only fields \"sender_chat\" with channel, group or null, but was $sender_chat")
|
||||
}
|
||||
else -> error("Unknown type of public chat: $chat")
|
||||
}
|
||||
is PrivateChat -> PrivateContentMessageImpl(
|
||||
messageId,
|
||||
|
@ -1,15 +1,22 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.chat.ForumChat
|
||||
import dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
|
||||
interface GroupContentMessage<T : MessageContent> : PublicContentMessage<T> {
|
||||
sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<T> {
|
||||
override val chat: GroupChat
|
||||
}
|
||||
|
||||
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T> {
|
||||
override val chat: ForumChat
|
||||
val threadId: MessageThreadId
|
||||
}
|
||||
|
||||
interface FromChannelGroupContentMessage<T : MessageContent> : GroupContentMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
|
||||
sealed interface FromChannelGroupContentMessage<T : MessageContent> : GroupContentMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
val channel: ChannelChat
|
||||
override val senderChat: ChannelChat
|
||||
get() = channel
|
||||
@ -24,3 +31,12 @@ interface AnonymousGroupContentMessage<T : MessageContent> : GroupContentMessage
|
||||
}
|
||||
|
||||
interface CommonGroupContentMessage<T : MessageContent> : GroupContentMessage<T>, FromUserMessage
|
||||
|
||||
interface FromChannelForumContentMessage<T: MessageContent> : FromChannelGroupContentMessage<T>, ForumContentMessage<T>
|
||||
|
||||
interface AnonymousForumContentMessage<T : MessageContent> : ForumContentMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
override val senderChat: GroupChat
|
||||
get() = chat
|
||||
}
|
||||
|
||||
interface CommonForumContentMessage<T : MessageContent> : ForumContentMessage<T>, FromUserMessage
|
||||
|
@ -124,6 +124,8 @@ import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
|
||||
@ -131,6 +133,8 @@ import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.ForumChat
|
||||
import dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
import dev.inmo.tgbotapi.types.chat.GroupChatImpl
|
||||
import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat
|
||||
@ -212,6 +216,7 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaVideo
|
||||
import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.media.TitledTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
||||
@ -242,23 +247,29 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted
|
||||
import dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.CommonGroupEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.ForwardInfo
|
||||
import dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
import dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.GroupContentMessage
|
||||
@ -761,6 +772,18 @@ public inline fun <T>
|
||||
WithUser.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl<MessageContent>) -> T):
|
||||
T? = commonGroupContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun WithUser.commonForumContentMessageImplOrNull():
|
||||
CommonForumContentMessageImpl<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun WithUser.commonForumContentMessageImplOrThrow():
|
||||
CommonForumContentMessageImpl<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
WithUser.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl<MessageContent>) -> T):
|
||||
T? = commonForumContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun WithUser.passportMessageOrNull(): PassportMessage? = this as?
|
||||
dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
|
||||
@ -812,6 +835,18 @@ public inline fun <T>
|
||||
WithUser.ifCommonGroupContentMessage(block: (CommonGroupContentMessage<MessageContent>) -> T):
|
||||
T? = commonGroupContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun WithUser.commonForumContentMessageOrNull():
|
||||
CommonForumContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun WithUser.commonForumContentMessageOrThrow():
|
||||
CommonForumContentMessage<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
WithUser.ifCommonForumContentMessage(block: (CommonForumContentMessage<MessageContent>) -> T):
|
||||
T? = commonForumContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun WithUser.privateContentMessageOrNull(): PrivateContentMessage<MessageContent>? =
|
||||
this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
@ -1848,23 +1883,15 @@ public inline fun KeyboardMarkup.replyKeyboardRemoveOrThrow(): ReplyKeyboardRemo
|
||||
public inline fun <T> KeyboardMarkup.ifReplyKeyboardRemove(block: (ReplyKeyboardRemove) -> T): T? =
|
||||
replyKeyboardRemoveOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.channelChatOrNull(): ChannelChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
public inline fun Chat.usernameChatOrNull(): UsernameChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.UsernameChat
|
||||
|
||||
public inline fun Chat.channelChatOrThrow(): ChannelChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
public inline fun Chat.usernameChatOrThrow(): UsernameChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.UsernameChat
|
||||
|
||||
public inline fun <T> Chat.ifChannelChat(block: (ChannelChat) -> T): T? = channelChatOrNull()
|
||||
public inline fun <T> Chat.ifUsernameChat(block: (UsernameChat) -> T): T? = usernameChatOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.groupChatOrNull(): GroupChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
|
||||
public inline fun Chat.groupChatOrThrow(): GroupChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
|
||||
public inline fun <T> Chat.ifGroupChat(block: (GroupChat) -> T): T? = groupChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.privateChatOrNull(): PrivateChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.PrivateChat
|
||||
|
||||
@ -1883,15 +1910,6 @@ public inline fun Chat.publicChatOrThrow(): PublicChat = this as
|
||||
public inline fun <T> Chat.ifPublicChat(block: (PublicChat) -> T): T? = publicChatOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.supergroupChatOrNull(): SupergroupChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||
|
||||
public inline fun Chat.supergroupChatOrThrow(): SupergroupChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||
|
||||
public inline fun <T> Chat.ifSupergroupChat(block: (SupergroupChat) -> T): T? =
|
||||
supergroupChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.superPublicChatOrNull(): SuperPublicChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.SuperPublicChat
|
||||
|
||||
@ -1901,15 +1919,40 @@ public inline fun Chat.superPublicChatOrThrow(): SuperPublicChat = this as
|
||||
public inline fun <T> Chat.ifSuperPublicChat(block: (SuperPublicChat) -> T): T? =
|
||||
superPublicChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.usernameChatOrNull(): UsernameChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.UsernameChat
|
||||
public inline fun Chat.channelChatOrNull(): ChannelChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
|
||||
public inline fun Chat.usernameChatOrThrow(): UsernameChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.UsernameChat
|
||||
public inline fun Chat.channelChatOrThrow(): ChannelChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
|
||||
public inline fun <T> Chat.ifUsernameChat(block: (UsernameChat) -> T): T? = usernameChatOrNull()
|
||||
public inline fun <T> Chat.ifChannelChat(block: (ChannelChat) -> T): T? = channelChatOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.groupChatOrNull(): GroupChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
|
||||
public inline fun Chat.groupChatOrThrow(): GroupChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.GroupChat
|
||||
|
||||
public inline fun <T> Chat.ifGroupChat(block: (GroupChat) -> T): T? = groupChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.supergroupChatOrNull(): SupergroupChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||
|
||||
public inline fun Chat.supergroupChatOrThrow(): SupergroupChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||
|
||||
public inline fun <T> Chat.ifSupergroupChat(block: (SupergroupChat) -> T): T? =
|
||||
supergroupChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.forumChatOrNull(): ForumChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ForumChat
|
||||
|
||||
public inline fun Chat.forumChatOrThrow(): ForumChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ForumChat
|
||||
|
||||
public inline fun <T> Chat.ifForumChat(block: (ForumChat) -> T): T? = forumChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.possiblyPremiumChatOrNull(): PossiblyPremiumChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat
|
||||
|
||||
@ -1965,6 +2008,15 @@ public inline fun Chat.extendedSupergroupChatImplOrThrow(): ExtendedSupergroupCh
|
||||
public inline fun <T> Chat.ifExtendedSupergroupChatImpl(block: (ExtendedSupergroupChatImpl) -> T):
|
||||
T? = extendedSupergroupChatImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedForumChatImplOrNull(): ExtendedForumChatImpl? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
||||
|
||||
public inline fun Chat.extendedForumChatImplOrThrow(): ExtendedForumChatImpl = this as
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl
|
||||
|
||||
public inline fun <T> Chat.ifExtendedForumChatImpl(block: (ExtendedForumChatImpl) -> T): T? =
|
||||
extendedForumChatImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedBotOrNull(): ExtendedBot? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||
|
||||
@ -2028,6 +2080,15 @@ public inline fun Chat.extendedSupergroupChatOrThrow(): ExtendedSupergroupChat =
|
||||
public inline fun <T> Chat.ifExtendedSupergroupChat(block: (ExtendedSupergroupChat) -> T): T? =
|
||||
extendedSupergroupChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedForumChatOrNull(): ExtendedForumChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
||||
|
||||
public inline fun Chat.extendedForumChatOrThrow(): ExtendedForumChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
||||
|
||||
public inline fun <T> Chat.ifExtendedForumChat(block: (ExtendedForumChat) -> T): T? =
|
||||
extendedForumChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedChatOrNull(): ExtendedChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
|
||||
@ -2064,6 +2125,15 @@ public inline fun Chat.supergroupChatImplOrThrow(): SupergroupChatImpl = this as
|
||||
public inline fun <T> Chat.ifSupergroupChatImpl(block: (SupergroupChatImpl) -> T): T? =
|
||||
supergroupChatImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.forumChatImplOrNull(): ForumChatImpl? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
||||
|
||||
public inline fun Chat.forumChatImplOrThrow(): ForumChatImpl = this as
|
||||
dev.inmo.tgbotapi.types.chat.ForumChatImpl
|
||||
|
||||
public inline fun <T> Chat.ifForumChatImpl(block: (ForumChatImpl) -> T): T? = forumChatImplOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.channelChatImplOrNull(): ChannelChatImpl? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ChannelChatImpl
|
||||
|
||||
@ -3011,6 +3081,42 @@ public inline fun <T>
|
||||
Message.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl<MessageContent>) -> T):
|
||||
T? = commonGroupContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.fromChannelForumContentMessageImplOrNull():
|
||||
FromChannelForumContentMessageImpl<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.fromChannelForumContentMessageImplOrThrow():
|
||||
FromChannelForumContentMessageImpl<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifFromChannelForumContentMessageImpl(block: (FromChannelForumContentMessageImpl<MessageContent>) -> T):
|
||||
T? = fromChannelForumContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.anonymousForumContentMessageImplOrNull():
|
||||
AnonymousForumContentMessageImpl<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.anonymousForumContentMessageImplOrThrow():
|
||||
AnonymousForumContentMessageImpl<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifAnonymousForumContentMessageImpl(block: (AnonymousForumContentMessageImpl<MessageContent>) -> T):
|
||||
T? = anonymousForumContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.commonForumContentMessageImplOrNull():
|
||||
CommonForumContentMessageImpl<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.commonForumContentMessageImplOrThrow():
|
||||
CommonForumContentMessageImpl<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl<MessageContent>) -> T):
|
||||
T? = commonForumContentMessageImplOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.passportMessageOrNull(): PassportMessage? = this as?
|
||||
dev.inmo.tgbotapi.types.message.PassportMessage
|
||||
|
||||
@ -3111,6 +3217,18 @@ public inline fun <T>
|
||||
Message.ifGroupContentMessage(block: (GroupContentMessage<MessageContent>) -> T): T? =
|
||||
groupContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.forumContentMessageOrNull(): ForumContentMessage<MessageContent>? = this
|
||||
as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.forumContentMessageOrThrow(): ForumContentMessage<MessageContent> = this
|
||||
as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifForumContentMessage(block: (ForumContentMessage<MessageContent>) -> T): T? =
|
||||
forumContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.fromChannelGroupContentMessageOrNull():
|
||||
FromChannelGroupContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
@ -3171,6 +3289,42 @@ public inline fun <T>
|
||||
Message.ifCommonGroupContentMessage(block: (CommonGroupContentMessage<MessageContent>) -> T): T?
|
||||
= commonGroupContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.fromChannelForumContentMessageOrNull():
|
||||
FromChannelForumContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.fromChannelForumContentMessageOrThrow():
|
||||
FromChannelForumContentMessage<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifFromChannelForumContentMessage(block: (FromChannelForumContentMessage<MessageContent>) -> T):
|
||||
T? = fromChannelForumContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.anonymousForumContentMessageOrNull():
|
||||
AnonymousForumContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.anonymousForumContentMessageOrThrow():
|
||||
AnonymousForumContentMessage<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifAnonymousForumContentMessage(block: (AnonymousForumContentMessage<MessageContent>) -> T):
|
||||
T? = anonymousForumContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.commonForumContentMessageOrNull():
|
||||
CommonForumContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.commonForumContentMessageOrThrow():
|
||||
CommonForumContentMessage<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifCommonForumContentMessage(block: (CommonForumContentMessage<MessageContent>) -> T): T?
|
||||
= commonForumContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.mediaGroupMessageOrNull(): MediaGroupMessage<MediaGroupContent>? = this
|
||||
as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage<dev.inmo.tgbotapi.types.message.content.MediaGroupContent>
|
||||
|
Loading…
Reference in New Issue
Block a user