1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

CustomBotAction

This commit is contained in:
InsanusMokrassar 2021-09-12 15:32:36 +06:00
parent 8d8bcfba01
commit 76985501f5
2 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,9 @@
## 0.35.9 ## 0.35.9
* `Core`:
* New `BotAction` implementation - `CustomBotAction`
## 0.35.8 ## 0.35.8
* `Common`: * `Common`:

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.actions package dev.inmo.tgbotapi.types.actions
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
@ -34,7 +35,7 @@ object BotActionSerializer: KSerializer<BotAction> {
FindLocationAction.actionName -> FindLocationAction FindLocationAction.actionName -> FindLocationAction
RecordVideoNoteAction.actionName -> RecordVideoNoteAction RecordVideoNoteAction.actionName -> RecordVideoNoteAction
UploadVideoNoteAction.actionName -> UploadVideoNoteAction UploadVideoNoteAction.actionName -> UploadVideoNoteAction
else -> throw IllegalStateException("Unknown action type: $actionName") else -> CustomBotAction(actionName)
} }
} }
} }
@ -148,3 +149,7 @@ object UploadVideoNoteAction : BotAction {
inline val uploadVideoNote inline val uploadVideoNote
get() = UploadVideoNoteAction get() = UploadVideoNoteAction
inline fun BotAction.asUploadVideoNote() = this as? UploadVideoNoteAction inline fun BotAction.asUploadVideoNote() = this as? UploadVideoNoteAction
@Serializable(BotActionSerializer::class)
@RiskFeature("Usage of this action may lead to errors")
class CustomBotAction(override val actionName: String) : BotAction