1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

logical fixes

This commit is contained in:
InsanusMokrassar 2020-02-07 10:12:21 +06:00
parent e43ad41d2f
commit 7d0009039f
6 changed files with 12 additions and 51 deletions

View File

@ -39,13 +39,10 @@ suspend fun RequestsExecutor.pinChatMessage(
) = pinChatMessage(chat.id, messageId, disableNotification)
suspend fun RequestsExecutor.pinChatMessage(
chatId: ChatIdentifier,
message: Message,
disableNotification: Boolean = false
) = pinChatMessage(chatId, message.messageId, disableNotification)
suspend fun RequestsExecutor.pinChatMessage(
chat: PublicChat,
message: Message,
disableNotification: Boolean = false
) = pinChatMessage(chat.id, message.messageId, disableNotification)
) = if (message.chat is PublicChat) {
pinChatMessage(message.chat.id, message.messageId, disableNotification)
} else {
error("It is possible to pin messages only in non one-to-one chats")
}

View File

@ -26,12 +26,12 @@ data class SetChatPhoto (
override val paramsJson: JsonObject = toJson(serializer())
}
suspend fun RequestsExecutor.setChatPermissions(
suspend fun RequestsExecutor.setChatPhoto(
chatId: ChatIdentifier,
photo: MultipartFile
) = execute(SetChatPhoto(chatId, photo))
suspend fun RequestsExecutor.setChatPermissions(
suspend fun RequestsExecutor.setChatPhoto(
chat: PublicChat,
photo: MultipartFile
) = setChatPermissions(chat.id, photo)
) = setChatPhoto(chat.id, photo)

View File

@ -49,14 +49,7 @@ suspend fun RequestsExecutor.editMessageReplyMarkup(
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
suspend fun RequestsExecutor.editMessageReplyMarkup(
chatId: ChatId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(chatId, message.messageId, replyMarkup)
suspend fun RequestsExecutor.editMessageReplyMarkup(
chat: Chat,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(chat.id, message.messageId, replyMarkup)
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)

View File

@ -60,21 +60,10 @@ suspend fun RequestsExecutor.editMessageCaption(
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
suspend fun <T> RequestsExecutor.editMessageCaption(
chatId: ChatId,
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
return editMessageCaption(chatId, message.messageId, text, parseMode, replyMarkup)
}
suspend fun <T> RequestsExecutor.editMessageCaption(
chat: Chat,
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
return editMessageCaption(chat.id, message.messageId, text, parseMode, replyMarkup)
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
}

View File

@ -63,15 +63,7 @@ suspend fun RequestsExecutor.editMessageMedia(
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
chatId: ChatId,
message: ContentMessage<out MediaContent>,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chatId, message.messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
chat: Chat,
message: ContentMessage<out MediaContent>,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, message.messageId, media, replyMarkup)
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)

View File

@ -59,19 +59,9 @@ suspend fun RequestsExecutor.editMessageText(
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
suspend fun RequestsExecutor.editMessageText(
chatId: ChatId,
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chatId, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
suspend fun RequestsExecutor.editMessageText(
chat: Chat,
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)