mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
CustomBotAction
This commit is contained in:
parent
8d8bcfba01
commit
76985501f5
@ -2,6 +2,9 @@
|
||||
|
||||
## 0.35.9
|
||||
|
||||
* `Core`:
|
||||
* New `BotAction` implementation - `CustomBotAction`
|
||||
|
||||
## 0.35.8
|
||||
|
||||
* `Common`:
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.actions
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
@ -34,7 +35,7 @@ object BotActionSerializer: KSerializer<BotAction> {
|
||||
FindLocationAction.actionName -> FindLocationAction
|
||||
RecordVideoNoteAction.actionName -> RecordVideoNoteAction
|
||||
UploadVideoNoteAction.actionName -> UploadVideoNoteAction
|
||||
else -> throw IllegalStateException("Unknown action type: $actionName")
|
||||
else -> CustomBotAction(actionName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,3 +149,7 @@ object UploadVideoNoteAction : BotAction {
|
||||
inline val uploadVideoNote
|
||||
get() = 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
|
||||
|
Loading…
Reference in New Issue
Block a user