mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 03:50:24 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9bc40187f | |||
| 3da4ee4808 | |||
| 6571e8f592 | |||
| 5c13047a0b | |||
| 4908bb2cfe | |||
| a01ca43837 | |||
| a9a01e3154 | |||
| 468c54a30f | |||
| 9177e01910 | |||
| 417f72af4a | |||
| df6d70b20d | |||
| 0b12df14db | |||
| 1590e1eef2 | |||
| 6896bc0772 | |||
| ce1abb0ae2 | |||
| 76a2cfd1a0 | |||
|
|
edca5494d4 |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,5 +1,21 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 10.1.0
|
||||
|
||||
**Add support of [Telegram Bots API 7.1](https://core.telegram.org/bots/api-changelog#february-16-2024)**
|
||||
|
||||
* `Version`:
|
||||
* `Coroutines`: `1.7.3` -> `1.8.0`
|
||||
* `MicroUtils`: `0.20.32` -> `0.20.34`
|
||||
|
||||
## 10.0.1
|
||||
|
||||
* `Version`:
|
||||
* `Ktor`: `2.3.7` -> `2.3.8`
|
||||
* `MicroUtils`: `0.20.26` -> `0.20.32`
|
||||
* `Korlibs`: `5.3.0` -> `5.3.1`
|
||||
* `KSLog`: `1.3.1` -> `1.3.2`
|
||||
|
||||
## 10.0.0
|
||||
|
||||
**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#december-29-2023)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#february-16-2024)
|
||||
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
@@ -118,5 +118,5 @@ suspend fun main() {
|
||||
### More examples
|
||||
|
||||
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
||||
always welcome in our [bookstack](https://bookstack.inmo.dev/books/telegrambotapi) and
|
||||
always welcome in our [docs](https://docs.inmo.dev/tgbotapi/index.html) and
|
||||
[chat](https://t.me/InMoTelegramBotAPIChat).
|
||||
|
||||
12
build.gradle
12
build.gradle
@@ -54,13 +54,13 @@ if (new File(projectDir, "secret.gradle").exists()) {
|
||||
githubRelease {
|
||||
token "${project.property('GITHUB_RELEASE_TOKEN')}"
|
||||
|
||||
owner "InsanusMokrassar"
|
||||
repo "TelegramBotAPI"
|
||||
owner = "InsanusMokrassar"
|
||||
repo = "TelegramBotAPI"
|
||||
|
||||
tagName "v$library_version"
|
||||
releaseName "$library_version"
|
||||
targetCommitish "$library_version"
|
||||
tagName = "v$library_version"
|
||||
releaseName = "$library_version"
|
||||
targetCommitish = "$library_version"
|
||||
|
||||
body getCurrentVersionChangelog()
|
||||
body = getCurrentVersionChangelog()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=10.0.0
|
||||
library_version=10.1.0
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
kotlin = "1.9.22"
|
||||
kotlin-serialization = "1.6.2"
|
||||
kotlin-coroutines = "1.7.3"
|
||||
kotlin-coroutines = "1.8.0"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "5.3.0"
|
||||
korlibs = "5.3.1"
|
||||
uuid = "0.8.2"
|
||||
ktor = "2.3.7"
|
||||
ktor = "2.3.8"
|
||||
|
||||
ksp = "1.9.22-1.0.16"
|
||||
kotlin-poet = "1.15.3"
|
||||
ksp = "1.9.22-1.0.17"
|
||||
kotlin-poet = "1.16.0"
|
||||
|
||||
microutils = "0.20.26"
|
||||
kslog = "1.3.1"
|
||||
microutils = "0.20.34"
|
||||
kslog = "1.3.2"
|
||||
|
||||
versions = "0.50.0"
|
||||
versions = "0.51.0"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
github-release-plugin = "2.5.2"
|
||||
dokka = "1.9.10"
|
||||
|
||||
[libraries]
|
||||
|
||||
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-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
|
||||
@@ -214,3 +214,8 @@ suspend fun BehaviourContext.waitChatShared(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostAdded(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatBoostAdded>(initRequest, errorFactory)
|
||||
|
||||
@@ -208,3 +208,8 @@ suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostAddedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatBoostAdded>(initRequest, errorFactory)
|
||||
|
||||
@@ -823,3 +823,24 @@ suspend fun <BC : BehaviourContext> BC.onChatShared(
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<ChatShared>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||
* to combinate several filters
|
||||
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onChatBoostAdded(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<ChatBoostAdded>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<ChatBoostAdded>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatBoostAdded>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<ChatBoostAdded>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
@@ -45,6 +45,11 @@ value class CustomEmojiId(
|
||||
val appLink
|
||||
get() = "${internalTgAppLinksBeginning}emoji?id=$this"
|
||||
}
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class StoryId(
|
||||
val long: Long
|
||||
)
|
||||
|
||||
typealias Seconds = Int
|
||||
typealias MilliSeconds = Long
|
||||
@@ -246,6 +251,8 @@ const val profileAccentColorIdField = "profile_accent_color_id"
|
||||
const val backgroundCustomEmojiIdField = "background_custom_emoji_id"
|
||||
const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id"
|
||||
const val hasVisibleHistoryField = "has_visible_history"
|
||||
const val unrestrictBoostsCountField = "unrestrict_boost_count"
|
||||
const val customEmojiStickerSetNameField = "custom_emoji_sticker_set_name"
|
||||
const val iconCustomEmojiIdField = "icon_custom_emoji_id"
|
||||
const val canJoinGroupsField = "can_join_groups"
|
||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||
@@ -656,6 +663,7 @@ const val menuButtonField = "menu_button"
|
||||
|
||||
const val boostIdField = "boost_id"
|
||||
const val boostField = "boost"
|
||||
const val boostCountField = "boost_count"
|
||||
const val addDateField = "add_date"
|
||||
const val expirationDateField = "expiration_date"
|
||||
const val removeDateField = "remove_date"
|
||||
|
||||
@@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.Giveaway
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.MessageOrigin
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.payments.Invoice
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
@@ -34,6 +33,14 @@ sealed interface ReplyInfo {
|
||||
get() = message.metaInfo
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ToStory(
|
||||
val story: Story
|
||||
): ReplyInfo {
|
||||
override val messageMeta: Message.MetaInfo?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable(External.Companion::class)
|
||||
sealed interface External : ReplyInfo {
|
||||
val origin: MessageOrigin
|
||||
|
||||
@@ -17,23 +17,41 @@ private val formatter
|
||||
sealed class ChatType {
|
||||
abstract val stringified: String
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
object PrivateChatType : ChatType() { override val stringified = "private" }
|
||||
object Sender : ChatType() { override val stringified = "sender" }
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
object GroupChatType : ChatType() { override val stringified = "group" }
|
||||
object Private : ChatType() { override val stringified = "private" }
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
object SupergroupChatType : ChatType() { override val stringified = "supergroup" }
|
||||
object Group : ChatType() { override val stringified = "group" }
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
object ChannelChatType : ChatType() { override val stringified = "channel" }
|
||||
object Supergroup : ChatType() { override val stringified = "supergroup" }
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
class UnknownChatType(override val stringified: String) : ChatType()
|
||||
object Channel : ChatType() { override val stringified = "channel" }
|
||||
@Serializable(ChatTypeSerializer::class)
|
||||
class Unknown(override val stringified: String) : ChatType()
|
||||
|
||||
companion object {
|
||||
@Deprecated("Renamed", ReplaceWith("Private", "dev.inmo.tgbotapi.types.chat.ChatType.Private"))
|
||||
val PrivateChatType = Private
|
||||
@Deprecated("Renamed", ReplaceWith("Group", "dev.inmo.tgbotapi.types.chat.ChatType.Group"))
|
||||
val GroupChatType = Group
|
||||
@Deprecated("Renamed", ReplaceWith("Supergroup", "dev.inmo.tgbotapi.types.chat.ChatType.Supergroup"))
|
||||
val SupergroupChatType = Supergroup
|
||||
@Deprecated("Renamed", ReplaceWith("Channel", "dev.inmo.tgbotapi.types.chat.ChatType.Channel"))
|
||||
val ChannelChatType = Channel
|
||||
@Deprecated("Renamed", ReplaceWith("Unknown", "dev.inmo.tgbotapi.types.chat.ChatType.Unknown"))
|
||||
val UnknownChatType = Unknown
|
||||
@Deprecated("Renamed", ReplaceWith("Unknown(stringified)", "dev.inmo.tgbotapi.types.chat.ChatType.Unknown"))
|
||||
fun UnknownChatType(stringified: String) = Unknown(stringified)
|
||||
}
|
||||
}
|
||||
val String.asChatType
|
||||
get() = when (this) {
|
||||
ChatType.PrivateChatType.stringified -> ChatType.PrivateChatType
|
||||
ChatType.GroupChatType.stringified -> ChatType.GroupChatType
|
||||
ChatType.SupergroupChatType.stringified -> ChatType.SupergroupChatType
|
||||
ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType
|
||||
else -> ChatType.UnknownChatType(this)
|
||||
ChatType.Sender.stringified -> ChatType.Sender
|
||||
ChatType.Private.stringified -> ChatType.Private
|
||||
ChatType.Group.stringified -> ChatType.Group
|
||||
ChatType.Supergroup.stringified -> ChatType.Supergroup
|
||||
ChatType.Channel.stringified -> ChatType.Channel
|
||||
else -> ChatType.Unknown(this)
|
||||
}
|
||||
|
||||
@RiskFeature
|
||||
@@ -63,15 +81,16 @@ object ChatSerializer : KSerializer<Chat> {
|
||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||
|
||||
when (type) {
|
||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.SupergroupChatType -> if (isForum) {
|
||||
ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownChatType(
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.Unknown -> UnknownChatType(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
decodedJson.toString(),
|
||||
decodedJson
|
||||
@@ -101,15 +120,16 @@ object PreviewChatSerializer : KSerializer<PreviewChat> {
|
||||
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 -> if (isForum) {
|
||||
ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownChatType(
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.Unknown -> UnknownChatType(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
decodedJson.toString(),
|
||||
decodedJson
|
||||
@@ -143,16 +163,16 @@ sealed class ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
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 -> if (isForum) {
|
||||
ChatType.Sender -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.UnknownChatType -> UnknownExtendedChat(
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.Unknown -> UnknownExtendedChat(
|
||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||
decodedJson.toString(),
|
||||
decodedJson
|
||||
|
||||
@@ -184,6 +184,10 @@ data class ExtendedSupergroupChatImpl(
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(hasVisibleHistoryField)
|
||||
override val newMembersSeeHistory: Boolean = false,
|
||||
@SerialName(unrestrictBoostsCountField)
|
||||
override val unrestrictBoostsCount: Int? = null,
|
||||
@SerialName(customEmojiStickerSetNameField)
|
||||
override val customEmojiStickerSetName: StickerSetName? = null,
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -242,6 +246,10 @@ data class ExtendedForumChatImpl(
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(hasVisibleHistoryField)
|
||||
override val newMembersSeeHistory: Boolean = false,
|
||||
@SerialName(unrestrictBoostsCountField)
|
||||
override val unrestrictBoostsCount: Int? = null,
|
||||
@SerialName(customEmojiStickerSetNameField)
|
||||
override val customEmojiStickerSetName: StickerSetName? = null,
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -59,7 +59,9 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext
|
||||
val stickerSetName: StickerSetName?
|
||||
val canSetStickerSet: Boolean
|
||||
val linkedChannelChatId: IdChatIdentifier?
|
||||
val unrestrictBoostsCount: Int?
|
||||
val location: ChatLocation?
|
||||
val customEmojiStickerSetName: StickerSetName?
|
||||
|
||||
/**
|
||||
* This field represents field "join_to_send_messages" from API
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents
|
||||
|
||||
import dev.inmo.tgbotapi.types.boostCountField
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostAdded(
|
||||
@SerialName(boostCountField)
|
||||
val count: Int
|
||||
) : PublicChatEvent
|
||||
@@ -123,6 +123,7 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
override val senderBoostsCount: Int?
|
||||
) : CommonGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
@@ -137,8 +138,9 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
senderBoostsCount: Int?,
|
||||
) : this(
|
||||
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId
|
||||
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount
|
||||
)
|
||||
}
|
||||
|
||||
@@ -226,6 +228,7 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
override val senderBoostsCount: Int?,
|
||||
) : CommonForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
@@ -241,7 +244,8 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
senderBoostsCount: Int?,
|
||||
) : this(
|
||||
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId
|
||||
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount
|
||||
)
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ internal data class RawMessage(
|
||||
private val is_topic_message: Boolean? = null,
|
||||
private val is_automatic_forward: Boolean? = null,
|
||||
private val reply_to_message: RawMessage? = null,
|
||||
private val reply_to_story: Story? = null,
|
||||
private val external_reply: ReplyInfo.External? = null,
|
||||
private val quote: TextQuote? = null,
|
||||
private val via_bot: CommonBot? = null,
|
||||
@@ -98,6 +99,7 @@ internal data class RawMessage(
|
||||
private val successful_payment: SuccessfulPayment? = null,
|
||||
private val giveaway: Giveaway? = null,
|
||||
private val giveaway_winners: GiveawayResults? = null,
|
||||
private val sender_boost_count: Int? = null,
|
||||
|
||||
private val users_shared: UsersShared? = null,
|
||||
private val chat_shared: ChatShared? = null,
|
||||
@@ -117,6 +119,9 @@ internal data class RawMessage(
|
||||
private val general_forum_topic_unhidden: GeneralForumTopicUnhidden? = null,
|
||||
private val write_access_allowed: WriteAccessAllowed? = null,
|
||||
|
||||
// Boost added to groups
|
||||
private val boost_added: ChatBoostAdded? = null,
|
||||
|
||||
// AutoDelete Message time changed
|
||||
private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null,
|
||||
|
||||
@@ -247,6 +252,7 @@ internal data class RawMessage(
|
||||
giveaway_created != null -> giveaway_created
|
||||
giveaway_winners is GiveawayPrivateResults -> giveaway_winners
|
||||
giveaway_completed != null -> giveaway_completed
|
||||
boost_added != null -> boost_added
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -295,6 +301,7 @@ internal data class RawMessage(
|
||||
reply_to_message != null -> ReplyInfo.Internal(
|
||||
reply_to_message.asMessage
|
||||
)
|
||||
reply_to_story != null -> ReplyInfo.ToStory(reply_to_story)
|
||||
external_reply != null -> external_reply
|
||||
else -> null
|
||||
}
|
||||
@@ -367,7 +374,8 @@ internal data class RawMessage(
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
media_group_id
|
||||
media_group_id,
|
||||
sender_boost_count
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -431,7 +439,8 @@ internal data class RawMessage(
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
media_group_id
|
||||
media_group_id,
|
||||
sender_boost_count
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -495,7 +504,8 @@ internal data class RawMessage(
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
media_group_id
|
||||
media_group_id,
|
||||
sender_boost_count
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<
|
||||
override val chat: PreviewGroupChat
|
||||
}
|
||||
|
||||
sealed interface PotentiallyFromUserGroupContentMessage<T : MessageContent> : GroupContentMessage<T> {
|
||||
val senderBoostsCount: Int?
|
||||
}
|
||||
|
||||
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage {
|
||||
override val chat: PreviewForumChat
|
||||
override val threadId: MessageThreadId
|
||||
@@ -28,7 +32,7 @@ interface AnonymousGroupContentMessage<T : MessageContent> : GroupContentMessage
|
||||
get() = chat
|
||||
}
|
||||
|
||||
interface CommonGroupContentMessage<T : MessageContent> : GroupContentMessage<T>, FromUserMessage
|
||||
interface CommonGroupContentMessage<T : MessageContent> : GroupContentMessage<T>, PotentiallyFromUserGroupContentMessage<T>, FromUserMessage
|
||||
|
||||
interface FromChannelForumContentMessage<T: MessageContent> : FromChannelGroupContentMessage<T>, ForumContentMessage<T>
|
||||
|
||||
@@ -37,4 +41,4 @@ interface AnonymousForumContentMessage<T : MessageContent> : ForumContentMessage
|
||||
get() = chat
|
||||
}
|
||||
|
||||
interface CommonForumContentMessage<T : MessageContent> : ForumContentMessage<T>, FromUserMessage
|
||||
interface CommonForumContentMessage<T : MessageContent> : ForumContentMessage<T>, PotentiallyFromUserGroupContentMessage<T>, FromUserMessage
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.stories
|
||||
|
||||
import dev.inmo.tgbotapi.types.ReplyInfo
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.chatField
|
||||
import dev.inmo.tgbotapi.types.idField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class Story : ReplyInfo.External.ContentVariant
|
||||
data class Story(
|
||||
@SerialName(idField)
|
||||
val id: StoryId,
|
||||
@SerialName(chatField)
|
||||
val chat: PreviewChat
|
||||
) : ReplyInfo.External.ContentVariant
|
||||
|
||||
@@ -86,7 +86,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
sourceMessage.mediaGroupId
|
||||
sourceMessage.mediaGroupId,
|
||||
sourceMessage.senderBoostsCount
|
||||
)
|
||||
is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl(
|
||||
sourceMessage.chat,
|
||||
@@ -146,7 +147,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
sourceMessage.mediaGroupId
|
||||
sourceMessage.mediaGroupId,
|
||||
sourceMessage.senderBoostsCount
|
||||
)
|
||||
is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl(
|
||||
sourceMessage.chat,
|
||||
|
||||
@@ -222,6 +222,7 @@ import dev.inmo.tgbotapi.types.media.TitledTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.GroupChatCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMemberEvent
|
||||
@@ -284,6 +285,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PublicContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.SignedMessage
|
||||
@@ -1629,6 +1631,15 @@ public inline fun ReplyInfo.internalOrThrow(): ReplyInfo.Internal = this as
|
||||
public inline fun <T> ReplyInfo.ifInternal(block: (ReplyInfo.Internal) -> T): T? = internalOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun ReplyInfo.toStoryOrNull(): ReplyInfo.ToStory? = this as?
|
||||
dev.inmo.tgbotapi.types.ReplyInfo.ToStory
|
||||
|
||||
public inline fun ReplyInfo.toStoryOrThrow(): ReplyInfo.ToStory = this as
|
||||
dev.inmo.tgbotapi.types.ReplyInfo.ToStory
|
||||
|
||||
public inline fun <T> ReplyInfo.ifToStory(block: (ReplyInfo.ToStory) -> T): T? = toStoryOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun BotAction.typingActionOrNull(): TypingAction? = this as?
|
||||
dev.inmo.tgbotapi.types.actions.TypingAction
|
||||
|
||||
@@ -2882,6 +2893,15 @@ public inline fun ChatEvent.channelChatCreatedOrThrow(): ChannelChatCreated = th
|
||||
public inline fun <T> ChatEvent.ifChannelChatCreated(block: (ChannelChatCreated) -> T): T? =
|
||||
channelChatCreatedOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.chatBoostAddedOrNull(): ChatBoostAdded? = this as?
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
|
||||
public inline fun ChatEvent.chatBoostAddedOrThrow(): ChatBoostAdded = this as
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
|
||||
public inline fun <T> ChatEvent.ifChatBoostAdded(block: (ChatBoostAdded) -> T): T? =
|
||||
chatBoostAddedOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.deleteChatPhotoOrNull(): DeleteChatPhoto? = this as?
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
||||
|
||||
@@ -3387,6 +3407,18 @@ public inline fun <T>
|
||||
Message.ifGroupContentMessage(block: (GroupContentMessage<MessageContent>) -> T): T? =
|
||||
groupContentMessageOrNull() ?.let(block)
|
||||
|
||||
public inline fun Message.potentiallyFromUserGroupContentMessageOrNull():
|
||||
PotentiallyFromUserGroupContentMessage<MessageContent>? = this as?
|
||||
dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun Message.potentiallyFromUserGroupContentMessageOrThrow():
|
||||
PotentiallyFromUserGroupContentMessage<MessageContent> = this as
|
||||
dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage<dev.inmo.tgbotapi.types.message.content.MessageContent>
|
||||
|
||||
public inline fun <T>
|
||||
Message.ifPotentiallyFromUserGroupContentMessage(block: (PotentiallyFromUserGroupContentMessage<MessageContent>) -> T):
|
||||
T? = potentiallyFromUserGroupContentMessageOrNull() ?.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>
|
||||
|
||||
Reference in New Issue
Block a user