mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-07-04 00:55:26 +00:00
Add Bot API 10.1 Join Request Queries support
Adds: - ChatJoinRequestQueryId value class and ChatJoinRequest.queryId field - ExtendedBot.supportsJoinRequestQueries (User.supports_join_request_queries) - ExtendedChat.guardBot (ChatFullInfo.guard_bot), parsed for public chats - AnswerChatJoinRequestQuery request + ChatJoinRequestQueryResult enum - SendChatJoinRequestWebApp request - answerChatJoinRequestQuery / sendChatJoinRequestWebApp TelegramBot extensions Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatJoinRequestQueryId
|
||||
import dev.inmo.tgbotapi.types.chatJoinRequestQueryIdField
|
||||
import dev.inmo.tgbotapi.types.resultField
|
||||
import dev.inmo.tgbotapi.utils.serializers.UnitFromBooleanSerializer
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
/**
|
||||
* Result of an [AnswerChatJoinRequestQuery].
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#answerchatjoinrequestquery">answerChatJoinRequestQuery</a>
|
||||
*/
|
||||
@Serializable
|
||||
enum class ChatJoinRequestQueryResult {
|
||||
/**
|
||||
* Allow the user to join the chat.
|
||||
*/
|
||||
@SerialName("approve")
|
||||
Approve,
|
||||
|
||||
/**
|
||||
* Disallow the user to join the chat.
|
||||
*/
|
||||
@SerialName("decline")
|
||||
Decline,
|
||||
|
||||
/**
|
||||
* Leave the decision to other administrators.
|
||||
*/
|
||||
@SerialName("queue")
|
||||
Queue
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to process a received chat join request query.
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#answerchatjoinrequestquery">answerChatJoinRequestQuery</a>
|
||||
*/
|
||||
@Serializable
|
||||
data class AnswerChatJoinRequestQuery(
|
||||
@SerialName(chatJoinRequestQueryIdField)
|
||||
val chatJoinRequestQueryId: ChatJoinRequestQueryId,
|
||||
@SerialName(resultField)
|
||||
val result: ChatJoinRequestQueryResult
|
||||
) : SimpleRequest<Unit> {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Unit>
|
||||
get() = UnitFromBooleanSerializer
|
||||
|
||||
override fun method(): String = "answerChatJoinRequestQuery"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatJoinRequestQueryId
|
||||
import dev.inmo.tgbotapi.types.chatJoinRequestQueryIdField
|
||||
import dev.inmo.tgbotapi.types.webAppUrlField
|
||||
import dev.inmo.tgbotapi.utils.serializers.UnitFromBooleanSerializer
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
/**
|
||||
* Use this method to process a received chat join request query by showing a Mini App to the user before deciding the
|
||||
* outcome. Call [AnswerChatJoinRequestQuery] to resolve the join request query based on the user interaction with the
|
||||
* Mini App.
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#sendchatjoinrequestwebapp">sendChatJoinRequestWebApp</a>
|
||||
*/
|
||||
@Serializable
|
||||
data class SendChatJoinRequestWebApp(
|
||||
@SerialName(chatJoinRequestQueryIdField)
|
||||
val chatJoinRequestQueryId: ChatJoinRequestQueryId,
|
||||
@SerialName(webAppUrlField)
|
||||
val webAppUrl: String
|
||||
) : SimpleRequest<Unit> {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Unit>
|
||||
get() = UnitFromBooleanSerializer
|
||||
|
||||
override fun method(): String = "sendChatJoinRequestWebApp"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
/**
|
||||
* Identifier of a join request query.
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#chatjoinrequest">ChatJoinRequest.query_id</a>
|
||||
*/
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class ChatJoinRequestQueryId(
|
||||
val string: String
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return string
|
||||
}
|
||||
}
|
||||
@@ -568,6 +568,11 @@ const val payloadField = "payload"
|
||||
const val vcardField = "vcard"
|
||||
const val resultsField = "results"
|
||||
const val resultField = "result"
|
||||
const val guardBotField = "guard_bot"
|
||||
const val supportsJoinRequestQueriesField = "supports_join_request_queries"
|
||||
const val queryIdField = "query_id"
|
||||
const val chatJoinRequestQueryIdField = "chat_join_request_query_id"
|
||||
const val webAppUrlField = "web_app_url"
|
||||
const val certificateField = "certificate"
|
||||
const val questionField = "question"
|
||||
const val questionEntitiesField = "question_entities"
|
||||
|
||||
@@ -24,7 +24,9 @@ data class ChatJoinRequest(
|
||||
@SerialName(inviteLinkField)
|
||||
val inviteLink: ChatInviteLink? = null,
|
||||
@SerialName(bioField)
|
||||
val bio: String? = null
|
||||
val bio: String? = null,
|
||||
@SerialName(queryIdField)
|
||||
val queryId: ChatJoinRequestQueryId? = null
|
||||
) : FromUser {
|
||||
@Suppress("unused")
|
||||
val dateTime: DateTime
|
||||
|
||||
@@ -69,7 +69,9 @@ data class ExtendedChannelChatImpl(
|
||||
@SerialName(maxReactionCountField)
|
||||
override val maxReactionsCount: Int = 3,
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
) : ExtendedChannelChat
|
||||
|
||||
@Serializable
|
||||
@@ -116,7 +118,9 @@ data class ExtendedGroupChatImpl(
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val paidMessageStarCount: Int? = null,
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
) : ExtendedGroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -316,7 +320,9 @@ data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val paidMessageStarCount: Int? = null,
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -390,7 +396,9 @@ data class ExtendedForumChatImpl(
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val paidMessageStarCount: Int? = null,
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
@@ -467,7 +475,9 @@ data class ExtendedChannelDirectMessagesChatImpl(
|
||||
@SerialName(paidMessageStarCountField)
|
||||
override val paidMessageStarCount: Int? = null,
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
) : ExtendedChannelDirectMessagesChat {
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
@SerialName(isDirectMessagesField)
|
||||
@@ -495,6 +505,8 @@ data class ExtendedBot(
|
||||
val supportsInlineQueries: Boolean = false,
|
||||
@SerialName(supportsGuestQueriesField)
|
||||
val supportsGuestQueries: Boolean = false,
|
||||
@SerialName(supportsJoinRequestQueriesField)
|
||||
val supportsJoinRequestQueries: Boolean = false,
|
||||
@SerialName(canConnectToBusinessField)
|
||||
val canConnectToBusiness: Boolean = false,
|
||||
@SerialName(photoField)
|
||||
|
||||
@@ -27,6 +27,14 @@ sealed interface ExtendedChat : Chat {
|
||||
|
||||
val uniqueGiftColors: UniqueGiftColors?
|
||||
|
||||
/**
|
||||
* The bot that processes join request queries in the chat. The field is only available to chat administrators.
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#chatfullinfo">ChatFullInfo.guard_bot</a>
|
||||
*/
|
||||
val guardBot: User?
|
||||
get() = null
|
||||
|
||||
@Deprecated(
|
||||
message = "Telegram Bot API v9.0 introduced the new field, `acceptedGiftTypes`, to allow granular" +
|
||||
" control over which types of gifts user, bot, or chat can accept.",
|
||||
|
||||
Reference in New Issue
Block a user