mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 20:40:20 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df6d70b20d | |||
| 0b12df14db | |||
| 1590e1eef2 | |||
| 6896bc0772 | |||
| ce1abb0ae2 | |||
| 76a2cfd1a0 | |||
|
|
edca5494d4 |
@@ -1,5 +1,13 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 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
|
## 10.0.0
|
||||||
|
|
||||||
**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)**
|
**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)**
|
||||||
|
|||||||
@@ -118,5 +118,5 @@ suspend fun main() {
|
|||||||
### More examples
|
### More examples
|
||||||
|
|
||||||
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
|
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).
|
[chat](https://t.me/InMoTelegramBotAPIChat).
|
||||||
|
|||||||
12
build.gradle
12
build.gradle
@@ -54,13 +54,13 @@ if (new File(projectDir, "secret.gradle").exists()) {
|
|||||||
githubRelease {
|
githubRelease {
|
||||||
token "${project.property('GITHUB_RELEASE_TOKEN')}"
|
token "${project.property('GITHUB_RELEASE_TOKEN')}"
|
||||||
|
|
||||||
owner "InsanusMokrassar"
|
owner = "InsanusMokrassar"
|
||||||
repo "TelegramBotAPI"
|
repo = "TelegramBotAPI"
|
||||||
|
|
||||||
tagName "v$library_version"
|
tagName = "v$library_version"
|
||||||
releaseName "$library_version"
|
releaseName = "$library_version"
|
||||||
targetCommitish "$library_version"
|
targetCommitish = "$library_version"
|
||||||
|
|
||||||
body getCurrentVersionChangelog()
|
body = getCurrentVersionChangelog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=10.0.0
|
library_version=10.0.1
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ kotlin-coroutines = "1.7.3"
|
|||||||
|
|
||||||
javax-activation = "1.1.1"
|
javax-activation = "1.1.1"
|
||||||
|
|
||||||
korlibs = "5.3.0"
|
korlibs = "5.3.1"
|
||||||
uuid = "0.8.2"
|
uuid = "0.8.2"
|
||||||
ktor = "2.3.7"
|
ktor = "2.3.8"
|
||||||
|
|
||||||
ksp = "1.9.22-1.0.16"
|
ksp = "1.9.22-1.0.17"
|
||||||
kotlin-poet = "1.15.3"
|
kotlin-poet = "1.16.0"
|
||||||
|
|
||||||
microutils = "0.20.26"
|
microutils = "0.20.32"
|
||||||
kslog = "1.3.1"
|
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"
|
dokka = "1.9.10"
|
||||||
|
|
||||||
[libraries]
|
[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
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|||||||
@@ -17,23 +17,41 @@ private val formatter
|
|||||||
sealed class ChatType {
|
sealed class ChatType {
|
||||||
abstract val stringified: String
|
abstract val stringified: String
|
||||||
@Serializable(ChatTypeSerializer::class)
|
@Serializable(ChatTypeSerializer::class)
|
||||||
object PrivateChatType : ChatType() { override val stringified = "private" }
|
object Sender : ChatType() { override val stringified = "sender" }
|
||||||
@Serializable(ChatTypeSerializer::class)
|
@Serializable(ChatTypeSerializer::class)
|
||||||
object GroupChatType : ChatType() { override val stringified = "group" }
|
object Private : ChatType() { override val stringified = "private" }
|
||||||
@Serializable(ChatTypeSerializer::class)
|
@Serializable(ChatTypeSerializer::class)
|
||||||
object SupergroupChatType : ChatType() { override val stringified = "supergroup" }
|
object Group : ChatType() { override val stringified = "group" }
|
||||||
@Serializable(ChatTypeSerializer::class)
|
@Serializable(ChatTypeSerializer::class)
|
||||||
object ChannelChatType : ChatType() { override val stringified = "channel" }
|
object Supergroup : ChatType() { override val stringified = "supergroup" }
|
||||||
@Serializable(ChatTypeSerializer::class)
|
@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
|
val String.asChatType
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
ChatType.PrivateChatType.stringified -> ChatType.PrivateChatType
|
ChatType.Sender.stringified -> ChatType.Sender
|
||||||
ChatType.GroupChatType.stringified -> ChatType.GroupChatType
|
ChatType.Private.stringified -> ChatType.Private
|
||||||
ChatType.SupergroupChatType.stringified -> ChatType.SupergroupChatType
|
ChatType.Group.stringified -> ChatType.Group
|
||||||
ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType
|
ChatType.Supergroup.stringified -> ChatType.Supergroup
|
||||||
else -> ChatType.UnknownChatType(this)
|
ChatType.Channel.stringified -> ChatType.Channel
|
||||||
|
else -> ChatType.Unknown(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RiskFeature
|
@RiskFeature
|
||||||
@@ -63,15 +81,16 @@ object ChatSerializer : KSerializer<Chat> {
|
|||||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||||
|
|
||||||
when (type) {
|
when (type) {
|
||||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.SupergroupChatType -> if (isForum) {
|
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||||
|
ChatType.Supergroup -> if (isForum) {
|
||||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||||
} else {
|
} else {
|
||||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||||
}
|
}
|
||||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||||
is ChatType.UnknownChatType -> UnknownChatType(
|
is ChatType.Unknown -> UnknownChatType(
|
||||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||||
decodedJson.toString(),
|
decodedJson.toString(),
|
||||||
decodedJson
|
decodedJson
|
||||||
@@ -101,15 +120,16 @@ object PreviewChatSerializer : KSerializer<PreviewChat> {
|
|||||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||||
|
|
||||||
return when (type) {
|
return when (type) {
|
||||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.SupergroupChatType -> if (isForum) {
|
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||||
|
ChatType.Supergroup -> if (isForum) {
|
||||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||||
} else {
|
} else {
|
||||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||||
}
|
}
|
||||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||||
is ChatType.UnknownChatType -> UnknownChatType(
|
is ChatType.Unknown -> UnknownChatType(
|
||||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||||
decodedJson.toString(),
|
decodedJson.toString(),
|
||||||
decodedJson
|
decodedJson
|
||||||
@@ -143,16 +163,16 @@ sealed class ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
|||||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||||
|
|
||||||
return when (type) {
|
return when (type) {
|
||||||
// else -> throw IllegalArgumentException("Unknown type of chat")
|
ChatType.Sender -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.PrivateChatType -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
ChatType.Private -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||||
ChatType.GroupChatType -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson)
|
ChatType.Group -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson)
|
||||||
ChatType.SupergroupChatType -> if (isForum) {
|
ChatType.Supergroup -> if (isForum) {
|
||||||
formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
||||||
} else {
|
} else {
|
||||||
formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||||
}
|
}
|
||||||
ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
ChatType.Channel -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||||
is ChatType.UnknownChatType -> UnknownExtendedChat(
|
is ChatType.Unknown -> UnknownExtendedChat(
|
||||||
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(),
|
||||||
decodedJson.toString(),
|
decodedJson.toString(),
|
||||||
decodedJson
|
decodedJson
|
||||||
|
|||||||
Reference in New Issue
Block a user