1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

add FromUser interface to objects where field user is present

This commit is contained in:
vasya 2021-06-29 00:57:32 +03:00
parent 30c138029e
commit 022e6f623a
9 changed files with 25 additions and 18 deletions

View File

@ -1,11 +1,11 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
sealed interface CallbackQuery {
sealed interface CallbackQuery : FromUser {
val id: CallbackQueryIdentifier
val user: User
val chatInstance: String
}

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import kotlinx.serialization.SerialName
@ -10,7 +11,7 @@ data class ChatMemberUpdated(
@SerialName(chatField)
val chat: Chat,
@SerialName(fromField)
val user: User,
override val user: User,
@SerialName(dateField)
val date: TelegramDate,
@SerialName(oldChatMemberField)
@ -19,4 +20,4 @@ data class ChatMemberUpdated(
val newChatMemberState: ChatMember,
@SerialName(inviteLinkField)
val inviteLink: ChatInviteLink? = null
)
) : FromUser

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.ChosenInlineResult
import dev.inmo.tgbotapi.types.location.StaticLocation
@ -11,14 +12,14 @@ internal data class RawChosenInlineResult(
@SerialName(resultIdField)
val resultId: InlineQueryIdentifier, //chosen temporary, can be changed
@SerialName(fromField)
val user: User,
override val user: User,
@SerialName(queryField)
val query: String,
@SerialName(locationField)
val location: StaticLocation? = null,
@SerialName(inlineMessageIdField)
val inlineMessageId: InlineMessageIdentifier? = null
) {
) : FromUser {
val asChosenInlineResult: ChosenInlineResult by lazy {
location ?.let {
LocationChosenInlineResult(resultId, user, location, inlineMessageId, query)

View File

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

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.games
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -9,7 +10,7 @@ data class GameHighScore (
@SerialName(positionField)
val position: Long,
@SerialName(userField)
val user: User,
override val user: User,
@SerialName(scoreField)
val score: Long
)
) : FromUser

View File

@ -1,8 +1,9 @@
package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
data class LeftChatMember(
val user: User
): CommonEvent
override val user: User
): CommonEvent, FromUser

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.payments
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.payments.abstracts.*
import kotlinx.serialization.SerialName
@ -11,7 +12,7 @@ data class PreCheckoutQuery(
@SerialName(idField)
val id: PreCheckoutQueryId,
@SerialName(fromField)
val user: User,
override val user: User,
@SerialName(currencyField)
override val currency: Currency,
@SerialName(totalAmountField)
@ -22,4 +23,4 @@ data class PreCheckoutQuery(
val shippingOptionId: ShippingOptionIdentifier? = null,
@SerialName(orderInfoField)
val orderInfo: OrderInfo? = null
) : Currencied, Amounted
) : Currencied, Amounted, FromUser

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.payments
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -9,9 +10,9 @@ data class ShippingQuery(
@SerialName(idField)
val id: ShippingQueryIdentifier,
@SerialName(fromField)
val user: User,
override val user: User,
@SerialName(invoicePayloadField)
val invoicePayload: InvoicePayload,
@SerialName(shippingAddressField)
val shippingAddress: ShippingAddress
)
) : FromUser

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.polls
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -9,7 +10,7 @@ data class PollAnswer(
@SerialName(pollIdField)
val pollId: PollIdentifier,
@SerialName(userField)
val user: User,
override val user: User,
@SerialName(optionIdsField)
val chosen: List<Int>
)
) : FromUser