mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
update user shared to users shared
This commit is contained in:
parent
c025a027c6
commit
fc183bfd2f
@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@ -202,7 +202,7 @@ suspend fun BehaviourContext.waitChatSharedRequest(
|
|||||||
suspend fun BehaviourContext.waitUserShared(
|
suspend fun BehaviourContext.waitUserShared(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEvents<UserShared>(initRequest, errorFactory)
|
) = waitEvents<UsersShared>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatShared(
|
suspend fun BehaviourContext.waitChatShared(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
@ -196,7 +196,7 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
|||||||
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEventsMessages<UserShared>(initRequest, errorFactory)
|
) = waitEventsMessages<UsersShared>(initRequest, errorFactory)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
@ -25,7 +25,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
|
|||||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
||||||
@ -776,10 +776,10 @@ suspend fun <BC : BehaviourContext> BC.onChatSharedRequest(
|
|||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
||||||
initialFilter: SimpleFilter<PrivateEventMessage<UserShared>>? = null,
|
initialFilter: SimpleFilter<PrivateEventMessage<UsersShared>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UserShared>, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UsersShared>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<UserShared>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<UsersShared>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UserShared>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UsersShared>>
|
||||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ val keywordsInStickerLimit = 0 .. 20
|
|||||||
|
|
||||||
val stickerKeywordLengthLimit = 0 .. 64
|
val stickerKeywordLengthLimit = 0 .. 64
|
||||||
|
|
||||||
|
val keyboardButtonRequestUserLimit = 1 .. 10
|
||||||
|
|
||||||
val forwardMessagesLimit = 1 .. 100
|
val forwardMessagesLimit = 1 .. 100
|
||||||
val copyMessagesLimit = forwardMessagesLimit
|
val copyMessagesLimit = forwardMessagesLimit
|
||||||
val deleteMessagesLimit = forwardMessagesLimit
|
val deleteMessagesLimit = forwardMessagesLimit
|
||||||
@ -245,6 +247,7 @@ const val slowModeDelayField = "slow_mode_delay"
|
|||||||
const val maskPositionField = "mask_position"
|
const val maskPositionField = "mask_position"
|
||||||
const val phoneNumberField = "phone_number"
|
const val phoneNumberField = "phone_number"
|
||||||
const val userIdField = "user_id"
|
const val userIdField = "user_id"
|
||||||
|
const val userIdsField = "user_ids"
|
||||||
const val onlyIfBannedField = "only_if_banned"
|
const val onlyIfBannedField = "only_if_banned"
|
||||||
const val containsMasksField = "contains_masks"
|
const val containsMasksField = "contains_masks"
|
||||||
const val resultIdField = "result_id"
|
const val resultIdField = "result_id"
|
||||||
@ -331,8 +334,10 @@ const val requestContactField = "request_contact"
|
|||||||
const val requestLocationField = "request_location"
|
const val requestLocationField = "request_location"
|
||||||
const val requestPollField = "request_poll"
|
const val requestPollField = "request_poll"
|
||||||
const val requestUserField = "request_user"
|
const val requestUserField = "request_user"
|
||||||
|
const val requestUsersField = "request_users"
|
||||||
const val requestChatField = "request_chat"
|
const val requestChatField = "request_chat"
|
||||||
const val requestIdField = "request_id"
|
const val requestIdField = "request_id"
|
||||||
|
const val maxQuantityField = "max_quantity"
|
||||||
|
|
||||||
const val userIsBotField = "user_is_bot"
|
const val userIsBotField = "user_is_bot"
|
||||||
const val userIsPremiumField = "user_is_premium"
|
const val userIsPremiumField = "user_is_premium"
|
||||||
|
@ -103,13 +103,13 @@ data class RequestPollKeyboardButton(
|
|||||||
*
|
*
|
||||||
* In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is
|
* In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is
|
||||||
* recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming
|
* recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming
|
||||||
* [dev.inmo.tgbotapi.types.request.UserShared.requestId]
|
* [dev.inmo.tgbotapi.types.request.UsersShared.requestId]
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RequestUserKeyboardButton(
|
data class RequestUserKeyboardButton(
|
||||||
override val text: String,
|
override val text: String,
|
||||||
@SerialName(requestUserField)
|
@SerialName(requestUsersField)
|
||||||
val requestUser: KeyboardButtonRequestUser
|
val requestUsers: KeyboardButtonRequestUsers
|
||||||
) : KeyboardButton
|
) : KeyboardButton
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,11 +160,11 @@ object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
|||||||
asJson[requestPollField] ?.jsonObject ?: buildJsonObject { }
|
asJson[requestPollField] ?.jsonObject ?: buildJsonObject { }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
asJson is JsonObject && asJson[requestUserField] != null -> RequestUserKeyboardButton(
|
asJson is JsonObject && asJson[requestUsersField] != null -> RequestUserKeyboardButton(
|
||||||
asJson[textField]!!.jsonPrimitive.content,
|
asJson[textField]!!.jsonPrimitive.content,
|
||||||
nonstrictJsonFormat.decodeFromJsonElement(
|
nonstrictJsonFormat.decodeFromJsonElement(
|
||||||
KeyboardButtonRequestUser.serializer(),
|
KeyboardButtonRequestUsers.serializer(),
|
||||||
asJson[requestUserField] ?.jsonObject ?: buildJsonObject { }
|
asJson[requestUsersField] ?.jsonObject ?: buildJsonObject { }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton(
|
asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton(
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.buttons
|
package dev.inmo.tgbotapi.types.buttons
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.request.RequestId
|
import dev.inmo.tgbotapi.types.request.RequestId
|
||||||
import dev.inmo.tgbotapi.types.requestIdField
|
|
||||||
import dev.inmo.tgbotapi.types.userIsBotField
|
|
||||||
import dev.inmo.tgbotapi.types.userIsPremiumField
|
|
||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import kotlinx.serialization.EncodeDefault
|
import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
@ -14,17 +12,20 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
|||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@Serializable(KeyboardButtonRequestUser.Companion::class)
|
@Serializable(KeyboardButtonRequestUsers.Companion::class)
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
sealed interface KeyboardButtonRequestUser {
|
sealed interface KeyboardButtonRequestUsers {
|
||||||
val requestId: RequestId
|
val requestId: RequestId
|
||||||
val isBot: Boolean?
|
val isBot: Boolean?
|
||||||
|
val maxCount: Int
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Any(
|
data class Any(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId
|
override val requestId: RequestId,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean? = null
|
override val isBot: Boolean? = null
|
||||||
@ -35,8 +36,10 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId,
|
override val requestId: RequestId,
|
||||||
@SerialName(userIsPremiumField)
|
@SerialName(userIsPremiumField)
|
||||||
val isPremium: Boolean? = null
|
val isPremium: Boolean? = null,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean = false
|
override val isBot: Boolean = false
|
||||||
@ -45,15 +48,17 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class Bot(
|
data class Bot(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId
|
override val requestId: RequestId,
|
||||||
) : KeyboardButtonRequestUser {
|
@SerialName(maxQuantityField)
|
||||||
|
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
|
) : KeyboardButtonRequestUsers {
|
||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val isBot: Boolean = true
|
override val isBot: Boolean = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializer(KeyboardButtonRequestUser::class)
|
@Serializer(KeyboardButtonRequestUsers::class)
|
||||||
companion object : KSerializer<KeyboardButtonRequestUser> {
|
companion object : KSerializer<KeyboardButtonRequestUsers> {
|
||||||
@Serializable
|
@Serializable
|
||||||
private data class Surrogate(
|
private data class Surrogate(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
@ -61,31 +66,37 @@ sealed interface KeyboardButtonRequestUser {
|
|||||||
@SerialName(userIsBotField)
|
@SerialName(userIsBotField)
|
||||||
val userIsBot: Boolean? = null,
|
val userIsBot: Boolean? = null,
|
||||||
@SerialName(userIsPremiumField)
|
@SerialName(userIsPremiumField)
|
||||||
val userIsPremium: Boolean? = null
|
val userIsPremium: Boolean? = null,
|
||||||
|
@SerialName(maxQuantityField)
|
||||||
|
val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||||
)
|
)
|
||||||
private val realSerializer = Surrogate.serializer()
|
private val realSerializer = Surrogate.serializer()
|
||||||
|
|
||||||
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUser {
|
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUsers {
|
||||||
val surrogate = realSerializer.deserialize(decoder)
|
val surrogate = realSerializer.deserialize(decoder)
|
||||||
|
|
||||||
return when (surrogate.userIsBot) {
|
return when (surrogate.userIsBot) {
|
||||||
true -> Bot(surrogate.requestId)
|
true -> Bot(surrogate.requestId, surrogate.maxCount)
|
||||||
false -> Common(surrogate.requestId, surrogate.userIsPremium)
|
false -> Common(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount)
|
||||||
null -> Any(surrogate.requestId)
|
null -> Any(surrogate.requestId, surrogate.maxCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUser) {
|
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUsers) {
|
||||||
realSerializer.serialize(
|
realSerializer.serialize(
|
||||||
encoder,
|
encoder,
|
||||||
Surrogate(
|
Surrogate(
|
||||||
value.requestId,
|
value.requestId,
|
||||||
value.isBot,
|
value.isBot,
|
||||||
(value as? Common) ?.isPremium
|
(value as? Common) ?.isPremium,
|
||||||
|
value.maxCount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("KeyboardButtonRequestUsers", "dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers"))
|
||||||
|
typealias KeyboardButtonRequestUser = KeyboardButtonRequestUsers
|
@ -57,25 +57,25 @@ inline fun webAppReplyButton(
|
|||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestUser: KeyboardButtonRequestUser
|
requestUser: KeyboardButtonRequestUsers
|
||||||
) = RequestUserKeyboardButton(
|
) = RequestUserKeyboardButton(
|
||||||
text,
|
text,
|
||||||
requestUser
|
requestUser
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot]
|
||||||
*/
|
*/
|
||||||
inline fun requestBotReplyButton(
|
inline fun requestBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Bot(requestId)
|
KeyboardButtonRequestUsers.Bot(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
|
||||||
*/
|
*/
|
||||||
inline fun requestUserReplyButton(
|
inline fun requestUserReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
@ -83,18 +83,18 @@ inline fun requestUserReplyButton(
|
|||||||
premiumUser: Boolean? = null
|
premiumUser: Boolean? = null
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Common(requestId, premiumUser)
|
KeyboardButtonRequestUsers.Common(requestId, premiumUser)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
|
||||||
*/
|
*/
|
||||||
inline fun requestUserOrBotReplyButton(
|
inline fun requestUserOrBotReplyButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserReplyButton(
|
) = requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Any(requestId)
|
KeyboardButtonRequestUsers.Any(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import dev.inmo.tgbotapi.types.payments.Invoice
|
|||||||
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
||||||
import dev.inmo.tgbotapi.types.polls.Poll
|
import dev.inmo.tgbotapi.types.polls.Poll
|
||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.types.stories.Story
|
import dev.inmo.tgbotapi.types.stories.Story
|
||||||
import dev.inmo.tgbotapi.types.venue.Venue
|
import dev.inmo.tgbotapi.types.venue.Venue
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -97,7 +97,7 @@ internal data class RawMessage(
|
|||||||
private val dice: Dice? = null,
|
private val dice: Dice? = null,
|
||||||
private val successful_payment: SuccessfulPayment? = null,
|
private val successful_payment: SuccessfulPayment? = null,
|
||||||
|
|
||||||
private val user_shared: UserShared? = null,
|
private val users_shared: UsersShared? = null,
|
||||||
private val chat_shared: ChatShared? = null,
|
private val chat_shared: ChatShared? = null,
|
||||||
|
|
||||||
// Voice Chat Service Messages
|
// Voice Chat Service Messages
|
||||||
@ -266,7 +266,7 @@ internal data class RawMessage(
|
|||||||
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
||||||
connected_website != null -> UserLoggedIn(connected_website)
|
connected_website != null -> UserLoggedIn(connected_website)
|
||||||
web_app_data != null -> web_app_data
|
web_app_data != null -> web_app_data
|
||||||
user_shared != null -> user_shared
|
users_shared != null -> users_shared
|
||||||
chat_shared != null -> chat_shared
|
chat_shared != null -> chat_shared
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
package dev.inmo.tgbotapi.types.request
|
package dev.inmo.tgbotapi.types.request
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.requestIdField
|
|
||||||
import dev.inmo.tgbotapi.types.userIdField
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UserShared(
|
data class UsersShared(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
override val requestId: RequestId,
|
override val requestId: RequestId,
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdsField)
|
||||||
val userId: UserId
|
val userIds: List<UserId>
|
||||||
) : ChatSharedRequest {
|
) : ChatSharedRequest {
|
||||||
|
val userId: UserId
|
||||||
|
get() = userIds.first()
|
||||||
|
constructor(
|
||||||
|
requestId: RequestId,
|
||||||
|
userId: UserId
|
||||||
|
) : this(requestId, listOf(userId))
|
||||||
override val chatId: ChatId
|
override val chatId: ChatId
|
||||||
get() = userId
|
get() = userId
|
||||||
}
|
}
|
@ -102,7 +102,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardBu
|
|||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.WebAppInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.WebAppInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser
|
import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.buttons.ReplyForce
|
import dev.inmo.tgbotapi.types.buttons.ReplyForce
|
||||||
import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup
|
||||||
@ -420,7 +420,7 @@ import dev.inmo.tgbotapi.types.reactions.Reaction
|
|||||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
import dev.inmo.tgbotapi.types.request.RequestResponse
|
import dev.inmo.tgbotapi.types.request.RequestResponse
|
||||||
import dev.inmo.tgbotapi.types.request.UserShared
|
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
|
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.ChannelPostUpdate
|
import dev.inmo.tgbotapi.types.update.ChannelPostUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
||||||
@ -1735,32 +1735,32 @@ public inline fun <T>
|
|||||||
InlineKeyboardButton.ifWebAppInlineKeyboardButton(block: (WebAppInlineKeyboardButton) -> T): T?
|
InlineKeyboardButton.ifWebAppInlineKeyboardButton(block: (WebAppInlineKeyboardButton) -> T): T?
|
||||||
= webAppInlineKeyboardButtonOrNull() ?.let(block)
|
= webAppInlineKeyboardButtonOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.anyOrNull(): KeyboardButtonRequestUser.Any? = this as?
|
public inline fun KeyboardButtonRequestUsers.anyOrNull(): KeyboardButtonRequestUsers.Any? = this as?
|
||||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any
|
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.anyOrThrow(): KeyboardButtonRequestUser.Any = this as
|
public inline fun KeyboardButtonRequestUsers.anyOrThrow(): KeyboardButtonRequestUsers.Any = this as
|
||||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any
|
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any
|
||||||
|
|
||||||
public inline fun <T> KeyboardButtonRequestUser.ifAny(block: (KeyboardButtonRequestUser.Any) -> T):
|
public inline fun <T> KeyboardButtonRequestUsers.ifAny(block: (KeyboardButtonRequestUsers.Any) -> T):
|
||||||
T? = anyOrNull() ?.let(block)
|
T? = anyOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.botOrNull(): KeyboardButtonRequestUser.Bot? = this as?
|
public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestUsers.Bot? = this as?
|
||||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot
|
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.botOrThrow(): KeyboardButtonRequestUser.Bot = this as
|
public inline fun KeyboardButtonRequestUsers.botOrThrow(): KeyboardButtonRequestUsers.Bot = this as
|
||||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot
|
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
|
||||||
|
|
||||||
public inline fun <T> KeyboardButtonRequestUser.ifBot(block: (KeyboardButtonRequestUser.Bot) -> T):
|
public inline fun <T> KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T):
|
||||||
T? = botOrNull() ?.let(block)
|
T? = botOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.commonOrNull(): KeyboardButtonRequestUser.Common? = this
|
public inline fun KeyboardButtonRequestUsers.commonOrNull(): KeyboardButtonRequestUsers.Common? = this
|
||||||
as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common
|
as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common
|
||||||
|
|
||||||
public inline fun KeyboardButtonRequestUser.commonOrThrow(): KeyboardButtonRequestUser.Common = this
|
public inline fun KeyboardButtonRequestUsers.commonOrThrow(): KeyboardButtonRequestUsers.Common = this
|
||||||
as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common
|
as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common
|
||||||
|
|
||||||
public inline fun <T>
|
public inline fun <T>
|
||||||
KeyboardButtonRequestUser.ifCommon(block: (KeyboardButtonRequestUser.Common) -> T): T? =
|
KeyboardButtonRequestUsers.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? =
|
||||||
commonOrNull() ?.let(block)
|
commonOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
|
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
|
||||||
@ -2972,13 +2972,13 @@ public inline fun ChatEvent.chatSharedRequestOrThrow(): ChatSharedRequest = this
|
|||||||
public inline fun <T> ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
public inline fun <T> ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
||||||
chatSharedRequestOrNull() ?.let(block)
|
chatSharedRequestOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun ChatEvent.userSharedOrNull(): UserShared? = this as?
|
public inline fun ChatEvent.userSharedOrNull(): UsersShared? = this as?
|
||||||
dev.inmo.tgbotapi.types.request.UserShared
|
dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
|
|
||||||
public inline fun ChatEvent.userSharedOrThrow(): UserShared = this as
|
public inline fun ChatEvent.userSharedOrThrow(): UsersShared = this as
|
||||||
dev.inmo.tgbotapi.types.request.UserShared
|
dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
|
|
||||||
public inline fun <T> ChatEvent.ifUserShared(block: (UserShared) -> T): T? = userSharedOrNull()
|
public inline fun <T> ChatEvent.ifUserShared(block: (UsersShared) -> T): T? = userSharedOrNull()
|
||||||
?.let(block)
|
?.let(block)
|
||||||
|
|
||||||
public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as?
|
public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as?
|
||||||
@ -4564,13 +4564,13 @@ public inline fun RequestResponse.chatSharedRequestOrThrow(): ChatSharedRequest
|
|||||||
public inline fun <T> RequestResponse.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
public inline fun <T> RequestResponse.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
||||||
chatSharedRequestOrNull() ?.let(block)
|
chatSharedRequestOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun RequestResponse.userSharedOrNull(): UserShared? = this as?
|
public inline fun RequestResponse.userSharedOrNull(): UsersShared? = this as?
|
||||||
dev.inmo.tgbotapi.types.request.UserShared
|
dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
|
|
||||||
public inline fun RequestResponse.userSharedOrThrow(): UserShared = this as
|
public inline fun RequestResponse.userSharedOrThrow(): UsersShared = this as
|
||||||
dev.inmo.tgbotapi.types.request.UserShared
|
dev.inmo.tgbotapi.types.request.UsersShared
|
||||||
|
|
||||||
public inline fun <T> RequestResponse.ifUserShared(block: (UserShared) -> T): T? =
|
public inline fun <T> RequestResponse.ifUserShared(block: (UsersShared) -> T): T? =
|
||||||
userSharedOrNull() ?.let(block)
|
userSharedOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun Update.callbackQueryUpdateOrNull(): CallbackQueryUpdate? = this as?
|
public inline fun Update.callbackQueryUpdateOrNull(): CallbackQueryUpdate? = this as?
|
||||||
|
@ -139,7 +139,7 @@ inline fun ReplyKeyboardRowBuilder.webAppButton(
|
|||||||
*/
|
*/
|
||||||
inline fun ReplyKeyboardRowBuilder.requestUserButton(
|
inline fun ReplyKeyboardRowBuilder.requestUserButton(
|
||||||
text: String,
|
text: String,
|
||||||
requestUser: KeyboardButtonRequestUser
|
requestUser: KeyboardButtonRequestUsers
|
||||||
) = add(
|
) = add(
|
||||||
requestUserReplyButton(
|
requestUserReplyButton(
|
||||||
text,
|
text,
|
||||||
@ -148,7 +148,7 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot]
|
||||||
*
|
*
|
||||||
* @see replyKeyboard
|
* @see replyKeyboard
|
||||||
* @see ReplyKeyboardBuilder.row
|
* @see ReplyKeyboardBuilder.row
|
||||||
@ -158,11 +158,11 @@ inline fun ReplyKeyboardRowBuilder.requestBotButton(
|
|||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserButton(
|
) = requestUserButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Bot(requestId)
|
KeyboardButtonRequestUsers.Bot(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
|
||||||
*
|
*
|
||||||
* @see replyKeyboard
|
* @see replyKeyboard
|
||||||
* @see ReplyKeyboardBuilder.row
|
* @see ReplyKeyboardBuilder.row
|
||||||
@ -173,11 +173,11 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton(
|
|||||||
premiumUser: Boolean? = null
|
premiumUser: Boolean? = null
|
||||||
) = requestUserButton(
|
) = requestUserButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Common(requestId, premiumUser)
|
KeyboardButtonRequestUsers.Common(requestId, premiumUser)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
* Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
|
||||||
*
|
*
|
||||||
* @see replyKeyboard
|
* @see replyKeyboard
|
||||||
* @see ReplyKeyboardBuilder.row
|
* @see ReplyKeyboardBuilder.row
|
||||||
@ -187,7 +187,7 @@ inline fun ReplyKeyboardRowBuilder.requestUserOrBotButton(
|
|||||||
requestId: RequestId
|
requestId: RequestId
|
||||||
) = requestUserButton(
|
) = requestUserButton(
|
||||||
text,
|
text,
|
||||||
KeyboardButtonRequestUser.Any(requestId)
|
KeyboardButtonRequestUsers.Any(requestId)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user