improvements in users requests

This commit is contained in:
InsanusMokrassar 2024-01-10 23:10:28 +06:00
parent 984ffb8bae
commit 6a04b3980c

View File

@ -7,14 +7,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPoll
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared
import dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestBotButton
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestChatButton
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestGroupButton
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserButton
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserOrBotButton
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUsersShared
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.chat.PrivateChat
import dev.inmo.tgbotapi.types.keyboardButtonRequestUserLimit
import dev.inmo.tgbotapi.types.message.textsources.mention
import dev.inmo.tgbotapi.types.request.RequestId
import dev.inmo.tgbotapi.utils.row
@ -50,30 +47,35 @@ suspend fun main(args: Array<String>) {
resizeKeyboard = true,
) {
row {
requestUserOrBotButton(
requestUsersOrBotsButton(
"\uD83D\uDC64/\uD83E\uDD16",
requestIdUserOrBot
requestIdUserOrBot,
maxCount = keyboardButtonRequestUserLimit.last
)
}
row {
requestUserButton(
requestUsersButton(
"\uD83D\uDC64",
requestIdUserNonPremium,
premiumUser = false
premiumUser = false,
maxCount = keyboardButtonRequestUserLimit.last
)
requestUserButton(
requestUsersButton(
"\uD83D\uDC64",
requestIdUserAny,
premiumUser = null
premiumUser = null,
maxCount = keyboardButtonRequestUserLimit.last
)
requestUserButton(
requestUsersButton(
"\uD83D\uDC64",
requestIdUserPremium,
premiumUser = true
premiumUser = true,
maxCount = keyboardButtonRequestUserLimit.last
)
requestBotButton(
requestBotsButton(
"\uD83E\uDD16",
requestIdBot
requestIdBot,
maxCount = keyboardButtonRequestUserLimit.last
)
}
row {
@ -164,8 +166,8 @@ suspend fun main(args: Array<String>) {
)
}
onUserShared {
val userId = it.chatEvent.userId
onUsersShared {
it.chatEvent.userIds.forEach { userId ->
val userInfo = runCatchingSafely { getChat(userId) }.getOrNull()
reply(
it,
@ -185,6 +187,7 @@ suspend fun main(args: Array<String>) {
+" (user info: $userInfo; user id: $userId)"
}
}
}
onChatShared {
val chatId = it.chatEvent.chatId