mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fixes
This commit is contained in:
parent
fc59ab0cdd
commit
a85e7d7387
@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.bot.Ktor.base
|
package dev.inmo.tgbotapi.bot.Ktor.base
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.safely
|
import dev.inmo.micro_utils.coroutines.safely
|
||||||
|
import dev.inmo.micro_utils.coroutines.safelyWithResult
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||||
@ -57,7 +58,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
val content = response.receive<String>()
|
val content = response.receive<String>()
|
||||||
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
|
||||||
|
|
||||||
return safely {
|
return safelyWithResult {
|
||||||
(responseObject.result?.let {
|
(responseObject.result?.let {
|
||||||
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
jsonFormatter.decodeFromJsonElement(request.resultDeserializer, it)
|
||||||
} ?: response.let {
|
} ?: response.let {
|
||||||
@ -67,7 +68,7 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
"Can't get result object from $content"
|
"Can't get result object from $content"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}.getOrThrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,4 +77,4 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
|
|||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
request: Request<T>
|
request: Request<T>
|
||||||
): Any?
|
): Any?
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.invite_links
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.SerializationStrategy
|
|
||||||
import kotlinx.serialization.builtins.serializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
||||||
@ -17,7 +15,9 @@ sealed interface ChatJoinRequestAnswer : SimpleRequest<Boolean> {
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ApproveChatJoinRequest(
|
data class ApproveChatJoinRequest(
|
||||||
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(userIdField)
|
||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatJoinRequestAnswer {
|
) : ChatJoinRequestAnswer {
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
@ -28,7 +28,9 @@ data class ApproveChatJoinRequest(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeclineChatJoinRequest(
|
data class DeclineChatJoinRequest(
|
||||||
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(userIdField)
|
||||||
override val userId: UserId
|
override val userId: UserId
|
||||||
) : ChatJoinRequestAnswer {
|
) : ChatJoinRequestAnswer {
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
@ -9,12 +9,12 @@ import kotlinx.serialization.Serializable
|
|||||||
data class ChatJoinRequest(
|
data class ChatJoinRequest(
|
||||||
@SerialName(chatField)
|
@SerialName(chatField)
|
||||||
val chat: PublicChat,
|
val chat: PublicChat,
|
||||||
@SerialName(userField)
|
@SerialName(fromField)
|
||||||
override val from: User,
|
override val from: User,
|
||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
val date: TelegramDate,
|
val date: TelegramDate,
|
||||||
@SerialName(bioField)
|
|
||||||
val bio: String,
|
|
||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
val inviteLink: ChatInviteLink
|
val inviteLink: ChatInviteLink,
|
||||||
|
@SerialName(bioField)
|
||||||
|
val bio: String? = null
|
||||||
) : FromUser
|
) : FromUser
|
||||||
|
Loading…
Reference in New Issue
Block a user