1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 12:08:43 +00:00

fix several todo

This commit is contained in:
InsanusMokrassar 2020-03-22 14:07:00 +06:00
parent c85faa73c0
commit 865edf385f
5 changed files with 27 additions and 6 deletions

View File

@ -12,6 +12,9 @@
* `UUID`: `0.0.7` -> `0.1.0` * `UUID`: `0.0.7` -> `0.1.0`
* `TelegramBotAPI`: * `TelegramBotAPI`:
* `Bot` implementations (as and `Bot` itself) now have not nullable `username` * `Bot` implementations (as and `Bot` itself) now have not nullable `username`
* `File#toInputFile` extension now will throw error when file does not exists
* `InlineKeyboardMarkup` will check that `PayInlineKeyboardButton` is the first in case if it is exists in
`keyboard`
## 0.24.0 ## 0.24.0

View File

@ -16,7 +16,6 @@ import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>> private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
= TelegramBotAPIMessageDeserializationStrategyClass() = TelegramBotAPIMessageDeserializationStrategyClass()
// TODO:: Add location tracker for tracking location
@Serializable @Serializable
data class SendLocation( data class SendLocation(
@SerialName(chatIdField) @SerialName(chatIdField)

View File

@ -9,7 +9,6 @@ sealed class InlineKeyboardButton {
abstract val text: String abstract val text: String
} }
//TODO:: add check that this button first in a row (it MUST be first in a row)
@Serializable @Serializable
data class PayInlineKeyboardButton( data class PayInlineKeyboardButton(
override val text: String, override val text: String,

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton
import com.github.insanusmokrassar.TelegramBotAPI.types.inlineKeyboardField import com.github.insanusmokrassar.TelegramBotAPI.types.inlineKeyboardField
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -9,4 +10,19 @@ import kotlinx.serialization.Serializable
data class InlineKeyboardMarkup( data class InlineKeyboardMarkup(
@SerialName(inlineKeyboardField) @SerialName(inlineKeyboardField)
val keyboard: Matrix<InlineKeyboardButton> val keyboard: Matrix<InlineKeyboardButton>
) : KeyboardMarkup ) : KeyboardMarkup {
init {
val isTherePayButton = keyboard.any { it ->
it.any {
it is PayInlineKeyboardButton
}
}
if (isTherePayButton) {
// first button is not PayInlineKeyboardButton
val firstIsPaymentButton = keyboard.first().firstOrNull() is PayInlineKeyboardButton
if (!firstIsPaymentButton) {
error("In case if PayInlineKeyboardButton included in keyboard - it must ")
}
}
}
}

View File

@ -3,6 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
import java.io.File import java.io.File
fun File.toInputFile() = MultipartFile( fun File.toInputFile() = if (exists()) {
MultipartFile(
StorageFile(this) StorageFile(this)
) )
} else {
error("Specified file $absolutePath does not exists")
}