1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-16 05:40:32 +00:00

final refactor, fixes and upfilling of changelog

This commit is contained in:
2021-06-28 11:10:09 +06:00
parent 21c5d42dc2
commit fd6e4b0522
6 changed files with 39 additions and 37 deletions

View File

@@ -18,14 +18,14 @@ private class SurrogateBotCommandScope(
val userId: UserId? = null
) {
fun asBotCommandScope() = when (type) {
"default" -> BotCommandScopeDefault
"all_private_chats" -> BotCommandScopeAllPrivateChats
"all_group_chats" -> BotCommandScopeAllGroupChats
"all_chat_administrators" -> BotCommandScopeAllChatAdministrators
"chat_administrators" -> BotCommandScopeChatAdministrators(
BotCommandScopeDefault.type -> BotCommandScopeDefault
BotCommandScopeAllPrivateChats.type -> BotCommandScopeAllPrivateChats
BotCommandScopeAllGroupChats.type -> BotCommandScopeAllGroupChats
BotCommandScopeAllChatAdministrators.type -> BotCommandScopeAllChatAdministrators
BotCommandScopeChatAdministrators.type -> BotCommandScopeChatAdministrators(
chatId ?: error("chat_administrators type must have $chatIdField field, but have no")
)
"chat_member" -> BotCommandScopeChatMember(
BotCommandScopeChatMember.type -> BotCommandScopeChatMember(
chatId ?: error("chat_administrators type must have $chatIdField field, but have no"),
userId ?: error("chat_administrators type must have $userIdField field, but have no")
)
@@ -89,7 +89,10 @@ data class BotCommandScopeChatAdministrators(
override val chatId: ChatIdentifier
) : ChatBotCommandScope {
@Required
override val type: String = "chat_administrators"
override val type: String = BotCommandScopeChatAdministrators.type
companion object {
const val type = "chat_administrators"
}
}
@Serializable
@@ -98,13 +101,15 @@ data class BotCommandScopeChatMember(
val userId: UserId
) : ChatBotCommandScope {
@Required
override val type: String = "chat_member"
override val type: String = BotCommandScopeChatMember.type
companion object {
const val type = "chat_member"
}
}
object BotCommandScopeSerializer : KSerializer<BotCommandScope> {
@RiskFeature
override val descriptor: SerialDescriptor = SurrogateBotCommandScope.serializer().descriptor
override fun deserialize(

View File

@@ -42,7 +42,7 @@ fun FlowsUpdatesFilter(
broadcastChannelsSize: Int = 100
) = DefaultFlowsUpdatesFilter(broadcastChannelsSize)
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
@Suppress("unused")
class DefaultFlowsUpdatesFilter(
broadcastChannelsSize: Int = 100,
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND