mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-15 03:20:18 +00:00
WAT A HUGE REFACTOR
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
@file:OptIn(ExperimentalCoroutinesApi::class)
|
||||
|
||||
package dev.inmo.tgbotapi.bot.exceptions
|
||||
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.types.Response
|
||||
import dev.inmo.tgbotapi.types.RetryAfterError
|
||||
import io.ktor.utils.io.errors.IOException
|
||||
import kotlinx.coroutines.CopyableThrowable
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.io.IOException
|
||||
|
||||
fun newRequestException(
|
||||
response: Response,
|
||||
@@ -42,7 +45,7 @@ class CommonBotException(message: String = "Something went wrong", cause: Throwa
|
||||
override fun createCopy(): BotException = CommonBotException(message!!, cause)
|
||||
}
|
||||
|
||||
sealed class RequestException constructor(
|
||||
sealed class RequestException (
|
||||
val response: Response,
|
||||
val plainAnswer: String,
|
||||
message: String? = null,
|
||||
|
||||
@@ -18,6 +18,7 @@ import kotlinx.serialization.json.Json
|
||||
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
||||
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
||||
*/
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
expect class KtorRequestsExecutor internal constructor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient,
|
||||
@@ -52,5 +53,5 @@ fun KtorRequestsExecutor(
|
||||
jsonFormatter = jsonFormatter,
|
||||
pipelineStepsHolder = pipelineStepsHolder,
|
||||
logger = logger,
|
||||
diff = kotlin.Unit,
|
||||
diff = Unit,
|
||||
)
|
||||
|
||||
@@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.bot.ktor.base
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.kslog.common.v
|
||||
import dev.inmo.kslog.common.w
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.requests.GetUpdatesRequest
|
||||
@@ -73,7 +72,7 @@ abstract class AbstractRequestCallFactory(
|
||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||
logger.v { "Answer as json for $request: $responseObject" }
|
||||
|
||||
return runCatchingSafely {
|
||||
return runCatching {
|
||||
(responseObject.result?.let {
|
||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
||||
} ?: response.let {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.base
|
||||
|
||||
import dev.inmo.kslog.common.*
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
||||
import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
||||
@@ -83,7 +82,7 @@ class DefaultKtorRequestsExecutor internal constructor(
|
||||
|
||||
when (e) {
|
||||
is ClientRequestException -> {
|
||||
val exceptionResult = runCatchingSafely {
|
||||
val exceptionResult = runCatching {
|
||||
val content = e.response.bodyAsText()
|
||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||
newRequestException(
|
||||
|
||||
@@ -24,11 +24,12 @@ object DownloadFileChannelRequestCallFactory : KtorCallFactory {
|
||||
): T? = (request as? DownloadFileStream) ?.let {
|
||||
val fullUrl = urlsKeeper.createFileLinkUrl(it.filePath)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
ByteReadChannelAllocator {
|
||||
val scope = CoroutineScope(currentCoroutineContext() + SupervisorJob())
|
||||
val outChannel = ByteChannel()
|
||||
scope.launch {
|
||||
runCatchingSafely {
|
||||
runCatching {
|
||||
val response = client.get(fullUrl)
|
||||
val channel: ByteReadChannel = response.bodyAsChannel()
|
||||
channel.copyAndClose(outChannel)
|
||||
|
||||
@@ -21,9 +21,7 @@ object DownloadFileRequestCallFactory : KtorCallFactory {
|
||||
): T? = (request as? DownloadFile)?.let {
|
||||
val fullUrl = urlsKeeper.createFileLinkUrl(it.filePath)
|
||||
|
||||
safely {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
client.get(fullUrl).readRawBytes() as T // always ByteArray
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
client.get(fullUrl).readRawBytes() as T // always ByteArray
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.base
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
@@ -107,7 +106,7 @@ class MultipleClientKtorRequestsExecutor(
|
||||
|
||||
private suspend fun <T> withRequestExecutor(block: suspend (DefaultKtorRequestsExecutor) -> T): T {
|
||||
val requestsExecutor = prepareRequestsExecutor()
|
||||
val result = runCatchingSafely {
|
||||
val result = runCatching {
|
||||
block(requestsExecutor)
|
||||
}
|
||||
freeRequestsExecutor(requestsExecutor)
|
||||
|
||||
@@ -35,6 +35,7 @@ open class TelegramBotMiddleware(
|
||||
) : TelegramBotPipelinesHandler {
|
||||
object ResultAbsence : Throwable()
|
||||
override suspend fun <T : Any> onRequestException(request: Request<T>, t: Throwable): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return onRequestException ?.invoke(request, t) as? T
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ open class TelegramBotMiddleware(
|
||||
request: Request<T>,
|
||||
potentialFactory: KtorCallFactory
|
||||
): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return onAfterCallFactoryMakeCall ?.invoke(result, request, potentialFactory) as? T
|
||||
}
|
||||
|
||||
@@ -60,6 +62,7 @@ open class TelegramBotMiddleware(
|
||||
resultCallFactory: KtorCallFactory,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return onRequestResultPresented ?.invoke(result, request, resultCallFactory, callsFactories) as? T
|
||||
}
|
||||
|
||||
@@ -67,6 +70,7 @@ open class TelegramBotMiddleware(
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return onRequestResultAbsent ?.invoke(request, callsFactories) as? T
|
||||
}
|
||||
|
||||
@@ -75,6 +79,7 @@ open class TelegramBotMiddleware(
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): Result<T> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return onRequestReturnResult ?.invoke(result, request, callsFactories) as? Result<T> ?: Result.failure(ResultAbsence)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.exceptions.TooMuchRequestsException
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@@ -11,7 +10,7 @@ object ExceptionsOnlyLimiter : RequestLimiter {
|
||||
override suspend fun <T> limit(block: suspend () -> T): T {
|
||||
var result: Result<T>? = null
|
||||
while (result == null || result.isFailure) {
|
||||
result = runCatchingSafely {
|
||||
result = runCatching {
|
||||
block()
|
||||
}.onFailure {
|
||||
if (it is TooMuchRequestsException) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
@file:Suppress("unused", "RemoveExplicitTypeArguments")
|
||||
|
||||
package dev.inmo.tgbotapi.bot.settings.limiters
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.actor
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.tgbotapi.types.MilliSeconds
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -56,7 +57,7 @@ data class PowLimiter(
|
||||
}
|
||||
delay(delayMillis)
|
||||
return try {
|
||||
safely { block() }
|
||||
block()
|
||||
} finally {
|
||||
eventsChannel.send(CompleteRequest)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetPassportDataErrors(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val user: UserId,
|
||||
@SerialName(errorsField)
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
@file:Suppress("DEPRECATION") // for io.ktor.utils.io.core.ByteReadPacket
|
||||
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
@@ -70,6 +73,7 @@ internal inline val InputFile.fileIdToSend
|
||||
/**
|
||||
* Contains file id or file url
|
||||
*/
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(InputFileSerializer::class)
|
||||
data class FileId(
|
||||
override val fileId: String
|
||||
@@ -92,6 +96,7 @@ object InputFileSerializer : KSerializer<InputFile> {
|
||||
*
|
||||
* @see asMultipartFile
|
||||
*/
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(InputFileSerializer::class)
|
||||
data class MultipartFile (
|
||||
val filename: String,
|
||||
@@ -126,5 +131,5 @@ suspend inline fun ByteReadChannelAllocator.asMultipartFile(
|
||||
) = this.invoke().asMultipartFile(fileName)
|
||||
|
||||
expect fun MPPFile.asMultipartFile(): MultipartFile
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun MPPFile.multipartFile() = asMultipartFile()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.answers
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.types.StartParameter
|
||||
import dev.inmo.tgbotapi.types.startParameterField
|
||||
import dev.inmo.tgbotapi.types.textField
|
||||
import dev.inmo.tgbotapi.types.webAppField
|
||||
@@ -29,6 +27,7 @@ sealed interface InlineQueryResultsButton {
|
||||
val deepLinkParameter: String? = null
|
||||
)
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||
data class WebApp(
|
||||
@SerialName(textField)
|
||||
@@ -37,6 +36,7 @@ sealed interface InlineQueryResultsButton {
|
||||
val webAppInfo: WebAppInfo
|
||||
) : InlineQueryResultsButton
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||
data class Start(
|
||||
@SerialName(textField)
|
||||
@@ -45,6 +45,8 @@ sealed interface InlineQueryResultsButton {
|
||||
val deepLinkParameter: String
|
||||
) : InlineQueryResultsButton
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(InlineQueryResultsButtonSerializer::class)
|
||||
data class Unknown internal constructor (
|
||||
@SerialName(textField)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.types.DoubleSeconds
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.StickerFormat
|
||||
import dev.inmo.tgbotapi.types.animationField
|
||||
import dev.inmo.tgbotapi.types.mainFrameTimestampField
|
||||
import dev.inmo.tgbotapi.types.photoField
|
||||
import dev.inmo.tgbotapi.utils.deserializeWithRaw
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -23,6 +23,7 @@ sealed interface InputProfilePhoto {
|
||||
val mediaPair: Pair<String, MultipartFile>
|
||||
@Serializable
|
||||
data class Static(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(photoField)
|
||||
val photo: MultipartFile
|
||||
) : InputProfilePhoto {
|
||||
@@ -33,6 +34,7 @@ sealed interface InputProfilePhoto {
|
||||
}
|
||||
@Serializable
|
||||
data class Animated(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(animationField)
|
||||
val animation: MultipartFile,
|
||||
@SerialName(mainFrameTimestampField)
|
||||
|
||||
@@ -19,6 +19,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class ReadBusinessMessage(
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(chatIdField)
|
||||
val chatId: ChatId,
|
||||
@SerialName(messageIdField)
|
||||
|
||||
@@ -2,21 +2,10 @@ package dev.inmo.tgbotapi.requests.business_connection
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.chatIdField
|
||||
import dev.inmo.tgbotapi.types.firstNameField
|
||||
import dev.inmo.tgbotapi.types.isPublicField
|
||||
import dev.inmo.tgbotapi.types.lastNameField
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
import dev.inmo.tgbotapi.types.messageIdField
|
||||
import dev.inmo.tgbotapi.types.messageIdsField
|
||||
import dev.inmo.tgbotapi.types.photoField
|
||||
import dev.inmo.tgbotapi.types.usernameField
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -39,6 +28,7 @@ data class SetBusinessAccountProfilePhoto(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(
|
||||
photo.mediaPair
|
||||
)
|
||||
|
||||
@@ -20,6 +20,7 @@ data class TransferGift(
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(ownedGiftIdField)
|
||||
val ownedGiftId: GiftId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(newOwnerChatIdField)
|
||||
val newOwnerChatId: ChatId,
|
||||
@SerialName(starCountField)
|
||||
|
||||
@@ -18,12 +18,13 @@ sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
||||
|
||||
/**
|
||||
* Represent [approve](https://core.telegram.org/bots/api#approvechatjoinrequest) [ChatJoinRequestAnswer]. You may approve
|
||||
* the requests retrieved in with [ChatJoinRequest] (in [dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate])
|
||||
* the requests retrieved in with [dev.inmo.tgbotapi.types.chat.ChatJoinRequest] (in [dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate])
|
||||
*/
|
||||
@Serializable
|
||||
data class ApproveChatJoinRequest(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatJoinRequestAnswer {
|
||||
@@ -35,12 +36,13 @@ data class ApproveChatJoinRequest(
|
||||
|
||||
/**
|
||||
* Represent [decline](https://core.telegram.org/bots/api#declinechatjoinrequest) [ChatJoinRequestAnswer]. You may approve
|
||||
* the requests retrieved in with [ChatJoinRequest] (in [dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate])
|
||||
* the requests retrieved in with [dev.inmo.tgbotapi.types.chat.ChatJoinRequest] (in [dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate])
|
||||
*/
|
||||
@Serializable
|
||||
data class DeclineChatJoinRequest(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatJoinRequestAnswer {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.SubscriptionInfo
|
||||
import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.requests.chat.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.chat.invite_links
|
||||
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.chat.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class BanChatMember(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(untilDateField)
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class BanChatSenderChat(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(senderChatIdField)
|
||||
override val senderChatId: IdChatIdentifier
|
||||
) : ChatSenderRequest {
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlinx.serialization.*
|
||||
data class GetChatMember(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<ChatMember> {
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class PromoteChatMember(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(untilDateField)
|
||||
|
||||
@@ -11,6 +11,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class RestrictChatMember(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(untilDateField)
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class SetChatAdministratorCustomTitle(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(customTitleField)
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class UnbanChatMember(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(onlyIfBannedField)
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
data class UnbanChatSenderChat(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(senderChatIdField)
|
||||
override val senderChatId: IdChatIdentifier
|
||||
) : ChatSenderRequest {
|
||||
|
||||
@@ -56,6 +56,7 @@ fun EditChatMessageCaption(
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class EditChatMessageCaption internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -37,6 +37,7 @@ fun EditInlineMessageCaption(
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class EditInlineMessageCaption internal constructor(
|
||||
@SerialName(inlineMessageIdField)
|
||||
|
||||
@@ -23,6 +23,7 @@ data class EditChatMessageMedia(
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(mediaField)
|
||||
override val media: TelegramFreeMedia,
|
||||
@SerialName(businessConnectionIdField)
|
||||
|
||||
@@ -11,6 +11,7 @@ import kotlinx.serialization.*
|
||||
data class EditInlineMessageMedia(
|
||||
@SerialName(inlineMessageIdField)
|
||||
override val inlineMessageId: InlineMessageId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(mediaField)
|
||||
override val media: TelegramFreeMedia,
|
||||
@SerialName(replyMarkupField)
|
||||
|
||||
@@ -14,6 +14,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class EditUserStarSubscription(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(telegramPaymentChargeIdField)
|
||||
|
||||
@@ -55,6 +55,7 @@ fun EditChatMessageText(
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class EditChatMessageText internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -46,6 +46,7 @@ fun EditInlineMessageText(
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class EditInlineMessageText internal constructor(
|
||||
@SerialName(inlineMessageIdField)
|
||||
|
||||
@@ -7,8 +7,10 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetGameHighScoresByChat (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: IdChatIdentifier,
|
||||
@SerialName(messageIdField)
|
||||
|
||||
@@ -7,6 +7,7 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetGameHighScoresByInlineMessageId (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(inlineMessageIdField)
|
||||
|
||||
@@ -7,10 +7,12 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class SetGameScoreByChatId (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(scoreField)
|
||||
override val score: Long,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: IdChatIdentifier,
|
||||
@SerialName(messageIdField)
|
||||
|
||||
@@ -7,6 +7,7 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class SetGameScoreByInlineMessageId (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(scoreField)
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.files.StickerSerializer
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
internal val getCustomEmojiStickersResultSerializer = ListSerializer(StickerSerializer) as DeserializationStrategy<List<CustomEmojiSticker>>
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -8,6 +8,7 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetFile(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(fileIdField)
|
||||
val fileId: FileId
|
||||
): SimpleRequest<PathedFile> {
|
||||
|
||||
@@ -13,6 +13,7 @@ import kotlinx.serialization.SerializationStrategy
|
||||
data class GetUserChatBoosts(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId
|
||||
) : SimpleRequest<UserChatBoosts>, ChatRequest {
|
||||
|
||||
@@ -6,6 +6,7 @@ import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetUserProfilePhotos(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(offsetField)
|
||||
|
||||
@@ -21,8 +21,10 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class GiftPremiumSubscription internal constructor(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(monthCountField)
|
||||
|
||||
@@ -6,7 +6,6 @@ import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeSourceString
|
||||
@@ -16,8 +15,10 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendGift internal constructor(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId? = null,
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@Serializable
|
||||
data class SavePreparedInlineMessage(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@Serializable(InlineQueryResultSerializer::class)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
|
||||
import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
@@ -10,7 +11,6 @@ import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.WithCustomizableCaptionRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
@@ -143,6 +143,7 @@ fun CopyMessage(
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class CopyMessage internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -78,6 +78,7 @@ fun SendTextMessage(
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendTextMessage internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
@@ -133,6 +135,7 @@ fun SendAnimation(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendAnimationData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -202,6 +205,8 @@ data class SendAnimationData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendAnimationFiles internal constructor(
|
||||
val animation: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.Performerable
|
||||
@@ -126,6 +128,7 @@ fun SendAudio(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendAudioData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -190,6 +193,8 @@ data class SendAudioData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendAudioFiles internal constructor(
|
||||
val audio: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused", "FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
@@ -144,6 +146,7 @@ private val commonResultDeserializer: DeserializationStrategy<ContentMessage<Doc
|
||||
* @see ContentMessage
|
||||
* @see DocumentContent
|
||||
*/
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendDocumentData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -201,6 +204,7 @@ data class SendDocumentData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
data class SendDocumentFiles internal constructor(
|
||||
val document: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName", "DuplicatedCode")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
@@ -72,6 +74,7 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
|
||||
replyParameters = replyParameters
|
||||
)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (if (files.isEmpty()) {
|
||||
data
|
||||
} else {
|
||||
@@ -182,6 +185,7 @@ private object MessagesListSerializer: KSerializer<PossiblySentViaBotCommonMessa
|
||||
|
||||
}
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendMediaGroupData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -203,6 +207,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override val replyParameters: ReplyParameters? = null,
|
||||
) : DataRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>,
|
||||
SendContentMessageRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
|
||||
@Suppress("unused")
|
||||
@SerialName(mediaField)
|
||||
private val convertedMedia: String
|
||||
get() = buildJsonArray {
|
||||
@@ -219,6 +224,8 @@ data class SendMediaGroupData internal constructor(
|
||||
get() = MessagesListSerializer
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendMediaGroupFiles internal constructor(
|
||||
val files: List<MultipartFile>
|
||||
) : Files by (files.map { it.fileId to it }.toMap())
|
||||
) : Files by (files.associateBy { it.fileId })
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMedia
|
||||
@@ -145,12 +147,14 @@ fun SendPaidMedia(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PaidMediaInfoContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendPaidMediaData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(starCountField)
|
||||
val starCount: Int,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(mediaField)
|
||||
val media: List<TelegramPaidMedia>,
|
||||
@SerialName(captionField)
|
||||
@@ -204,6 +208,8 @@ data class SendPaidMediaData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendPaidMediaFiles internal constructor(
|
||||
val photo: MultipartFile
|
||||
) : Files by mapOf(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
@@ -109,6 +111,7 @@ fun SendPhoto(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendPhotoData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -167,6 +170,8 @@ data class SendPhotoData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendPhotoFiles internal constructor(
|
||||
val photo: MultipartFile
|
||||
) : Files by mapOf(
|
||||
|
||||
@@ -13,6 +13,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializ
|
||||
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun SendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: InputFile,
|
||||
@@ -50,6 +51,7 @@ fun SendSticker(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendStickerByFileId internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
|
||||
@@ -148,6 +150,7 @@ fun SendVideo(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendVideoData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -225,6 +228,8 @@ data class SendVideoData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendVideoFiles internal constructor(
|
||||
val video: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -13,6 +13,7 @@ import dev.inmo.tgbotapi.types.message.content.VideoNoteContent
|
||||
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun SendVideoNote(
|
||||
chatId: ChatIdentifier,
|
||||
videoNote: InputFile,
|
||||
@@ -60,6 +61,7 @@ fun SendVideoNote(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendVideoNoteData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -105,6 +107,8 @@ data class SendVideoNoteData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendVideoNoteFiles internal constructor(
|
||||
val videoNote: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -111,6 +111,7 @@ fun SendVoice(
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SendVoiceData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@@ -166,6 +167,8 @@ data class SendVoiceData internal constructor(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsistentCopyVisibility
|
||||
data class SendVoiceFiles internal constructor(
|
||||
val voice: MultipartFile? = null,
|
||||
val thumbnail: MultipartFile? = null
|
||||
|
||||
@@ -8,6 +8,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class RefundStarPayment(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(telegramPaymentChargeIdField)
|
||||
|
||||
@@ -5,7 +5,6 @@ import dev.inmo.tgbotapi.abstracts.types.*
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyWithEffectRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
@@ -24,6 +23,7 @@ private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<Inv
|
||||
*/
|
||||
@Serializable
|
||||
data class SendInvoice(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: IdChatIdentifier,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetUserEmojiStatus(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun AddStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: StickerSetName,
|
||||
@@ -31,8 +32,10 @@ fun AddStickerToSet(
|
||||
inputSticker = inputSticker
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class AddStickerToSetData internal constructor(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
|
||||
@@ -5,11 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* Will create one of [CreateNewStickerSet] types based on the first element of [stickers]
|
||||
@@ -84,6 +80,7 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||
|
||||
@Serializable
|
||||
data class Regular(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
@@ -99,6 +96,7 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||
}
|
||||
@Serializable
|
||||
data class Mask(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
@@ -114,6 +112,7 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||
}
|
||||
@Serializable
|
||||
data class CustomEmoji(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
@@ -130,8 +129,10 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||
get() = StickerType.CustomEmoji
|
||||
}
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SurrogateCreateNewSticker internal constructor(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
import kotlinx.serialization.*
|
||||
@@ -9,6 +8,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class DeleteStickerFromSet(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId
|
||||
) : StickerAction<Boolean> {
|
||||
|
||||
@@ -117,6 +117,7 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
||||
}
|
||||
},
|
||||
) {
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SurrogateInputSticker internal constructor(
|
||||
@SerialName(stickerField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -6,7 +8,6 @@ import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.files.File
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun ReplaceStickerInSet(
|
||||
@@ -30,6 +31,7 @@ fun ReplaceStickerInSet(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun ReplaceStickerInSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
@@ -42,12 +44,15 @@ fun ReplaceStickerInSet(
|
||||
newSticker = newSticker
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class ReplaceStickerInSetData internal constructor(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: StickerSetName,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(oldStickerField)
|
||||
val oldSticker: FileId,
|
||||
@SerialName(stickerField)
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.OwnerStickerSetAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Suppress("unused")
|
||||
@Serializable
|
||||
data class SetStickerEmojiList (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(emojiListField)
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.OwnerStickerSetAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Suppress("unused")
|
||||
@Serializable
|
||||
data class SetStickerKeywords (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(keywordsField)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.OwnerStickerSetAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
@@ -12,6 +9,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetStickerMaskPosition (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(maskPositionField)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.types.positionField
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
@@ -10,6 +9,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetStickerPositionInSet(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(positionField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("FunctionName")
|
||||
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
@@ -18,6 +20,7 @@ fun SetStickerSetThumbnail(
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun SetStickerSetThumbnail(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
@@ -32,12 +35,14 @@ fun SetStickerSetThumbnail(
|
||||
|
||||
@Serializable
|
||||
data class SetStickerSetThumbnail (
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: StickerSetName,
|
||||
@SerialName(formatField)
|
||||
val format: StickerFormat,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(thumbnailField)
|
||||
val thumbnail: FileId? = null
|
||||
) : OwnerStickerSetAction {
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable
|
||||
data class UploadStickerFile(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@Transient
|
||||
@@ -17,10 +18,7 @@ data class UploadStickerFile(
|
||||
@SerialName(stickerFormatField)
|
||||
val stickerFormat: StickerFormat
|
||||
): MultipartRequest<File> {
|
||||
init {
|
||||
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
||||
}
|
||||
|
||||
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
||||
override fun method(): String = "uploadStickerFile"
|
||||
@Transient
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||
|
||||
@@ -3,10 +3,7 @@ package dev.inmo.tgbotapi.requests.stories
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stories.PostStory
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.StoryId
|
||||
import dev.inmo.tgbotapi.types.activePeriodField
|
||||
import dev.inmo.tgbotapi.types.areasField
|
||||
import dev.inmo.tgbotapi.types.businessConnectionIdField
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
@@ -31,6 +28,7 @@ import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class EditStory private constructor(
|
||||
@SerialName(businessConnectionIdField)
|
||||
|
||||
@@ -28,6 +28,7 @@ import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class PostStory private constructor(
|
||||
@SerialName(businessConnectionIdField)
|
||||
@@ -120,6 +121,7 @@ data class PostStory private constructor(
|
||||
|
||||
override fun method(): String = "postStory"
|
||||
|
||||
@Suppress("unused")
|
||||
companion object {
|
||||
const val ACTIVE_PERIOD_6_HOURS: Seconds = 6 * 3600
|
||||
const val ACTIVE_PERIOD_12_HOURS: Seconds = 12 * 3600
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.verifications
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
@@ -9,9 +8,9 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
|
||||
@Serializable
|
||||
data class RemoveUserVerification(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
): SimpleRequest<Boolean> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.requests.verifications
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
@@ -12,6 +11,7 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class VerifyUser(
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId,
|
||||
@SerialName(customDescriptionField)
|
||||
|
||||
@@ -124,6 +124,7 @@ fun SetWebhook(
|
||||
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the [url],
|
||||
* e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
|
||||
*/
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class SetWebhook internal constructor(
|
||||
@SerialName(urlField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.colors.common.HEXAColor
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.common.Progress
|
||||
@@ -6,6 +8,7 @@ import dev.inmo.tgbotapi.utils.IntProgress100Serializer
|
||||
import dev.inmo.tgbotapi.utils.decodeDataAndJson
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
@@ -26,9 +28,10 @@ sealed interface ChatIdentifier
|
||||
/**
|
||||
* Also used as User Identifier
|
||||
*/
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
sealed interface IdChatIdentifier : ChatIdentifier {
|
||||
abstract val chatId: RawChatId
|
||||
val chatId: RawChatId
|
||||
val threadId: MessageThreadId?
|
||||
get() = null
|
||||
val businessConnectionId: BusinessConnectionId?
|
||||
@@ -45,10 +48,12 @@ sealed interface IdChatIdentifier : ChatIdentifier {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
@JvmInline
|
||||
value class ChatId(override val chatId: RawChatId) : IdChatIdentifier
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
@JvmInline
|
||||
value class ChatIdWithThreadId(val chatIdWithThreadId: Pair<RawChatId, MessageThreadId>) : IdChatIdentifier {
|
||||
@@ -59,6 +64,7 @@ value class ChatIdWithThreadId(val chatIdWithThreadId: Pair<RawChatId, MessageTh
|
||||
|
||||
constructor(chatId: RawChatId, threadId: MessageThreadId): this(chatId to threadId)
|
||||
}
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
@JvmInline
|
||||
value class BusinessChatId(val chatIdWithBusinessConnectionId: Pair<RawChatId, BusinessConnectionId>) : IdChatIdentifier {
|
||||
@@ -116,6 +122,7 @@ fun Byte.toChatId(): IdChatIdentifier = RawChatId(toLong()).toChatId()
|
||||
* @property full The full username string, guaranteed to start with "@".
|
||||
* @throws IllegalArgumentException if the provided [full] value doesn't start with "@" during initialization.
|
||||
*/
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE", "RemoveRedundantQualifierName")
|
||||
@Serializable(ChatIdentifierSerializer::class)
|
||||
@JvmInline
|
||||
value class Username (
|
||||
@@ -193,6 +200,7 @@ object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@RiskFeature
|
||||
object FullChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
private val internalSerializer = JsonPrimitive.serializer()
|
||||
@@ -216,7 +224,7 @@ object FullChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
val (chatId, _, businessConnectionId) = splitted
|
||||
BusinessChatId(
|
||||
chatId.toLongOrNull() ?.let(::RawChatId) ?: return@let null,
|
||||
businessConnectionId.let(::BusinessConnectionId) ?: return@let null
|
||||
businessConnectionId.let(::BusinessConnectionId)
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
|
||||
@@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.types
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.abstracts.WithUser
|
||||
import dev.inmo.tgbotapi.abstracts.types.SubscriptionInfo
|
||||
import dev.inmo.tgbotapi.abstracts.types.SubscriptionPeriodInfo
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.TimeSpanAsSecondsSerializer
|
||||
@@ -67,6 +66,7 @@ sealed interface ChatInviteLink : WithUser {
|
||||
/**
|
||||
* Base interface for all [ChatInviteLink]s which are NOT [PrimaryInviteLink]
|
||||
*/
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatInviteLinkSerializer::class)
|
||||
sealed interface SecondaryChatInviteLink : ChatInviteLink, SubscriptionInfo {
|
||||
override val isPrimary: Boolean
|
||||
@@ -96,7 +96,7 @@ data class PrimaryInviteLink(
|
||||
/**
|
||||
* Represent [SecondaryChatInviteLink] which will require an aprovement from one of the administrators
|
||||
*
|
||||
* @see ChatJoinRequest
|
||||
* @see dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
* @see dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
||||
*/
|
||||
@Serializable
|
||||
|
||||
@@ -12,6 +12,7 @@ data class Contact(
|
||||
override val firstName: String,
|
||||
@SerialName(lastNameField)
|
||||
override val lastName: String? = null,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId? = null,
|
||||
@SerialName(vcardField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -41,10 +43,12 @@ fun InlineQueryResultAudioCachedImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultAudioCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(audioFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(captionField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -49,6 +51,7 @@ fun InlineQueryResultAudioImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultAudioImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -47,10 +47,12 @@ fun InlineQueryResultDocumentCachedImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultDocumentCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(documentFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -59,6 +61,7 @@ fun InlineQueryResultDocumentImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultDocumentImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -57,10 +59,12 @@ fun InlineQueryResultGifCachedImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultGifCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(gifFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -136,6 +138,7 @@ fun InlineQueryResultGifImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultGifImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -57,10 +59,12 @@ fun InlineQueryResultMpeg4GifCachedImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultMpeg4GifCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(mpeg4GifFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -77,6 +79,7 @@ fun InlineQueryResultMpeg4GifImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultMpeg4GifImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -61,10 +63,12 @@ fun InlineQueryResultPhotoCachedImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultPhotoCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(photoFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -72,6 +74,7 @@ fun InlineQueryResultPhotoImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultPhotoImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.serialization.Serializable
|
||||
data class InlineQueryResultStickerCached(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(stickerFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(replyMarkupField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -61,10 +63,12 @@ fun InlineQueryResultVideoCachedImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultVideoCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(videoFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -81,6 +83,7 @@ fun InlineQueryResultVideoImpl(
|
||||
inputMessageContent = inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultVideoImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
@@ -44,10 +46,12 @@ fun InlineQueryResultVoiceCachedImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultVoiceCachedImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: InlineQueryId,
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@SerialName(voiceFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@@ -56,6 +58,7 @@ fun InlineQueryResultVoiceImpl(
|
||||
inputMessageContent
|
||||
)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InlineQueryResultVoiceImpl internal constructor(
|
||||
@SerialName(idField)
|
||||
|
||||
@@ -3,12 +3,14 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.*
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
@RiskFeature
|
||||
object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
@OptIn(InternalSerializationApi::class)
|
||||
@@ -39,6 +41,6 @@ object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): InlineQueryResult {
|
||||
throw TODO()
|
||||
throw NotImplementedError("Object can't be deserialized")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
@@ -30,6 +32,7 @@ fun InputTextMessageContent(
|
||||
linkPreviewOptions: LinkPreviewOptions? = null
|
||||
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), linkPreviewOptions)
|
||||
|
||||
@ConsistentCopyVisibility
|
||||
@Serializable
|
||||
data class InputTextMessageContent internal constructor(
|
||||
@SerialName(messageTextField)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package dev.inmo.tgbotapi.types.InlineQueries
|
||||
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.*
|
||||
@@ -19,7 +22,6 @@ object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||
is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value)
|
||||
is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value)
|
||||
is InputInvoiceMessageContent -> InputInvoiceMessageContent.serializer().serialize(encoder, value)
|
||||
else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user