mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-14 21:00:15 +00:00
*MyCommands actualization
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||
|
||||
sealed interface MyCommandsRequest<T : Any> : SimpleRequest<T> {
|
||||
val scope: BotCommandScope
|
||||
val languageCode: String?
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import dev.inmo.tgbotapi.types.languageCodeField
|
||||
import dev.inmo.tgbotapi.types.scopeField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class DeleteMyCommands(
|
||||
@SerialName(scopeField)
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
) : MyCommandsRequest<Boolean> {
|
||||
override fun method(): String = "deleteMyCommands"
|
||||
override val requestSerializer: SerializationStrategy<DeleteMyCommands> = serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean> = Boolean.serializer()
|
||||
|
||||
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
||||
}
|
@@ -1,17 +1,26 @@
|
||||
package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.BotCommand
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
private val getMyCommandsSerializer = ListSerializer(BotCommand.serializer())
|
||||
|
||||
@Serializable
|
||||
object GetMyCommands : SimpleRequest<List<BotCommand>> {
|
||||
data class GetMyCommands(
|
||||
@SerialName(scopeField)
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
) : MyCommandsRequest<List<BotCommand>> {
|
||||
override fun method(): String = "getMyCommands"
|
||||
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
||||
get() = getMyCommandsSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
||||
}
|
||||
|
@@ -2,14 +2,20 @@ package dev.inmo.tgbotapi.requests.bot
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.commands.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
class SetMyCommands(
|
||||
@SerialName(botCommandsField)
|
||||
val commands: List<BotCommand>
|
||||
) : SimpleRequest<Boolean> {
|
||||
val commands: List<BotCommand>,
|
||||
@SerialName(scopeField)
|
||||
@Serializable(BotCommandScopeSerializer::class)
|
||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||
@SerialName(languageCodeField)
|
||||
override val languageCode: String? = null
|
||||
) : MyCommandsRequest<Boolean> {
|
||||
override fun method(): String = "setMyCommands"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
|
@@ -234,6 +234,7 @@ const val hideUrlField = "hide_url"
|
||||
|
||||
const val botCommandField = "command"
|
||||
const val botCommandsField = "commands"
|
||||
const val scopeField = "scope"
|
||||
|
||||
const val isMemberField = "is_member"
|
||||
const val canSendMessagesField = "can_send_messages"
|
||||
|
Reference in New Issue
Block a user