PossiblyReplyMessage casts
Add asPossiblyReplyMessage / requirePossiblyReplyMessage / whenPossiblyReplyMessage
MODIFY
CHANGELOG.md
CHANGELOG.md
* Two new dsl:
* `inlineKeyboard` for creating `InlineKeyboardMarkup`
* `replyKeyboard` for creating `ReplyKeyboardMarkup`
+ * Cast helpers for `Message`:
+ * `asPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage`, returns `null` if the message is not of that type
+ * `requirePossiblyReplyMessage`: casts a `Message` to `PossiblyReplyMessage`, fails if the message is not of that type
+ * `whenPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage` and runs the given block of code with it, if the cast is successful
* `Behaviour Builder`:
* New expecters and waiters:
* `waitShippingQueries`/`onShippingQuery`

MODIFY
tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt
tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt
@@ -1132,6 +1132,15 @@ inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as?
@PreviewFeature
inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage
+@PreviewFeature
+inline fun <T> Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = asPossiblyReplyMessage() ?.let(block)
+
+@PreviewFeature
+inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage
+
+@PreviewFeature
+inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage
+
@PreviewFeature
inline fun <T> Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = asPossiblyForwardedMessage() ?.let(block)

PossiblyReplyMessage casts

Add asPossiblyReplyMessage / requirePossiblyReplyMessage / whenPossiblyReplyMessage