1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00
This commit is contained in:
InsanusMokrassar 2021-06-30 11:26:31 +06:00
parent 6ba9a31fb9
commit 4f920abb61
5 changed files with 12 additions and 3 deletions

View File

@ -11,6 +11,7 @@
* New extensions `TextSourcesList#make*String` for all parse modes
* All `MessageContent` subclasses now serializable
* `ChosenInlineResult` was replaced and modified to be sealed
* `ChosenInlineResult` now extends `FromUser`
* Added `Update#sourceUser` method
* More types assumed as sent by user types now implements `FromUser` interface
* Added `Any#whenFromUser`, `Any#asFromUser` and`Any#requireFromUser` extensions

View File

@ -1,9 +1,13 @@
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class BaseChosenInlineResult(
override val resultId: InlineQueryIdentifier,
@SerialName(fromField)
override val user: User,
override val inlineMessageId: InlineMessageIdentifier?,
override val query: String

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
sealed interface ChosenInlineResult {
sealed interface ChosenInlineResult : FromUser {
val resultId: InlineQueryIdentifier //chosen temporary, can be changed
val user: User
val inlineMessageId: InlineMessageIdentifier?
val query: String
}

View File

@ -2,9 +2,13 @@ package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.location.StaticLocation
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class LocationChosenInlineResult(
override val resultId: InlineQueryIdentifier,
@SerialName(fromField)
override val user: User,
val location: StaticLocation,
override val inlineMessageId: InlineMessageIdentifier?,

View File

@ -19,7 +19,7 @@ internal data class RawChosenInlineResult(
val inlineMessageId: InlineMessageIdentifier? = null
) {
val asChosenInlineResult: ChosenInlineResult by lazy {
location?.let {
location ?.let {
LocationChosenInlineResult(resultId, user, location, inlineMessageId, query)
} ?: BaseChosenInlineResult(resultId, user, inlineMessageId, query)
}