mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
add RequestId.random
This commit is contained in:
parent
ae8ef0dd3c
commit
47f1509ecc
@ -2,9 +2,14 @@ package dev.inmo.tgbotapi.types.request
|
|||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.jvm.JvmInline
|
import kotlin.jvm.JvmInline
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@JvmInline
|
@JvmInline
|
||||||
value class RequestId(
|
value class RequestId(
|
||||||
val long: Long
|
val float: Float
|
||||||
)
|
) {
|
||||||
|
companion object {
|
||||||
|
fun random() = RequestId(Random.nextFloat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -107,6 +107,8 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineK
|
|||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestChatInlineKeyboardButton
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestUserInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton
|
||||||
@ -433,6 +435,9 @@ import dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery
|
|||||||
import dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery
|
import dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery
|
||||||
import dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery
|
import dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery
|
||||||
import dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType
|
import dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType
|
||||||
|
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
|
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
|
import dev.inmo.tgbotapi.types.request.UserShared
|
||||||
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
|
||||||
@ -1879,6 +1884,30 @@ 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 InlineKeyboardButton.requestUserInlineKeyboardButtonOrNull():
|
||||||
|
RequestUserInlineKeyboardButton? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestUserInlineKeyboardButton
|
||||||
|
|
||||||
|
public inline fun InlineKeyboardButton.requestUserInlineKeyboardButtonOrThrow():
|
||||||
|
RequestUserInlineKeyboardButton = this as
|
||||||
|
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestUserInlineKeyboardButton
|
||||||
|
|
||||||
|
public inline fun <T>
|
||||||
|
InlineKeyboardButton.ifRequestUserInlineKeyboardButton(block: (RequestUserInlineKeyboardButton) -> T):
|
||||||
|
T? = requestUserInlineKeyboardButtonOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun InlineKeyboardButton.requestChatInlineKeyboardButtonOrNull():
|
||||||
|
RequestChatInlineKeyboardButton? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestChatInlineKeyboardButton
|
||||||
|
|
||||||
|
public inline fun InlineKeyboardButton.requestChatInlineKeyboardButtonOrThrow():
|
||||||
|
RequestChatInlineKeyboardButton = this as
|
||||||
|
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.RequestChatInlineKeyboardButton
|
||||||
|
|
||||||
|
public inline fun <T>
|
||||||
|
InlineKeyboardButton.ifRequestChatInlineKeyboardButton(block: (RequestChatInlineKeyboardButton) -> T):
|
||||||
|
T? = requestChatInlineKeyboardButtonOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
|
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
|
||||||
dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
@ -3031,6 +3060,33 @@ public inline fun ChatEvent.successfulPaymentEventOrThrow(): SuccessfulPaymentEv
|
|||||||
public inline fun <T> ChatEvent.ifSuccessfulPaymentEvent(block: (SuccessfulPaymentEvent) -> T): T? =
|
public inline fun <T> ChatEvent.ifSuccessfulPaymentEvent(block: (SuccessfulPaymentEvent) -> T): T? =
|
||||||
successfulPaymentEventOrNull() ?.let(block)
|
successfulPaymentEventOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun ChatEvent.chatSharedOrNull(): ChatShared? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
|
|
||||||
|
public inline fun ChatEvent.chatSharedOrThrow(): ChatShared = this as
|
||||||
|
dev.inmo.tgbotapi.types.request.ChatShared
|
||||||
|
|
||||||
|
public inline fun <T> ChatEvent.ifChatShared(block: (ChatShared) -> T): T? = chatSharedOrNull()
|
||||||
|
?.let(block)
|
||||||
|
|
||||||
|
public inline fun ChatEvent.chatSharedRequestOrNull(): ChatSharedRequest? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
|
|
||||||
|
public inline fun ChatEvent.chatSharedRequestOrThrow(): ChatSharedRequest = this as
|
||||||
|
dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||||
|
|
||||||
|
public inline fun <T> ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
||||||
|
chatSharedRequestOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun ChatEvent.userSharedOrNull(): UserShared? = this as?
|
||||||
|
dev.inmo.tgbotapi.types.request.UserShared
|
||||||
|
|
||||||
|
public inline fun ChatEvent.userSharedOrThrow(): UserShared = this as
|
||||||
|
dev.inmo.tgbotapi.types.request.UserShared
|
||||||
|
|
||||||
|
public inline fun <T> ChatEvent.ifUserShared(block: (UserShared) -> T): T? = userSharedOrNull()
|
||||||
|
?.let(block)
|
||||||
|
|
||||||
public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as?
|
public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as?
|
||||||
dev.inmo.tgbotapi.types.message.ForwardInfo.ByAnonymous
|
dev.inmo.tgbotapi.types.message.ForwardInfo.ByAnonymous
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user