mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
upgrades
This commit is contained in:
parent
4085f721be
commit
9a7dd6ec9a
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
|
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
@ -8,10 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
suspend fun TelegramBot.deleteMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = execute(DeleteMyCommands(scope, languageCode))
|
) = execute(DeleteMyCommands(scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.deleteMyCommands(
|
suspend fun TelegramBot.deleteMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String? = null
|
languageCode: String? = null
|
||||||
) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
) = deleteMyCommands(scope, languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
@ -8,10 +8,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
suspend fun TelegramBot.getMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyCommands(scope, languageCode))
|
) = execute(GetMyCommands(scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyCommands(
|
suspend fun TelegramBot.getMyCommands(
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))
|
) = getMyCommands(scope, languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
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.GetMyDescription
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDescription(
|
suspend fun TelegramBot.getMyDescription(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyDescription(languageCode))
|
) = execute(GetMyDescription(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyDescription(
|
suspend fun TelegramBot.getMyDescription(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyDescription(languageCode ?.let(::IetfLanguageCode))
|
) = getMyDescription(languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyName(
|
suspend fun TelegramBot.getMyName(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyName(languageCode))
|
) = execute(GetMyName(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyName(
|
suspend fun TelegramBot.getMyName(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyName(languageCode ?.let(::IetfLanguageCode))
|
) = getMyName(languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
|
||||||
@ -8,9 +8,9 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyShortDescription(
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(GetMyShortDescription(languageCode))
|
) = execute(GetMyShortDescription(languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.getMyShortDescription(
|
suspend fun TelegramBot.getMyShortDescription(
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = getMyShortDescription(languageCode ?.let(::IetfLanguageCode))
|
) = getMyShortDescription(languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
@ -10,20 +10,20 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
commands: List<BotCommand>,
|
commands: List<BotCommand>,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = execute(SetMyCommands(commands, scope, languageCode))
|
) = execute(SetMyCommands(commands, scope, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
vararg commands: BotCommand,
|
vararg commands: BotCommand,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: IetfLanguageCode?
|
languageCode: IetfLang?
|
||||||
) = setMyCommands(commands.toList(), scope, languageCode)
|
) = setMyCommands(commands.toList(), scope, languageCode)
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
commands: List<BotCommand>,
|
commands: List<BotCommand>,
|
||||||
scope: BotCommandScope = BotCommandScopeDefault,
|
scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
languageCode: String? = null
|
languageCode: String? = null
|
||||||
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLanguageCode))
|
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLang))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyCommands(
|
suspend fun TelegramBot.setMyCommands(
|
||||||
vararg commands: BotCommand,
|
vararg commands: BotCommand,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
|
||||||
@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.setMyDescription(
|
suspend fun TelegramBot.setMyDescription(
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyDescription(description, languageCode))
|
) = execute(SetMyDescription(description, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyDescription(
|
suspend fun TelegramBot.setMyDescription(
|
||||||
description: String?,
|
description: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyDescription(description, languageCode ?.let(::IetfLanguageCode))
|
) = setMyDescription(description, languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||||
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
import dev.inmo.tgbotapi.requests.bot.GetMyName
|
||||||
@ -10,10 +10,10 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
|
|||||||
|
|
||||||
suspend fun TelegramBot.setMyName(
|
suspend fun TelegramBot.setMyName(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyName(name, languageCode))
|
) = execute(SetMyName(name, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyName(
|
suspend fun TelegramBot.setMyName(
|
||||||
name: String?,
|
name: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyName(name, languageCode ?.let(::IetfLanguageCode))
|
) = setMyName(name, languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.bot
|
package dev.inmo.tgbotapi.extensions.api.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyShortDescription(
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
shortDescription: String? = null,
|
shortDescription: String? = null,
|
||||||
languageCode: IetfLanguageCode? = null
|
languageCode: IetfLang? = null
|
||||||
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
) = execute(SetMyShortDescription(shortDescription, languageCode))
|
||||||
|
|
||||||
suspend fun TelegramBot.setMyShortDescription(
|
suspend fun TelegramBot.setMyShortDescription(
|
||||||
shortDescription: String?,
|
shortDescription: String?,
|
||||||
languageCode: String?
|
languageCode: String?
|
||||||
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLanguageCode))
|
) = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import dev.inmo.tgbotapi.types.languageCodeField
|
import dev.inmo.tgbotapi.types.languageCodeField
|
||||||
import dev.inmo.tgbotapi.types.scopeField
|
import dev.inmo.tgbotapi.types.scopeField
|
||||||
@ -14,8 +15,8 @@ data class DeleteMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<Boolean> {
|
) : MyCommandsRequest<Boolean> {
|
||||||
override fun method(): String = "deleteMyCommands"
|
override fun method(): String = "deleteMyCommands"
|
||||||
override val requestSerializer: SerializationStrategy<DeleteMyCommands>
|
override val requestSerializer: SerializationStrategy<DeleteMyCommands>
|
||||||
@ -28,7 +29,7 @@ data class DeleteMyCommands(
|
|||||||
languageCode: String?
|
languageCode: String?
|
||||||
) : this(
|
) : this(
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
companion object : MyCommandsRequest<Boolean> by DeleteMyCommands()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -15,8 +16,8 @@ data class GetMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<List<BotCommand>> {
|
) : MyCommandsRequest<List<BotCommand>> {
|
||||||
override fun method(): String = "getMyCommands"
|
override fun method(): String = "getMyCommands"
|
||||||
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
override val resultDeserializer: DeserializationStrategy<List<BotCommand>>
|
||||||
@ -29,7 +30,7 @@ data class GetMyCommands(
|
|||||||
languageCode: String?
|
languageCode: String?
|
||||||
) : this(
|
) : this(
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
companion object : MyCommandsRequest<List<BotCommand>> by GetMyCommands()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyDescription(
|
class GetMyDescription(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotDescription>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotDescription>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyDescription"
|
override fun method(): String = "getMyDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotDescription>
|
override val resultDeserializer: DeserializationStrategy<BotDescription>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyName(
|
class GetMyName(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotName>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotName>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyName"
|
override fun method(): String = "getMyName"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotName>
|
override val resultDeserializer: DeserializationStrategy<BotName>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -12,8 +13,8 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
class GetMyShortDescription(
|
class GetMyShortDescription(
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<BotShortDescription>, WithOptionalLanguageCode {
|
) : SimpleRequest<BotShortDescription>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "getMyShortDescription"
|
override fun method(): String = "getMyShortDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<BotShortDescription>
|
override val resultDeserializer: DeserializationStrategy<BotShortDescription>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.commands.*
|
import dev.inmo.tgbotapi.types.commands.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -15,8 +16,8 @@ class SetMyCommands(
|
|||||||
@Serializable(BotCommandScopeSerializer::class)
|
@Serializable(BotCommandScopeSerializer::class)
|
||||||
override val scope: BotCommandScope = BotCommandScopeDefault,
|
override val scope: BotCommandScope = BotCommandScopeDefault,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : MyCommandsRequest<Boolean> {
|
) : MyCommandsRequest<Boolean> {
|
||||||
override fun method(): String = "setMyCommands"
|
override fun method(): String = "setMyCommands"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
@ -31,7 +32,7 @@ class SetMyCommands(
|
|||||||
) : this(
|
) : this(
|
||||||
commands,
|
commands,
|
||||||
scope,
|
scope,
|
||||||
languageCode ?.let(::IetfLanguageCode)
|
languageCode ?.let(::IetfLang)
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -14,8 +14,8 @@ class SetMyDescription(
|
|||||||
@SerialName(descriptionField)
|
@SerialName(descriptionField)
|
||||||
val description: String? = null,
|
val description: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyDescription"
|
override fun method(): String = "setMyDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -14,8 +14,8 @@ class SetMyName(
|
|||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyName"
|
override fun method(): String = "setMyName"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
@ -14,8 +14,8 @@ class SetMyShortDescription(
|
|||||||
@SerialName(shortDescriptionField)
|
@SerialName(shortDescriptionField)
|
||||||
val shortDescription: String? = null,
|
val shortDescription: String? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null
|
override val ietfLanguageCode: IetfLang? = null
|
||||||
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
) : SimpleRequest<Boolean>, WithOptionalLanguageCode {
|
||||||
override fun method(): String = "setMyShortDescription"
|
override fun method(): String = "setMyShortDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.abstracts
|
package dev.inmo.tgbotapi.types.abstracts
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
|
|
||||||
interface WithOptionalLanguageCode {
|
interface WithOptionalLanguageCode {
|
||||||
val ietfLanguageCode: IetfLanguageCode?
|
val ietfLanguageCode: IetfLang?
|
||||||
|
|
||||||
val languageCode: String?
|
val languageCode: String?
|
||||||
get() = ietfLanguageCode ?.code
|
get() = ietfLanguageCode ?.code
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.chat
|
package dev.inmo.tgbotapi.types.chat
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLangSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
@ -99,8 +99,8 @@ data class CommonUser(
|
|||||||
@SerialName(usernameField)
|
@SerialName(usernameField)
|
||||||
override val username: Username? = null,
|
override val username: Username? = null,
|
||||||
@SerialName(languageCodeField)
|
@SerialName(languageCodeField)
|
||||||
@Serializable(IetfLanguageCodeSerializer::class)
|
@Serializable(IetfLangSerializer::class)
|
||||||
override val ietfLanguageCode: IetfLanguageCode? = null,
|
override val ietfLanguageCode: IetfLang? = null,
|
||||||
@SerialName(isPremiumField)
|
@SerialName(isPremiumField)
|
||||||
override val isPremium: Boolean = false,
|
override val isPremium: Boolean = false,
|
||||||
@SerialName(addedToAttachmentMenuField)
|
@SerialName(addedToAttachmentMenuField)
|
||||||
@ -112,5 +112,5 @@ data class CommonUser(
|
|||||||
lastName: String = "",
|
lastName: String = "",
|
||||||
username: Username? = null,
|
username: Username? = null,
|
||||||
languageCode: String
|
languageCode: String
|
||||||
) : this(id, firstName, lastName, username, IetfLanguageCode(languageCode))
|
) : this(id, firstName, lastName, username, IetfLang(languageCode))
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
fun IetfLang?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
||||||
fun WithOptionalLanguageCode?.javaLocale() = this ?.ietfLanguageCode ?.javaLocale()
|
fun WithOptionalLanguageCode?.javaLocale() = this ?.ietfLanguageCode ?.javaLocale()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonBot
|
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
@ -42,7 +42,7 @@ fun WebAppUser.asUser() = if (isBot == true) {
|
|||||||
firstName = firstName,
|
firstName = firstName,
|
||||||
lastName = lastName ?: "",
|
lastName = lastName ?: "",
|
||||||
username = username ?.let(::Username),
|
username = username ?.let(::Username),
|
||||||
ietfLanguageCode = languageCode ?.let(::IetfLanguageCode),
|
ietfLanguageCode = languageCode ?.let(::IetfLang),
|
||||||
isPremium = isPremium
|
isPremium = isPremium
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user