a little updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.postssystem.targets.telegram.loader.server
|
||||
|
||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
|
@@ -6,14 +6,10 @@ import dev.inmo.postssystem.features.content.text.common.TextContent
|
||||
import dev.inmo.postssystem.features.publication.server.PublicationPost
|
||||
import dev.inmo.postssystem.features.publication.server.PublicationTarget
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.executeUnsafe
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.requests.send.media.*
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.readBytes
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
class PublicationTargetTelegram(
|
||||
@@ -24,7 +20,7 @@ class PublicationTargetTelegram(
|
||||
post.content.mapNotNull {
|
||||
when (val content = it.content) {
|
||||
is BinaryContent -> {
|
||||
val storageFile by lazy {
|
||||
val multipartFile by lazy {
|
||||
MultipartFile(content.filename.name) {
|
||||
content.inputProvider()
|
||||
}
|
||||
@@ -32,17 +28,17 @@ class PublicationTargetTelegram(
|
||||
when (content.mimeType) {
|
||||
is KnownMimeTypes.Image.Jpeg,
|
||||
is KnownMimeTypes.Image.Png -> {
|
||||
SendPhoto(targetChatId, storageFile)
|
||||
SendPhoto(targetChatId, multipartFile)
|
||||
}
|
||||
is KnownMimeTypes.Video.Mp4 -> {
|
||||
SendVideo(targetChatId, storageFile)
|
||||
SendVideo(targetChatId, multipartFile)
|
||||
}
|
||||
is KnownMimeTypes.Audio.Mpeg -> {
|
||||
SendAudio(targetChatId, storageFile)
|
||||
SendAudio(targetChatId, multipartFile)
|
||||
}
|
||||
else -> SendDocument(
|
||||
targetChatId,
|
||||
storageFile
|
||||
multipartFile
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user