1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-01-09 09:19:55 +00:00

add support of verification methods

This commit is contained in:
InsanusMokrassar 2025-01-03 09:25:36 +06:00
parent d222987fc7
commit 427b5775a2
10 changed files with 308 additions and 0 deletions

View File

@ -2319,6 +2319,20 @@ public final class dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandlingKt {
public static synthetic fun updateHandlerWithMediaGroupsAdaptation$default (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JILjava/lang/Object;)Lkotlin/jvm/functions/Function2; public static synthetic fun updateHandlerWithMediaGroupsAdaptation$default (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JILjava/lang/Object;)Lkotlin/jvm/functions/Function2;
} }
public final class dev/inmo/tgbotapi/extensions/api/verifications/VerifyChatKt {
public static final fun verifyChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun verifyChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyChat$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun verifyChat$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/verifications/VerifyUserKt {
public static final fun verifyUser (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyUser$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/Chat;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun verifyUser-nc95W0g (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun verifyUser-nc95W0g$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhookKt { public final class dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhookKt {
public static final fun deleteWebhook (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun deleteWebhook (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
} }

View File

@ -0,0 +1,39 @@
package dev.inmo.tgbotapi.extensions.api.verifications
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.verifications.VerifyChat
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.customDescriptionField
import kotlinx.serialization.SerialName
public suspend fun TelegramBot.verifyChat(
chatId: ChatIdentifier,
description: String? = null
): Boolean = execute(
VerifyChat(
chatId = chatId,
description = description
)
)
/**
* This method may call [verifyUser] in case when [chat] is [PrivateChat]
*/
public suspend fun TelegramBot.verifyChat(
chat: Chat,
description: String? = null
): Boolean = when (chat) {
is PrivateChat -> verifyUser(
chat = chat,
description = description
)
is UnknownExtendedChat,
is UnknownChatType,
is BusinessChat,
is PublicChat -> verifyChat(
chatId = chat.id,
description = description
)
}

View File

@ -0,0 +1,2 @@
package dev.inmo.tgbotapi.extensions.api.verifications

View File

@ -0,0 +1,26 @@
package dev.inmo.tgbotapi.extensions.api.verifications
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.verifications.VerifyChat
import dev.inmo.tgbotapi.requests.verifications.VerifyUser
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.Chat
import kotlinx.serialization.SerialName
public suspend fun TelegramBot.verifyUser(
userId: UserId,
description: String? = null
): Boolean = execute(
VerifyUser(
userId = userId,
description = description
)
)
public suspend fun TelegramBot.verifyUser(
chat: Chat,
description: String? = null
): Boolean = verifyUser(
userId = chat.id.toChatId(),
description = description
)

View File

@ -7796,6 +7796,132 @@ public final class dev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetActio
public static fun getResultDeserializer (Ldev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction;)Lkotlinx/serialization/KSerializer; public static fun getResultDeserializer (Ldev/inmo/tgbotapi/requests/stickers/abstracts/StickerSetAction;)Lkotlinx/serialization/KSerializer;
} }
public final class dev/inmo/tgbotapi/requests/verifications/RemoveChatVerification : dev/inmo/tgbotapi/abstracts/types/ChatRequest, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification$Companion;
public fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;)V
public final fun component1 ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public final fun copy (Ldev/inmo/tgbotapi/types/ChatIdentifier;)Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification;Ldev/inmo/tgbotapi/types/ChatIdentifier;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification;
public fun equals (Ljava/lang/Object;)Z
public fun getChatId ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy;
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
public fun hashCode ()I
public fun method ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
}
public synthetic class dev/inmo/tgbotapi/requests/verifications/RemoveChatVerification$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/verifications/RemoveChatVerification;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/RemoveChatVerification$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/RemoveUserVerification : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification$Companion;
public synthetic fun <init> (JLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-tHkBKVM ()J
public final fun copy-HZVsHAI (J)Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification;
public static synthetic fun copy-HZVsHAI$default (Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification;JILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification;
public fun equals (Ljava/lang/Object;)Z
public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy;
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
public final fun getUserId-tHkBKVM ()J
public fun hashCode ()I
public fun method ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
}
public synthetic class dev/inmo/tgbotapi/requests/verifications/RemoveUserVerification$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/verifications/RemoveUserVerification;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/RemoveUserVerification$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/VerifyChat : dev/inmo/tgbotapi/abstracts/types/ChatRequest, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/verifications/VerifyChat$Companion;
public fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public final fun component2 ()Ljava/lang/String;
public final fun copy (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;)Ldev/inmo/tgbotapi/requests/verifications/VerifyChat;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/requests/verifications/VerifyChat;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/verifications/VerifyChat;
public fun equals (Ljava/lang/Object;)Z
public fun getChatId ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public final fun getDescription ()Ljava/lang/String;
public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy;
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
public fun hashCode ()I
public fun method ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
}
public synthetic class dev/inmo/tgbotapi/requests/verifications/VerifyChat$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/requests/verifications/VerifyChat$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/verifications/VerifyChat;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/verifications/VerifyChat;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/VerifyChat$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/VerifyUser : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/verifications/VerifyUser$Companion;
public synthetic fun <init> (JLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JLjava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-tHkBKVM ()J
public final fun component2 ()Ljava/lang/String;
public final fun copy-zv9neSE (JLjava/lang/String;)Ldev/inmo/tgbotapi/requests/verifications/VerifyUser;
public static synthetic fun copy-zv9neSE$default (Ldev/inmo/tgbotapi/requests/verifications/VerifyUser;JLjava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/verifications/VerifyUser;
public fun equals (Ljava/lang/Object;)Z
public final fun getDescription ()Ljava/lang/String;
public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy;
public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy;
public final fun getUserId-tHkBKVM ()J
public fun hashCode ()I
public fun method ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
}
public synthetic class dev/inmo/tgbotapi/requests/verifications/VerifyUser$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/requests/verifications/VerifyUser$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/verifications/VerifyUser;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/verifications/VerifyUser;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/verifications/VerifyUser$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/requests/webhook/DeleteWebhook : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { public final class dev/inmo/tgbotapi/requests/webhook/DeleteWebhook : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/webhook/DeleteWebhook$Companion; public static final field Companion Ldev/inmo/tgbotapi/requests/webhook/DeleteWebhook$Companion;
public fun <init> ()V public fun <init> ()V
@ -8927,6 +9053,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt {
public static final field creatorField Ljava/lang/String; public static final field creatorField Ljava/lang/String;
public static final field credentialsField Ljava/lang/String; public static final field credentialsField Ljava/lang/String;
public static final field currencyField Ljava/lang/String; public static final field currencyField Ljava/lang/String;
public static final field customDescriptionField Ljava/lang/String;
public static final field customEmojiField Ljava/lang/String; public static final field customEmojiField Ljava/lang/String;
public static final field customEmojiIdField Ljava/lang/String; public static final field customEmojiIdField Ljava/lang/String;
public static final field customEmojiIdsField Ljava/lang/String; public static final field customEmojiIdsField Ljava/lang/String;

View File

@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class RemoveChatVerification(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "removeChatVerification"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class RemoveUserVerification(
@SerialName(userIdField)
val userId: UserId,
): SimpleRequest<Boolean> {
override fun method(): String = "removeUserVerification"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.customDescriptionField
import dev.inmo.tgbotapi.types.descriptionField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class VerifyChat(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(customDescriptionField)
val description: String? = null
): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "verifyChat"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,25 @@
package dev.inmo.tgbotapi.requests.verifications
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class VerifyUser(
@SerialName(userIdField)
val userId: UserId,
@SerialName(customDescriptionField)
val description: String? = null
): SimpleRequest<Boolean> {
override fun method(): String = "verifyUser"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -427,6 +427,7 @@ const val emojiField = "emoji"
const val emojisField = "emojis" const val emojisField = "emojis"
const val titleField = "title" const val titleField = "title"
const val descriptionField = "description" const val descriptionField = "description"
const val customDescriptionField = "custom_description"
const val shortDescriptionField = "short_description" const val shortDescriptionField = "short_description"
const val performerField = "performer" const val performerField = "performer"
const val durationField = "duration" const val durationField = "duration"