mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
include dice in TelegramBotAPI
This commit is contained in:
parent
84d2c88032
commit
c3fca5c6c4
@ -27,6 +27,11 @@
|
||||
|
||||
### 0.25.2
|
||||
|
||||
* `TelegramBotAPI`:
|
||||
* Request `SendDice` was added (calling [sendDice](https://core.telegram.org/bots/api#senddice))
|
||||
* Class `Dice` was added (type [dice](https://core.telegram.org/bots/api#dice))
|
||||
* Class `DiceContent` was added (for including it in [message](https://core.telegram.org/bots/api#message) object)
|
||||
|
||||
### 0.25.1
|
||||
|
||||
* Update kotlin: `1.3.70` -> `1.3.71`
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableNotification
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMessageId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.DiceContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal val DiceContentMessageResultDeserializer: DeserializationStrategy<ContentMessage<DiceContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendDice(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(disableNotificationField)
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(replyToMessageIdField)
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : ReplyingMarkupSendMessageRequest<ContentMessage<DiceContent>>, ReplyMessageId, DisableNotification {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "sendDice"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<DiceContent>>
|
||||
get() = DiceContentMessageResultDeserializer
|
||||
}
|
@ -19,6 +19,7 @@ typealias InlineMessageIdentifier = String
|
||||
typealias PollIdentifier = String
|
||||
typealias StickerSetName = String
|
||||
typealias FileUniqueId = String
|
||||
typealias DiceResult = Int
|
||||
|
||||
typealias Seconds = Int
|
||||
|
||||
@ -45,6 +46,8 @@ val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||
|
||||
val customTitleLength = 0 .. 16
|
||||
|
||||
val diceResultLimit = 1 .. 6
|
||||
|
||||
const val chatIdField = "chat_id"
|
||||
const val messageIdField = "message_id"
|
||||
const val updateIdField = "update_id"
|
||||
@ -230,6 +233,7 @@ const val optionsField = "options"
|
||||
const val payField = "pay"
|
||||
const val permissionsField = "permissions"
|
||||
const val typeField = "type"
|
||||
const val valueField = "value"
|
||||
|
||||
const val pointField = "point"
|
||||
const val xShiftField = "x_shift"
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Dice(
|
||||
@SerialName(valueField)
|
||||
val value: DiceResult
|
||||
)
|
@ -74,6 +74,7 @@ internal data class RawMessage(
|
||||
private val migrate_from_chat_id: ChatIdentifier? = null,
|
||||
private val pinned_message: RawMessage? = null,
|
||||
private val invoice: Invoice? = null,
|
||||
private val dice: Dice? = null,
|
||||
private val successful_payment: SuccessfulPayment? = null,
|
||||
|
||||
// login property
|
||||
@ -123,6 +124,7 @@ internal data class RawMessage(
|
||||
adaptedCaptionEntities
|
||||
)
|
||||
sticker != null -> StickerContent(sticker)
|
||||
dice != null -> DiceContent(dice)
|
||||
game != null -> GameContent(game.asGame)
|
||||
video_note != null -> VideoNoteContent(video_note)
|
||||
contact != null -> ContactContent(contact)
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class DiceContent(
|
||||
val dice: Dice
|
||||
) : MessageContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<ContentMessage<DiceContent>> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user