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:
parent
c85faa73c0
commit
865edf385f
@ -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
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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,
|
||||||
|
@ -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 ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user