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

CallbackQuery package -> queries.callback

This commit is contained in:
InsanusMokrassar 2022-04-21 22:42:54 +06:00
parent 2275a61d73
commit cdd5649c04
34 changed files with 134 additions and 94 deletions

View File

@ -8,6 +8,7 @@ __All the `tgbotapi.extensions.*` packages have been removed__
* `Core`:
* **`Ktor` package renamed. Migration:** `dev.inmo.tgbotapi.bot.Ktor` -> `dev.inmo.tgbotapi.bot.ktor`
* **`CallbackQuery` package renamed. Migration:** `dev.inmo.tgbotapi.types.CallbackQuery([\s\\.])` -> `dev.inmo.tgbotapi.types.queries.callback$1`
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json` ([#563](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/563))
* All the interfaces from `dev.inmo.tgbotapi.types.files.abstracts` have been replaced to `dev.inmo.tgbotapi.types.files` and converted to sealed ([#550](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/550))
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerCallbackQuery
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
suspend fun TelegramBot.answerCallbackQuery(

View File

@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.CallbackQuery.*
import dev.inmo.tgbotapi.types.queries.callback.*
import kotlinx.coroutines.flow.toList
typealias CallbackQueryMapper<T> = suspend T.() -> T?

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.ChatJoinRequest
import dev.inmo.tgbotapi.types.ChatMemberUpdated
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery

View File

@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
import dev.inmo.tgbotapi.types.CallbackQuery.*
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> BC.onCallbackQuery(

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.ChatJoinRequest
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
import dev.inmo.tgbotapi.types.payments.ShippingQuery

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.CommonAbstracts
import dev.inmo.tgbotapi.types.User
/**
* Inheritors of this interface have some [User] as a source of data. For example, any [dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery]
* Inheritors of this interface have some [User] as a source of data. For example, any [dev.inmo.tgbotapi.types.queries.callback.CallbackQuery]
* have [User] as the source of that query
*/
interface FromUser : WithUser {

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.requests.answers
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer

View File

@ -1,17 +1,7 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
@Deprecated("Replaced", ReplaceWith("CallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.CallbackQuery"))
typealias CallbackQuery = dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
sealed interface CallbackQuery : FromUser {
val id: CallbackQueryIdentifier
val chatInstance: String
}
data class UnknownCallbackQueryType(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
val raw: String
) : CallbackQuery
@Deprecated("Replaced", ReplaceWith("UnknownCallbackQueryType", "dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType"))
typealias UnknownCallbackQueryType = dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType

View File

@ -1,10 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
/**
* [CallbackQuery] with [data] field
*
* @see dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
*/
sealed interface DataCallbackQuery : CallbackQuery {
val data: String
}
@Deprecated("Replaced", ReplaceWith("DataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery"))
typealias DataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery

View File

@ -1,5 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
sealed interface GameShortNameCallbackQuery : CallbackQuery {
val gameShortName: String
}
@Deprecated("Replaced", ReplaceWith("GameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery"))
typealias GameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery

View File

@ -1,7 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
sealed interface InlineMessageIdCallbackQuery : CallbackQuery {
val inlineMessageId: InlineMessageIdentifier
}
@Deprecated("Replaced", ReplaceWith("InlineMessageIdCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery"))
typealias InlineMessageIdCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery

View File

@ -1,11 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.*
data class InlineMessageIdDataCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val inlineMessageId: InlineMessageIdentifier,
override val data: String
) : DataCallbackQuery, InlineMessageIdCallbackQuery
@Deprecated("Replaced", ReplaceWith("InlineMessageIdDataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery"))
typealias InlineMessageIdDataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery

View File

@ -1,11 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.*
data class InlineMessageIdGameShortNameCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val inlineMessageId: InlineMessageIdentifier,
override val gameShortName: String
) : GameShortNameCallbackQuery, InlineMessageIdCallbackQuery
@Deprecated("Replaced", ReplaceWith("InlineMessageIdGameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery"))
typealias InlineMessageIdGameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery

View File

@ -1,8 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
sealed interface MessageCallbackQuery : CallbackQuery {
val message: ContentMessage<MessageContent>
}
@Deprecated("Replaced", ReplaceWith("MessageCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery"))
typealias MessageCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery

View File

@ -1,14 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
data class MessageDataCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val message: ContentMessage<MessageContent>,
override val data: String
) : DataCallbackQuery, MessageCallbackQuery
@Deprecated("Replaced", ReplaceWith("MessageDataCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery"))
typealias MessageDataCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery

View File

@ -1,14 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
data class MessageGameShortNameCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val message: ContentMessage<MessageContent>,
override val gameShortName: String
) : GameShortNameCallbackQuery, MessageCallbackQuery
@Deprecated("Replaced", ReplaceWith("MessageGameShortNameCallbackQuery", "dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery"))
typealias MessageGameShortNameCallbackQuery = dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery

View File

@ -43,14 +43,14 @@ data class PayInlineKeyboardButton(
* Simple button with [callbackData] which you are able to catch this type of updates and data using
* [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onDataCallbackQuery] in
* case you are using Behaviour Builder OR [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.callbackQueriesFlow]
* with [kotlinx.coroutines.flow.filterIsInstance] and filtering by type [dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery]
* with [kotlinx.coroutines.flow.filterIsInstance] and filtering by type [dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery]
*/
@Serializable
data class CallbackDataInlineKeyboardButton(
@SerialName(textField)
override val text: String,
/**
* You will receive this data in [dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery.data] field
* You will receive this data in [dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery.data] field
*/
@SerialName(callbackDataField)
val callbackData: String

View File

@ -0,0 +1,17 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.CommonAbstracts.FromUser
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
sealed interface CallbackQuery : FromUser {
val id: CallbackQueryIdentifier
val chatInstance: String
}
data class UnknownCallbackQueryType(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
val raw: String
) : CallbackQuery

View File

@ -0,0 +1,10 @@
package dev.inmo.tgbotapi.types.queries.callback
/**
* [CallbackQuery] with [data] field
*
* @see dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
*/
sealed interface DataCallbackQuery : CallbackQuery {
val data: String
}

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.queries.callback
sealed interface GameShortNameCallbackQuery : CallbackQuery {
val gameShortName: String
}

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
sealed interface InlineMessageIdCallbackQuery : CallbackQuery {
val inlineMessageId: InlineMessageIdentifier
}

View File

@ -0,0 +1,11 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.*
data class InlineMessageIdDataCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val inlineMessageId: InlineMessageIdentifier,
override val data: String
) : DataCallbackQuery, InlineMessageIdCallbackQuery

View File

@ -0,0 +1,11 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.*
data class InlineMessageIdGameShortNameCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val inlineMessageId: InlineMessageIdentifier,
override val gameShortName: String
) : GameShortNameCallbackQuery, InlineMessageIdCallbackQuery

View File

@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
sealed interface MessageCallbackQuery : CallbackQuery {
val message: ContentMessage<MessageContent>
}

View File

@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
data class MessageDataCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val message: ContentMessage<MessageContent>,
override val data: String
) : DataCallbackQuery, MessageCallbackQuery

View File

@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
data class MessageGameShortNameCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: User,
override val chatInstance: String,
override val message: ContentMessage<MessageContent>,
override val gameShortName: String
) : GameShortNameCallbackQuery, MessageCallbackQuery

View File

@ -1,4 +1,4 @@
package dev.inmo.tgbotapi.types.CallbackQuery
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.*

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.update
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.update.abstracts.Update

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.update
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.CallbackQuery.RawCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.RawCallbackQuery
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult
import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery
import dev.inmo.tgbotapi.types.message.abstracts.*

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.utils
import dev.inmo.tgbotapi.types.CallbackQuery.*
import dev.inmo.tgbotapi.types.queries.callback.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.mapNotNull

View File

@ -5,7 +5,7 @@ package dev.inmo.tgbotapi.extensions.utils
import dev.inmo.tgbotapi.CommonAbstracts.*
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.CallbackQuery.*
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.ChatMember.*
import dev.inmo.tgbotapi.types.ChatMember.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.extensions.utils.extensions.raw
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.utils.updates
import dev.inmo.tgbotapi.types.CallbackQuery.*
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.mapNotNull