mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
classcasts fill for WithOptionalLanguageCode
This commit is contained in:
parent
75f4226772
commit
7d35114b5d
@ -21,6 +21,7 @@
|
|||||||
default `CoroutineScope`
|
default `CoroutineScope`
|
||||||
* New typealias `SimpleFilter` for unifying triggers filter signatures
|
* New typealias `SimpleFilter` for unifying triggers filter signatures
|
||||||
* All waiters got real filters (`SimpleFilter`) and rename old filters as mappers
|
* All waiters got real filters (`SimpleFilter`) and rename old filters as mappers
|
||||||
|
* New extensions for `Any`: `as`/`when`/`require` for `WithOptionalLanguageCode` and `WithLanguageCode`
|
||||||
|
|
||||||
## 0.35.2
|
## 0.35.2
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.bot
|
package dev.inmo.tgbotapi.requests.bot
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithOptionalLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
||||||
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
|
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import dev.inmo.tgbotapi.utils.*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.types.abstracts
|
||||||
|
|
||||||
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
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.IetfLanguageCode
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.WithLanguageCode
|
import dev.inmo.tgbotapi.types.abstracts.WithLanguageCode
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
fun IetfLanguageCode?.javaLocale() = this ?.code ?.let { Locale.forLanguageTag(it) }
|
||||||
|
@ -23,6 +23,8 @@ import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
|
|||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
||||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithLanguageCode
|
||||||
|
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||||
import dev.inmo.tgbotapi.types.actions.*
|
import dev.inmo.tgbotapi.types.actions.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.*
|
import dev.inmo.tgbotapi.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
|
||||||
@ -3106,3 +3108,21 @@ inline fun Any.asFromUser(): FromUser? = this as? FromUser
|
|||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun Any.requireFromUser(): FromUser = this as FromUser
|
inline fun Any.requireFromUser(): FromUser = this as FromUser
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun <T> Any.whenWithOptionalLanguageCode(block: (WithOptionalLanguageCode) -> T) = asWithOptionalLanguageCode() ?.let(block)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.asWithOptionalLanguageCode(): WithOptionalLanguageCode? = this as? WithOptionalLanguageCode
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.requireWithOptionalLanguageCode(): WithOptionalLanguageCode = this as WithOptionalLanguageCode
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun <T> Any.whenWithLanguageCode(block: (WithLanguageCode) -> T) = asWithLanguageCode() ?.let(block)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.asWithLanguageCode(): WithLanguageCode? = this as? WithLanguageCode
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun Any.requireWithLanguageCode(): WithLanguageCode = this as WithLanguageCode
|
||||||
|
Loading…
Reference in New Issue
Block a user