|
| 1 | +/* |
| 2 | + * Copyright (c) 2024. ForteScarlet. |
| 3 | + * |
| 4 | + * This file is part of simbot-component-telegram. |
| 5 | + * |
| 6 | + * simbot-component-telegram is free software: you can redistribute it and/or modify it under the terms |
| 7 | + * of the GNU Lesser General Public License as published by the Free Software Foundation, |
| 8 | + * either version 3 of the License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * simbot-component-telegram is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 11 | + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | + * See the GNU Lesser General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU Lesser General Public License along with simbot-component-telegram. |
| 15 | + * If not, see <https://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | + |
| 18 | +package love.forte.simbot.telegram.api.bot.command |
| 19 | + |
| 20 | +import kotlinx.serialization.DeserializationStrategy |
| 21 | +import kotlinx.serialization.SerialName |
| 22 | +import kotlinx.serialization.Serializable |
| 23 | +import kotlinx.serialization.builtins.serializer |
| 24 | +import love.forte.simbot.telegram.api.SimpleBodyTelegramApi |
| 25 | +import love.forte.simbot.telegram.api.TelegramApiResult |
| 26 | +import love.forte.simbot.telegram.type.BotCommandScope |
| 27 | +import kotlin.jvm.JvmOverloads |
| 28 | +import kotlin.jvm.JvmStatic |
| 29 | + |
| 30 | + |
| 31 | +/** |
| 32 | + * [deleteMyCommands](https://core.telegram.org/bots/api#deletemycommands) |
| 33 | + * |
| 34 | + * Use this method to delete the list of the bot's commands for the given scope and user language. |
| 35 | + * After deletion, higher level commands will be shown to affected users. Returns True on success. |
| 36 | + * |
| 37 | + * @author ForteScarlet |
| 38 | + */ |
| 39 | +public class DeleteMyCommandsApi |
| 40 | +private constructor(body: Body) : SimpleBodyTelegramApi<Boolean>() { |
| 41 | + public companion object Factory { |
| 42 | + private const val NAME = "deleteMyCommands" |
| 43 | + private val EMPTY = DeleteMyCommandsApi(Body()) |
| 44 | + |
| 45 | + /** |
| 46 | + * Create an instance of [DeleteMyCommandsApi]. |
| 47 | + * |
| 48 | + * @param scope A JSON-serialized object, describing scope of users for which the commands are relevant. |
| 49 | + * Defaults to BotCommandScopeDefault. |
| 50 | + * @param languageCode A two-letter ISO 639-1 language code. |
| 51 | + * If empty, commands will be applied to all users from the given scope, |
| 52 | + * for whose language there are no dedicated commands |
| 53 | + */ |
| 54 | + @JvmStatic |
| 55 | + @JvmOverloads |
| 56 | + public fun create( |
| 57 | + scope: BotCommandScope? = null, |
| 58 | + languageCode: String? = null, |
| 59 | + ): DeleteMyCommandsApi { |
| 60 | + return if (scope == null && languageCode == null) { |
| 61 | + EMPTY |
| 62 | + } else { |
| 63 | + DeleteMyCommandsApi( |
| 64 | + Body( |
| 65 | + scope = scope, |
| 66 | + languageCode = languageCode |
| 67 | + ) |
| 68 | + ) |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Request body for [DeleteMyCommandsApi] |
| 75 | + * @property scope A JSON-serialized object, describing scope of users for which the commands are relevant. |
| 76 | + * Defaults to BotCommandScopeDefault. |
| 77 | + * @property languageCode A two-letter ISO 639-1 language code. |
| 78 | + * If empty, commands will be applied to all users from the given scope, |
| 79 | + * for whose language there are no dedicated commands |
| 80 | + */ |
| 81 | + @Serializable |
| 82 | + public data class Body( |
| 83 | + val scope: BotCommandScope? = null, |
| 84 | + @SerialName("language_code") |
| 85 | + val languageCode: String? = null, |
| 86 | + ) |
| 87 | + |
| 88 | + override val name: String |
| 89 | + get() = NAME |
| 90 | + |
| 91 | + override val body: Any = body |
| 92 | + |
| 93 | + override val responseDeserializer: DeserializationStrategy<Boolean> |
| 94 | + get() = Boolean.serializer() |
| 95 | + |
| 96 | + override val resultDeserializer: DeserializationStrategy<TelegramApiResult<Boolean>> |
| 97 | + get() = TelegramApiResult.BooleanSerializer |
| 98 | +} |
| 99 | + |
| 100 | +/* |
| 101 | +Parameter Type Required Description |
| 102 | + */ |
0 commit comments