All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.vendeli.tgbot.api.media.Animation.kt Maven / Gradle / Ivy

There is a newer version: 6.6.0
Show newest version
@file:Suppress("MatchingDeclarationName")

package eu.vendeli.tgbot.api.media

import eu.vendeli.tgbot.interfaces.ActionState
import eu.vendeli.tgbot.interfaces.MediaAction
import eu.vendeli.tgbot.interfaces.TgAction
import eu.vendeli.tgbot.interfaces.features.CaptionFeature
import eu.vendeli.tgbot.interfaces.features.MarkupFeature
import eu.vendeli.tgbot.interfaces.features.OptionsFeature
import eu.vendeli.tgbot.types.Message
import eu.vendeli.tgbot.types.internal.ImplicitFile
import eu.vendeli.tgbot.types.internal.MediaContentType
import eu.vendeli.tgbot.types.internal.TgMethod
import eu.vendeli.tgbot.types.internal.options.AnimationOptions
import eu.vendeli.tgbot.utils.builders.EntitiesContextBuilder
import eu.vendeli.tgbot.utils.getReturnType
import java.io.File

class SendAnimationAction(private val animation: ImplicitFile<*>) :
    MediaAction,
    ActionState(),
    OptionsFeature,
    MarkupFeature,
    EntitiesContextBuilder,
    CaptionFeature {
    override val TgAction.method: TgMethod
        get() = TgMethod("sendAnimation")
    override val TgAction.returnType: Class
        get() = getReturnType()
    override val OptionsFeature.options: AnimationOptions
        get() = AnimationOptions()
    override val EntitiesContextBuilder.entitiesField: String
        get() = "caption_entities"

    override val MediaAction.defaultType: MediaContentType
        get() = MediaContentType.ImageGif
    override val MediaAction.media: ImplicitFile<*>
        get() = animation
    override val MediaAction.dataField: String
        get() = "animation"
}

fun animation(block: () -> String) = SendAnimationAction(ImplicitFile.FromString(block()))

fun animation(ba: ByteArray) = SendAnimationAction(ImplicitFile.FromByteArray(ba))

fun animation(file: File) = SendAnimationAction(ImplicitFile.FromFile(file))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy