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

complete update methods

This commit is contained in:
InsanusMokrassar 2020-02-06 14:05:36 +06:00
parent 2cfabb1c2a
commit 5e6ff01940
12 changed files with 241 additions and 8 deletions

View File

@ -1,8 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer
@ -20,3 +23,25 @@ data class DeleteMessage(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageIdentifier
) = execute(
DeleteMessage(chatId, messageId)
)
suspend fun RequestsExecutor.deleteMessage(
chat: Chat,
messageId: MessageIdentifier
) = deleteMessage(chat.id, messageId)
suspend fun RequestsExecutor.deleteMessage(
chatId: ChatId,
message: Message
) = deleteMessage(chatId, message.messageId)
suspend fun RequestsExecutor.deleteMessage(
chat: Chat,
message: Message
) = deleteMessage(chat.id, message.messageId)

View File

@ -2,9 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
import kotlinx.serialization.*
@ -23,3 +27,29 @@ data class StopPoll(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.stopPoll(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopPoll(chatId, messageId, replyMarkup)
)
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, messageId, replyMarkup)
suspend fun RequestsExecutor.stopPoll(
chatId: ChatId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup)
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer
@ -28,5 +27,5 @@ suspend fun RequestsExecutor.deleteChatStickerSet(
) = execute(DeleteChatStickerSet(chatId))
suspend fun RequestsExecutor.deleteChatStickerSet(
chat: PublicChat
chat: SupergroupChat
) = deleteChatStickerSet(chat.id)

View File

@ -4,8 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequ
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer
@ -29,6 +28,6 @@ suspend fun RequestsExecutor.setChatStickerSet(
) = execute(SetChatStickerSet(chatId, stickerSetName))
suspend fun RequestsExecutor.setChatStickerSet(
chat: PublicChat,
chat: SupergroupChat,
stickerSetName: StickerSetName
) = setChatStickerSet(chat.id, stickerSetName)

View File

@ -1,10 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditChatMessageMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
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.abstracts.MessageContent
import kotlinx.serialization.*
@ -29,3 +33,30 @@ data class EditChatMessageReplyMarkup(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageReplyMarkup(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
)
suspend fun RequestsExecutor.editMessageReplyMarkup(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = 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)

View File

@ -1,8 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditInlineMessageMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.*
@ -17,3 +20,8 @@ data class EditInlineMessageReplyMarkup(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageReplyMarkup(
inlineMessageId: InlineMessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))

View File

@ -1,12 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditChatMessageText
import com.github.insanusmokrassar.TelegramBotAPI.types.*
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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import kotlinx.serialization.*
@ -32,3 +36,37 @@ data class EditChatMessageCaption(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageCaption(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
)
suspend fun RequestsExecutor.editMessageCaption(
chat: Chat,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
suspend fun RequestsExecutor.editMessageCaption(
chatId: ChatId,
message: Message,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chatId, message.messageId, text, parseMode, replyMarkup)
suspend fun RequestsExecutor.editMessageCaption(
chat: Chat,
message: Message,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageCaption(chat.id, message.messageId, text, parseMode, replyMarkup)

View File

@ -1,6 +1,8 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditInlineMessageText
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
@ -22,3 +24,10 @@ data class EditInlineMessageCaption(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageCaption(
inlineMessageId: InlineMessageIdentifier,
text: String,
parseMode: ParseMode? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))

View File

@ -1,11 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditChatMessageCaption
import com.github.insanusmokrassar.TelegramBotAPI.types.*
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.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
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.abstracts.MediaContent
import kotlinx.serialization.*
@ -38,3 +42,33 @@ data class EditChatMessageMedia(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageMedia(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
)
suspend fun RequestsExecutor.editMessageMedia(
chat: Chat,
messageId: MessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
chatId: ChatId,
message: Message,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chatId, message.messageId, media, replyMarkup)
suspend fun RequestsExecutor.editMessageMedia(
chat: Chat,
message: Message,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, message.messageId, media, replyMarkup)

View File

@ -1,9 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
import com.github.insanusmokrassar.TelegramBotAPI.types.*
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 kotlinx.serialization.*
@ -27,3 +30,9 @@ data class EditInlineMessageMedia(
override fun method(): String = editMessageMediaMethod
}
suspend fun RequestsExecutor.editMessageCaption(
inlineMessageId: InlineMessageIdentifier,
media: InputMedia,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))

View File

@ -1,12 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
import com.github.insanusmokrassar.TelegramBotAPI.types.*
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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import kotlinx.serialization.*
@ -34,3 +37,41 @@ data class EditChatMessageText(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageText(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
)
suspend fun RequestsExecutor.editMessageText(
chat: Chat,
messageId: MessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
suspend fun RequestsExecutor.editMessageText(
chatId: ChatId,
message: Message,
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: Message,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)

View File

@ -1,11 +1,13 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod
import com.github.insanusmokrassar.TelegramBotAPI.types.*
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 kotlinx.serialization.*
@Serializable
@ -25,3 +27,11 @@ data class EditInlineMessageText(
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
suspend fun RequestsExecutor.editMessageText(
inlineMessageId: InlineMessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))