1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

refactor type inside edit messages extensions

This commit is contained in:
InsanusMokrassar 2020-02-06 20:36:29 +06:00
parent 6cf836708d
commit 5e5dc105a5
3 changed files with 21 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
@ -9,9 +10,12 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonMessageImpl
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
import kotlinx.serialization.*
const val editMessageCaptionMethod = "editMessageCaption"
@ -55,18 +59,22 @@ suspend fun RequestsExecutor.editMessageCaption(
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
suspend fun RequestsExecutor.editMessageCaption(
suspend fun <T> RequestsExecutor.editMessageCaption(
chatId: ChatId,
message: Message,
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chatId, message.messageId, text, parseMode, replyMarkup)
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
return editMessageCaption(chatId, message.messageId, text, parseMode, replyMarkup)
}
suspend fun RequestsExecutor.editMessageCaption(
suspend fun <T> RequestsExecutor.editMessageCaption(
chat: Chat,
message: Message,
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chat.id, message.messageId, text, parseMode, replyMarkup)
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
return editMessageCaption(chat.id, message.messageId, text, parseMode, replyMarkup)
}

View File

@ -9,9 +9,12 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonMessageImpl
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
import kotlinx.serialization.*
const val editMessageMediaMethod = "editMessageMedia"
@ -61,14 +64,14 @@ suspend fun RequestsExecutor.editMessageMedia(
suspend fun RequestsExecutor.editMessageMedia(
chatId: ChatId,
message: Message,
message: ContentMessage<out MediaContent>,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chatId, message.messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
chat: Chat,
message: Message,
message: ContentMessage<out MediaContent>,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, message.messageId, media, replyMarkup)

View File

@ -60,7 +60,7 @@ suspend fun RequestsExecutor.editMessageText(
suspend fun RequestsExecutor.editMessageText(
chatId: ChatId,
message: Message,
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
@ -69,7 +69,7 @@ suspend fun RequestsExecutor.editMessageText(
suspend fun RequestsExecutor.editMessageText(
chat: Chat,
message: Message,
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,