1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-16 03:50:24 +00:00

Compare commits

...

7 Commits

Author SHA1 Message Date
df6d70b20d update dependencies 2024-02-10 17:31:20 +06:00
0b12df14db start 10.0.1 2024-02-06 22:49:15 +06:00
1590e1eef2 Merge pull request #818 from InsanusMokrassar/10.0.0
10.0.0 hotfix: add support of 'sender' chat type
2024-01-12 14:21:55 +06:00
6896bc0772 add support of 'sender' chat type 2024-01-12 14:21:06 +06:00
ce1abb0ae2 Merge pull request #814 from InsanusMokrassar/10.0.0
10.0.0
2024-01-12 12:45:49 +06:00
76a2cfd1a0 Merge pull request #817 from mefilt/master
Fixed incorrect link at readme
2024-01-08 16:34:38 +06:00
Mefilt
edca5494d4 Fixed incorrect link at readme 2024-01-08 18:29:59 +08:00
7 changed files with 71 additions and 43 deletions

View File

@@ -1,5 +1,13 @@
# 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
**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)**

View File

@@ -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).

View File

@@ -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()
}
}

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=10.0.0
library_version=10.0.1

View File

@@ -6,19 +6,19 @@ kotlin-coroutines = "1.7.3"
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.32"
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]

View File

@@ -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

View File

@@ -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