-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #937 from InsanusMokrassar/23.1.0
23.1.0
- Loading branch information
Showing
16 changed files
with
477 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...pi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/verifications/VerifyChat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
...pi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/verifications/VerifyUser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
Oops, something went wrong.