1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +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`
* `TelegramBotAPI`:
* `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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
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 kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -9,4 +10,19 @@ import kotlinx.serialization.Serializable
data class InlineKeyboardMarkup(
@SerialName(inlineKeyboardField)
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 java.io.File
fun File.toInputFile() = MultipartFile(
StorageFile(this)
)
fun File.toInputFile() = if (exists()) {
MultipartFile(
StorageFile(this)
)
} else {
error("Specified file $absolutePath does not exists")
}