1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-26 19:48:09 +00:00
tgbotapi/TelegramBotAPI-extensions-api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt

91 lines
3.4 KiB
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.api.send.media
2020-02-15 09:33:04 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.bot.TelegramBot
2020-03-22 10:04:11 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
2020-02-15 09:33:04 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
2020-10-04 10:47:30 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
2020-02-15 09:33:04 +00:00
suspend fun TelegramBot.sendPhoto(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier,
fileId: InputFile,
2020-02-15 09:33:04 +00:00
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendPhoto(
chatId,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
2020-10-04 10:47:30 +00:00
suspend fun TelegramBot.sendPhoto(
chat: Chat,
fileId: InputFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
suspend fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
suspend fun TelegramBot.sendPhoto(
chat: Chat,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photo, caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto(
to: Message,
fileId: InputFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, caption, parseMode, disableNotification, to.messageId, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto(
to: Message,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, caption, parseMode, disableNotification, to.messageId, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyMarkup: KeyboardMarkup? = null
) = replyWithPhoto(to, photo, caption, parseMode, disableNotification, replyMarkup)