mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 08:37:12 +00:00
add support of saving prepared messages
This commit is contained in:
parent
c7d08df3bf
commit
5559923339
@ -0,0 +1,45 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.inline
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.answers.InlineQueryAnswersResultsSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.inline.SavePreparedInlineMessage
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.prepared.PreparedInlineMessage
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.savePreparedInlineMessage(
|
||||||
|
userId: UserId,
|
||||||
|
result: InlineQueryResult,
|
||||||
|
allowSendToUsers: Boolean = false,
|
||||||
|
allowSendToBots: Boolean = false,
|
||||||
|
allowSendToGroups: Boolean = false,
|
||||||
|
allowSendToChannels: Boolean = false,
|
||||||
|
): PreparedInlineMessage = execute(
|
||||||
|
SavePreparedInlineMessage(
|
||||||
|
userId = userId,
|
||||||
|
result = result,
|
||||||
|
allowSendToUsers = allowSendToUsers,
|
||||||
|
allowSendToBots = allowSendToBots,
|
||||||
|
allowSendToGroups = allowSendToGroups,
|
||||||
|
allowSendToChannels = allowSendToChannels
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
public suspend fun TelegramBot.savePreparedInlineMessage(
|
||||||
|
user: User,
|
||||||
|
result: InlineQueryResult,
|
||||||
|
allowSendToUsers: Boolean = false,
|
||||||
|
allowSendToBots: Boolean = false,
|
||||||
|
allowSendToGroups: Boolean = false,
|
||||||
|
allowSendToChannels: Boolean = false,
|
||||||
|
): PreparedInlineMessage = savePreparedInlineMessage(
|
||||||
|
userId = user.id,
|
||||||
|
result = result,
|
||||||
|
allowSendToUsers = allowSendToUsers,
|
||||||
|
allowSendToBots = allowSendToBots,
|
||||||
|
allowSendToGroups = allowSendToGroups,
|
||||||
|
allowSendToChannels = allowSendToChannels
|
||||||
|
)
|
@ -0,0 +1,35 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.inline
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.answers.InlineQueryAnswersResultsSerializer
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.prepared.PreparedInlineMessage
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SavePreparedInlineMessage(
|
||||||
|
@SerialName(idField)
|
||||||
|
val userId: UserId,
|
||||||
|
@Serializable(InlineQueryAnswersResultsSerializer::class)
|
||||||
|
@SerialName(resultField)
|
||||||
|
val result: InlineQueryResult,
|
||||||
|
@SerialName(allowUserChatsField)
|
||||||
|
val allowSendToUsers: Boolean = false,
|
||||||
|
@SerialName(allowBotChatsField)
|
||||||
|
val allowSendToBots: Boolean = false,
|
||||||
|
@SerialName(allowGroupChatsField)
|
||||||
|
val allowSendToGroups: Boolean = false,
|
||||||
|
@SerialName(allowChannelChatsField)
|
||||||
|
val allowSendToChannels: Boolean = false,
|
||||||
|
) : SimpleRequest<PreparedInlineMessage> {
|
||||||
|
override fun method(): String = "savePreparedInlineMessage"
|
||||||
|
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
override val resultDeserializer: DeserializationStrategy<PreparedInlineMessage>
|
||||||
|
get() = PreparedInlineMessage.serializer()
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.InlineQueries.prepared
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.PreparedMessageId
|
||||||
|
import dev.inmo.tgbotapi.types.TelegramDate
|
||||||
|
import dev.inmo.tgbotapi.types.expirationDateField
|
||||||
|
import dev.inmo.tgbotapi.types.idField
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PreparedInlineMessage(
|
||||||
|
@SerialName(idField)
|
||||||
|
val id: PreparedMessageId,
|
||||||
|
@SerialName(expirationDateField)
|
||||||
|
val expirationDate: TelegramDate,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user