eu.vendeli.tgbot.api.media.Document.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of telegram-bot Show documentation
Show all versions of telegram-bot Show documentation
Telegram Bot API wrapper, with handy Kotlin DSL.
@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.DocumentOptions
import eu.vendeli.tgbot.utils.builders.EntitiesContextBuilder
import eu.vendeli.tgbot.utils.getReturnType
import java.io.File
class SendDocumentAction(private val document: ImplicitFile<*>) :
MediaAction,
ActionState(),
EntitiesContextBuilder,
CaptionFeature,
OptionsFeature,
MarkupFeature {
override val TgAction.method: TgMethod
get() = TgMethod("sendDocument")
override val TgAction.returnType: Class
get() = getReturnType()
override val OptionsFeature.options: DocumentOptions
get() = DocumentOptions()
override val EntitiesContextBuilder.entitiesField: String
get() = "caption_entities"
override val MediaAction.defaultType: MediaContentType
get() = MediaContentType.Text
override val MediaAction.media: ImplicitFile<*>
get() = document
override val MediaAction.dataField: String
get() = "document"
}
fun document(block: () -> String) = SendDocumentAction(ImplicitFile.FromString(block()))
fun document(ba: ByteArray) = SendDocumentAction(ImplicitFile.FromByteArray(ba))
fun document(file: File) = SendDocumentAction(ImplicitFile.FromFile(file))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy