mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
commit
2de22a08a3
20
CHANGELOG.md
20
CHANGELOG.md
@ -1,5 +1,25 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.37.2 Telegram Bot API 5.5
|
||||
|
||||
* `Common`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.8.2` -> `0.8.7`
|
||||
* `Core`:
|
||||
* New request type: `ChatSenderRequest`
|
||||
* New request `BanChatSenderChat`
|
||||
* New request `UnbanChatSenderChat`
|
||||
* `ExtendedPrivateChat` got new properties: `hasPrivateForwards` and `allowCreateUserIdLink` (same as `hasPrivateForwards`)
|
||||
* All `ContentMessage` got field `forwardable` (old constructors marked as `Deprecated`)
|
||||
* `ChannelContentMessage` has been divided for two interfaces (and corresponding classes):
|
||||
* `ConnectedChannelContentMessage` (and `ConnectedChannelContentMessageImpl`) for connected to the group channels messages
|
||||
* `UnconnectedChannelContentMessage` (and `UnconnectedChannelContentMessageImpl`) for unconnected channels
|
||||
* `API`:
|
||||
* New extensions `TelegramBot#banChatSenderChat`
|
||||
* New extensions `TelegramBot#unbanChatSenderChat`
|
||||
* `Utils`:
|
||||
* Fix of `EntitiesBuilder#linkln`
|
||||
|
||||
## 0.37.1
|
||||
|
||||
* `Common`:
|
||||
|
@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-5.4-blue)](https://core.telegram.org/bots/api-changelog#november-5-2021)
|
||||
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-5.5-blue)](https://core.telegram.org/bots/api-changelog#december-7-2021)
|
||||
|
||||
| [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue)](https://forms.gle/2Hex2ynbHWHhi1KY7) [![Chat in Telegram](https://img.shields.io/static/v1?label=Telegram&message=Chat&color=blue)](https://t.me/InMoTelegramBotAPI) |
|
||||
|:---:|
|
||||
|
@ -12,11 +12,11 @@ klock_version=2.4.8
|
||||
uuid_version=0.3.1
|
||||
ktor_version=1.6.5
|
||||
|
||||
micro_utils_version=0.8.2
|
||||
micro_utils_version=0.8.7
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=0.37.1
|
||||
library_version=0.37.2
|
||||
|
||||
github_release_plugin_version=2.2.12
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
|
||||
|
@ -0,0 +1,27 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
|
||||
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.banChatSenderChat(
|
||||
chatId: ChatIdentifier,
|
||||
senderChatId: ChatId
|
||||
) = execute(BanChatSenderChat(chatId, senderChatId))
|
||||
|
||||
suspend fun TelegramBot.banChatSenderChat(
|
||||
chat: PublicChat,
|
||||
senderChatId: ChatId
|
||||
) = banChatSenderChat(chat.id, senderChatId)
|
||||
|
||||
suspend fun TelegramBot.banChatSenderChat(
|
||||
chatId: ChatId,
|
||||
senderChat: PublicChat
|
||||
) = banChatSenderChat(chatId, senderChat.id)
|
||||
|
||||
suspend fun TelegramBot.banChatSenderChat(
|
||||
chat: PublicChat,
|
||||
senderChat: PublicChat,
|
||||
) = banChatSenderChat(chat.id, senderChat)
|
@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.unbanChatSenderChat(
|
||||
chatId: ChatIdentifier,
|
||||
senderChatId: ChatId
|
||||
) = execute(UnbanChatSenderChat(chatId, senderChatId))
|
||||
|
||||
suspend fun TelegramBot.unbanChatSenderChat(
|
||||
chat: PublicChat,
|
||||
senderChatId: ChatId
|
||||
) = unbanChatSenderChat(chat.id, senderChatId)
|
||||
|
||||
suspend fun TelegramBot.unbanChatSenderChat(
|
||||
chatId: ChatId,
|
||||
senderChat: PublicChat
|
||||
) = unbanChatSenderChat(chatId, senderChat.id)
|
||||
|
||||
suspend fun TelegramBot.unbanChatSenderChat(
|
||||
chat: PublicChat,
|
||||
senderChat: PublicChat,
|
||||
) = unbanChatSenderChat(chat.id, senderChat)
|
@ -26,9 +26,9 @@ moments are describing by official [Telegram Bot API](https://core.telegram.org/
|
||||
Common ways to implement this library are presented here. In some cases it will require additional steps
|
||||
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
||||
`telegrambotapi.version`, which must be set up by developer. Available versions are presented on
|
||||
[bintray](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core), next version is last published:
|
||||
maven central, next version is last published:
|
||||
|
||||
[![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.core/images/download.svg) ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion)
|
||||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core)
|
||||
|
||||
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
|
||||
of signed artifacts in Bintray). You can:
|
||||
|
@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.requests.chat.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
|
||||
interface ChatSenderRequest : ChatRequest, SimpleRequest<Boolean> {
|
||||
val senderChatId: ChatId
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.requests.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatSenderRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
/**
|
||||
* Representation of [banChatSenderChat](https://core.telegram.org/bots/api#banchatsenderchat) request
|
||||
*/
|
||||
@Serializable
|
||||
data class BanChatSenderChat(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(senderChatIdField)
|
||||
override val senderChatId: ChatId
|
||||
) : ChatSenderRequest {
|
||||
override fun method(): String = "banChatSenderChat"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.requests.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatSenderRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
/**
|
||||
* Representation of [unbanChatSenderChat](https://core.telegram.org/bots/api#unbanchatsenderchat) request
|
||||
*/
|
||||
@Serializable
|
||||
data class UnbanChatSenderChat(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(senderChatIdField)
|
||||
override val senderChatId: ChatId
|
||||
) : ChatSenderRequest {
|
||||
override fun method(): String = "unbanChatSenderChat"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -96,6 +96,7 @@ val telegramInlineModeGifPermittedMimeTypes by lazy {
|
||||
}
|
||||
|
||||
const val chatIdField = "chat_id"
|
||||
const val senderChatIdField = "sender_chat_id"
|
||||
const val messageIdField = "message_id"
|
||||
const val updateIdField = "update_id"
|
||||
const val fromChatIdField = "from_chat_id"
|
||||
@ -112,6 +113,7 @@ const val isBotField = "is_bot"
|
||||
const val firstNameField = "first_name"
|
||||
const val lastNameField = "last_name"
|
||||
const val languageCodeField = "language_code"
|
||||
const val hasPrivateForwardsField = "has_private_forwards"
|
||||
const val canJoinGroupsField = "can_join_groups"
|
||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||
const val supportInlineQueriesField = "supports_inline_queries"
|
||||
|
@ -7,4 +7,8 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable(ExtendedChatSerializer::class)
|
||||
interface ExtendedPrivateChat : PrivateChat, ExtendedChat {
|
||||
val bio: String
|
||||
val hasPrivateForwards: Boolean
|
||||
|
||||
val allowCreateUserIdLink: Boolean
|
||||
get() = hasPrivateForwards
|
||||
}
|
||||
|
@ -18,5 +18,7 @@ data class ExtendedPrivateChatImpl(
|
||||
@SerialName(lastNameField)
|
||||
override val lastName: String = "",
|
||||
@SerialName(bioField)
|
||||
override val bio: String = ""
|
||||
override val bio: String = "",
|
||||
@SerialName(hasPrivateForwardsField)
|
||||
override val hasPrivateForwards: Boolean = false
|
||||
) : ExtendedPrivateChat
|
||||
|
@ -16,7 +16,21 @@ data class ChannelMediaGroupMessage<T : MediaGroupContent>(
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: T,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
) : MediaGroupMessage<T>
|
||||
) : MediaGroupMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
messageId: MessageIdentifier,
|
||||
chat: Chat,
|
||||
date: DateTime,
|
||||
mediaGroupId: MediaGroupIdentifier,
|
||||
content: T,
|
||||
editDate: DateTime?,
|
||||
forwardInfo: ForwardInfo?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?
|
||||
) : this(messageId, chat, date, mediaGroupId, content, editDate, true, forwardInfo, replyTo, replyMarkup)
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: ChannelChat,
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : ChannelContentMessage<T>
|
@ -15,7 +15,22 @@ data class CommonMediaGroupMessage<T : MediaGroupContent>(
|
||||
override val mediaGroupId: MediaGroupIdentifier,
|
||||
override val content: T,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?
|
||||
) : MediaGroupMessage<T>, FromUserMessage
|
||||
) : MediaGroupMessage<T>, FromUserMessage {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
messageId: MessageIdentifier,
|
||||
from: User,
|
||||
chat: Chat,
|
||||
date: DateTime,
|
||||
mediaGroupId: MediaGroupIdentifier,
|
||||
content: T,
|
||||
editDate: DateTime?,
|
||||
forwardInfo: ForwardInfo?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?
|
||||
) : this(messageId, from, chat, date, mediaGroupId, content, editDate, true, forwardInfo, replyTo, replyMarkup)
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class ConnectedChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: ChannelChat,
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : ConnectedChannelContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
messageId: MessageIdentifier,
|
||||
chat: ChannelChat,
|
||||
content: T,
|
||||
date: DateTime,
|
||||
editDate: DateTime?,
|
||||
forwardInfo: ForwardInfo?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?
|
||||
) : this(messageId, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot, authorSignature)
|
||||
}
|
@ -15,12 +15,28 @@ data class FromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : FromChannelGroupContentMessage<T>
|
||||
) : FromChannelGroupContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
chat: GroupChat,
|
||||
channel: ChannelChat,
|
||||
messageId: MessageIdentifier,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo?,
|
||||
editDate: DateTime?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?
|
||||
) : this(chat, channel, messageId, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot, authorSignature)
|
||||
}
|
||||
|
||||
data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val chat: GroupChat,
|
||||
@ -28,12 +44,27 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : AnonymousGroupContentMessage<T>
|
||||
) : AnonymousGroupContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
chat: GroupChat,
|
||||
messageId: MessageIdentifier,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo?,
|
||||
editDate: DateTime?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?
|
||||
) : this(chat, messageId, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot, authorSignature)
|
||||
}
|
||||
|
||||
data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val chat: GroupChat,
|
||||
@ -42,8 +73,23 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?
|
||||
) : CommonGroupContentMessage<T>
|
||||
) : CommonGroupContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
chat: GroupChat,
|
||||
messageId: MessageIdentifier,
|
||||
from: User,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo?,
|
||||
editDate: DateTime?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?
|
||||
) : this(chat, messageId, from, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
|
||||
data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
@ -16,8 +15,23 @@ data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
) : PrivateContentMessage<T>
|
||||
override val senderBot: CommonBot?
|
||||
) : PrivateContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
messageId: MessageIdentifier,
|
||||
from: User,
|
||||
chat: Chat,
|
||||
content: T,
|
||||
date: DateTime,
|
||||
editDate: DateTime?,
|
||||
forwardInfo: ForwardInfo?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
senderBot: CommonBot?
|
||||
) : this(messageId, from, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot)
|
||||
}
|
||||
|
@ -42,9 +42,11 @@ internal data class RawMessage(
|
||||
private val forward_signature: ForwardSignature? = null,
|
||||
private val forward_sender_name: ForwardSenderName? = null,
|
||||
private val forward_date: TelegramDate? = null,
|
||||
private val is_automatic_forward: Boolean? = null,
|
||||
private val reply_to_message: RawMessage? = null,
|
||||
private val via_bot: CommonBot? = null,
|
||||
private val edit_date: TelegramDate? = null,
|
||||
private val has_protected_content: Boolean? = null,
|
||||
private val media_group_id: MediaGroupIdentifier? = null,
|
||||
private val author_signature: AuthorSignature? = null,
|
||||
private val text: String? = null,
|
||||
@ -250,6 +252,7 @@ internal data class RawMessage(
|
||||
it,
|
||||
checkedContent,
|
||||
edit_date?.asDate,
|
||||
has_protected_content != true,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup
|
||||
@ -262,6 +265,7 @@ internal data class RawMessage(
|
||||
it,
|
||||
checkedContent,
|
||||
edit_date?.asDate,
|
||||
has_protected_content != true,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup
|
||||
@ -269,18 +273,35 @@ internal data class RawMessage(
|
||||
}
|
||||
} ?: when (chat) {
|
||||
is PublicChat -> when (chat) {
|
||||
is ChannelChat -> ChannelContentMessageImpl(
|
||||
is ChannelChat -> if (is_automatic_forward == true) {
|
||||
ConnectedChannelContentMessageImpl(
|
||||
messageId,
|
||||
chat,
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
has_protected_content != true,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
} else {
|
||||
UnconnectedChannelContentMessageImpl(
|
||||
messageId,
|
||||
chat,
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
has_protected_content != true,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
}
|
||||
is GroupChat -> when (sender_chat) {
|
||||
is ChannelChat -> FromChannelGroupContentMessageImpl(
|
||||
chat,
|
||||
@ -289,6 +310,7 @@ internal data class RawMessage(
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content != true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
@ -301,6 +323,7 @@ internal data class RawMessage(
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content != true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
@ -314,6 +337,7 @@ internal data class RawMessage(
|
||||
date.asDate,
|
||||
forwarded,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content != true,
|
||||
reply_to_message ?.asMessage,
|
||||
reply_markup,
|
||||
content,
|
||||
@ -330,6 +354,7 @@ internal data class RawMessage(
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
has_protected_content != true,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
|
@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class UnconnectedChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: ChannelChat,
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardable: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : UnconnectedChannelContentMessage<T> {
|
||||
@Deprecated("Use the constructor with forwardable field")
|
||||
constructor(
|
||||
messageId: MessageIdentifier,
|
||||
chat: ChannelChat,
|
||||
content: T,
|
||||
date: DateTime,
|
||||
editDate: DateTime?,
|
||||
forwardInfo: ForwardInfo?,
|
||||
replyTo: Message?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?
|
||||
) : this(messageId, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot, authorSignature)
|
||||
}
|
||||
|
||||
@Deprecated("Renamed to UnconnectedChannelContentMessage", ReplaceWith("UnconnectedChannelContentMessage", "dev.inmo.tgbotapi.types.message.UnconnectedChannelContentMessageImpl"))
|
||||
typealias ChannelContentMessageImpl<T> = UnconnectedChannelContentMessage<T>
|
@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||
|
||||
interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
sealed interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
override val chat: ChannelChat
|
||||
override val senderChat: ChannelChat
|
||||
get() = chat
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface ConnectedChannelContentMessage<T: MessageContent> : ChannelContentMessage<T>
|
@ -3,5 +3,9 @@ package dev.inmo.tgbotapi.types.message.abstracts
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface ContentMessage<T: MessageContent>: Message {
|
||||
val forwardable: Boolean
|
||||
val content: T
|
||||
|
||||
val hasProtectedContent: Boolean
|
||||
get() = !forwardable
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface UnconnectedChannelContentMessage<T: MessageContent> : ChannelContentMessage<T>
|
@ -915,15 +915,15 @@ inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupCont
|
||||
this as AnonymousGroupContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenChannelContentMessageImpl(block: (ChannelContentMessageImpl<MessageContent>) -> T) = asChannelContentMessageImpl() ?.let(block)
|
||||
inline fun <T> Message.whenChannelContentMessageImpl(block: (UnconnectedChannelContentMessageImpl<MessageContent>) -> T) = asChannelContentMessageImpl() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asChannelContentMessageImpl(): ChannelContentMessageImpl<MessageContent>? =
|
||||
this as? ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.asChannelContentMessageImpl(): UnconnectedChannelContentMessageImpl<MessageContent>? =
|
||||
this as? UnconnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireChannelContentMessageImpl(): ChannelContentMessageImpl<MessageContent> =
|
||||
this as ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.requireChannelContentMessageImpl(): UnconnectedChannelContentMessageImpl<MessageContent> =
|
||||
this as UnconnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenFromChannelGroupContentMessageImpl(block: (FromChannelGroupContentMessageImpl<MessageContent>) -> T) = asFromChannelGroupContentMessageImpl() ?.let(block)
|
||||
@ -1027,11 +1027,33 @@ inline fun <T> Message.whenChannelContentMessage(block: (ChannelContentMessage<M
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asChannelContentMessage(): ChannelContentMessage<MessageContent>? =
|
||||
this as? ChannelContentMessageImpl<MessageContent>
|
||||
this as? ChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireChannelContentMessage(): ChannelContentMessageImpl<MessageContent> =
|
||||
this as ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.requireChannelContentMessage(): ChannelContentMessage<MessageContent> =
|
||||
this as ChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenConnectedChannelContentMessage(block: (ConnectedChannelContentMessage<MessageContent>) -> T) = asConnectedChannelContentMessage() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asConnectedChannelContentMessage(): ConnectedChannelContentMessage<MessageContent>? =
|
||||
this as? ConnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireConnectedChannelContentMessage(): ConnectedChannelContentMessage<MessageContent> =
|
||||
this as ConnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenUnconnectedChannelContentMessage(block: (UnconnectedChannelContentMessage<MessageContent>) -> T) = asUnconnectedChannelContentMessage() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asUnconnectedChannelContentMessage(): UnconnectedChannelContentMessage<MessageContent>? =
|
||||
this as? UnconnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireUnconnectedChannelContentMessage(): UnconnectedChannelContentMessage<MessageContent> =
|
||||
this as UnconnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenChatEventMessage(block: (ChatEventMessage<ChatEvent>) -> T) = asChatEventMessage() ?.let(block)
|
||||
|
@ -429,7 +429,7 @@ inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbota
|
||||
/**
|
||||
* Version of [EntitiesBuilder.link] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text) + newLine
|
||||
inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine
|
||||
/**
|
||||
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.MessageEntity.textsources.link]
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user