diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt new file mode 100644 index 0000000000..acb3288ed2 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyDescription.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.getMyDescription( + languageCode: IetfLanguageCode? = null +) = execute(GetMyDescription(languageCode)) + +suspend fun TelegramBot.getMyDescription( + languageCode: String? +) = getMyDescription(languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt new file mode 100644 index 0000000000..bfebfef460 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyShortDescription.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.getMyShortDescription( + languageCode: IetfLanguageCode? = null +) = execute(GetMyShortDescription(languageCode)) + +suspend fun TelegramBot.getMyShortDescription( + languageCode: String? +) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt new file mode 100644 index 0000000000..370ca5a9a7 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyDescription.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.GetMyCommands +import dev.inmo.tgbotapi.requests.bot.GetMyDescription +import dev.inmo.tgbotapi.requests.bot.SetMyDescription +import dev.inmo.tgbotapi.types.commands.BotCommandScope +import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault + +suspend fun TelegramBot.setMyDescription( + description: String? = null, + languageCode: IetfLanguageCode? = null +) = execute(SetMyDescription(description, languageCode)) + +suspend fun TelegramBot.setMyDescription( + description: String?, + languageCode: String? +) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt new file mode 100644 index 0000000000..2fcc869793 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescription.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.extensions.api.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription + +suspend fun TelegramBot.setMyShortDescription( + shortDescription: String? = null, + languageCode: IetfLanguageCode? = null +) = execute(SetMyShortDescription(shortDescription, languageCode)) + +suspend fun TelegramBot.setMyShortDescription( + shortDescription: String?, + languageCode: String? +) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode)) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt new file mode 100644 index 0000000000..fc971d3ea2 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyDescription.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class GetMyDescription( + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "getMyDescription" + override val resultDeserializer: DeserializationStrategy + get() = BotDescription.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt new file mode 100644 index 0000000000..c12ff05551 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/GetMyShortDescription.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class GetMyShortDescription( + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "getMyShortDescription" + override val resultDeserializer: DeserializationStrategy + get() = BotShortDescription.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt new file mode 100644 index 0000000000..f0ce0520c9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyDescription.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class SetMyDescription( + @SerialName(descriptionField) + val description: String? = null, + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "setMyDescription" + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt new file mode 100644 index 0000000000..1a11061860 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/bot/SetMyShortDescription.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.requests.bot + +import dev.inmo.micro_utils.language_codes.IetfLanguageCode +import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.types.commands.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +class SetMyShortDescription( + @SerialName(shortDescriptionField) + val shortDescription: String? = null, + @SerialName(languageCodeField) + @Serializable(IetfLanguageCodeSerializer::class) + override val ietfLanguageCode: IetfLanguageCode? = null +) : SimpleRequest, WithOptionalLanguageCode { + override fun method(): String = "setMyShortDescription" + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt new file mode 100644 index 0000000000..d94fae277d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotDescription.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BotDescription( + @SerialName(descriptionField) + val description: String +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt new file mode 100644 index 0000000000..3ecbcf8b3d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotShortDescription.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class BotShortDescription( + @SerialName(shortDescriptionField) + val shortDescription: String +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 4dada53823..051774ede9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -385,6 +385,7 @@ const val emojiField = "emoji" const val emojisField = "emojis" const val titleField = "title" const val descriptionField = "description" +const val shortDescriptionField = "short_description" const val performerField = "performer" const val durationField = "duration" const val widthField = "width"