mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-09 10:12:58 +00:00
add support of verification methods
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.verifications
|
||||
|
@@ -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
|
||||
)
|
Reference in New Issue
Block a user