diff --git a/CHANGELOG b/CHANGELOG index bcf30576d4..4a4c2f58d8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,3 +15,24 @@ ## 0.8.3 * Now `ForwardedMessage` contains nullable `from` + +## 0.8.4 + +* Added `createMarkdownText` and extensions for `CaptionedMediaContent` and `TextContent` +* Added `ResendableContent` and realize in different contents + * Animation + * Audio + * Document + * Photo + * Sticker + * Video + * VideoNote + * Voice +* `MessageContent` now is `ResendableContent` +* Now all media sending factories which contains `thumb` have default `null` value +* `ChatIdentifier` classes now are `data` classes +* Now `MediaGroupContent` interface contains `toMediaGroupMemberInputMedia` method for easily creating mirror input media +* Change signature of `Update` + * Now `Update` is untyped and data is `Any` +* Media groups now are separated type of updates and you can subscribe on that receiving directly +* Now `AdministratorChatMember` is interface and `CreatorChatMember` implement it diff --git a/build.gradle b/build.gradle index c0b635ad4e..045922e9ed 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -project.version = "0.8.3" +project.version = "0.8.4" project.group = "com.github.insanusmokrassar" buildscript { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/Index.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/Index.kt index 9060345edd..bf1c66aab4 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/Index.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/Index.kt @@ -1,14 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.bot.ProxySettings -import com.github.insanusmokrassar.TelegramBotAPI.bot.useWith -import com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonMessageImpl -import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetUserProfilePhotos -import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.toInputMediaPhoto -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaGroup -import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest -import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.* import io.ktor.client.engine.okhttp.OkHttp import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt index 7be50995b0..5b3ec01f38 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt @@ -4,8 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.MultipartRequestCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.SimpleRequestCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException -import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters import io.ktor.client.HttpClient import io.ktor.client.call.HttpClientCall import io.ktor.client.engine.HttpClientEngine diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt index fdff4adecf..c5e4341d15 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/DeleteMessage.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests -import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt index 4d0d52d4b0..f0e764be4b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt index fc958b3c3f..d32001e0dd 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests -import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.User import kotlinx.serialization.KSerializer class GetMe : SimpleRequest { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt index 4da6df31b3..a4800f45c1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetUpdates.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests -import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate import kotlinx.serialization.* import kotlinx.serialization.internal.ArrayListSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt index addf37c658..ab1df291cf 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters -import com.github.insanusmokrassar.TelegramBotAPI.utils.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import kotlinx.serialization.* import kotlinx.serialization.json.JsonObject diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/types/ChatRequest.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/types/ChatRequest.kt index e538f3ac14..6b227e1345 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/types/ChatRequest.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/types/ChatRequest.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier interface ChatRequest { val chatId: ChatIdentifier diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt index 6eb8b3d1c6..829c8e4199 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/answers/AnswerCallbackQuery.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt index 2f8b66f55d..abe7ba5185 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/LeaveChat.kt @@ -6,7 +6,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer -import kotlinx.serialization.internal.StringSerializer @Serializable data class LeaveChat( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/abstracts/ChatMemberRequest.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/abstracts/ChatMemberRequest.kt index afa4ab863c..408a4973ed 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/abstracts/ChatMemberRequest.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/abstracts/ChatMemberRequest.kt @@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.UserId interface ChatMemberRequest : ChatRequest, SimpleRequest { val userId: UserId diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt index d8ab733578..1fdde3afb5 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChat.kt @@ -6,8 +6,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chat.RawChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer -import kotlinx.serialization.internal.StringSerializer @Serializable data class GetChat( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt index e1ceb4cc60..0733cacd82 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatAdministrators.kt @@ -4,10 +4,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.RawChat import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.* +import kotlinx.serialization.internal.ArrayListSerializer @Serializable data class GetChatAdministrators( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt index 4bb43799c2..c7d11a722e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/get/GetChatMembersCount.kt @@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatR import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* -import kotlinx.serialization.internal.* +import kotlinx.serialization.internal.IntSerializer @Serializable data class GetChatMembersCount( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt index df40b239db..6ca8211236 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/members/GetChatMember.kt @@ -1,11 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.UntilDate import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember import kotlinx.serialization.* -import kotlinx.serialization.internal.BooleanSerializer @Serializable data class GetChatMember( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt index 3bec4c4317..fc4608d176 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/DeleteChatPhoto.kt @@ -6,7 +6,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer -import kotlinx.serialization.internal.StringSerializer @Serializable data class DeleteChatPhoto( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt index 93ad6d990c..63908dbc6a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/PinChatMessage.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.DisableNotification import com.github.insanusmokrassar.TelegramBotAPI.types.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt index 53cd8aac9f..fd0d33f983 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatDescription.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt index 59934570ac..5053581e67 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatPhoto.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt index e288d4701e..faf46fa7e1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/SetChatTitle.kt @@ -1,6 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt index 3b6538712d..1ef661ec56 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/modify/UnpinChatMessage.kt @@ -6,7 +6,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer -import kotlinx.serialization.internal.StringSerializer @Serializable data class UnpinChatMessage( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt index af90e60f30..a224ebd87d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/chat/stickers/DeleteChatStickerSet.kt @@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ChatRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt index eb0a780abd..1fdbce0748 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditChatMessageLiveLocation.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* // TODO:: Replace return type by RawMessage or Boolean (as in documentation) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt index cc8bf27f6b..83d032ba86 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/EditInlineMessageLiveLocation.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* // TODO:: Replace return type by RawMessage or Boolean (as in documentation) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt index b5e9c2d11d..16693cf6ce 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopChatMessageLiveLocation.kt @@ -1,9 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* // TODO:: Replace return type by RawMessage or Boolean (as in documentation) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt index 64bf13498a..ccbd01aa37 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/LiveLocation/StopInlineMessageLiveLocation.kt @@ -1,9 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* // TODO:: Replace return type by RawMessage or Boolean (as in documentation) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt index 9b3ddc3979..8af0bd16cb 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt @@ -1,10 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditChatMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import kotlinx.serialization.* const val editMessageReplyMarkupMethod = "editMessageReplyMarkup" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt index 0ac7ddd734..38ad293c5f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt @@ -1,10 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditChatMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditChatMessage.kt index 7fd82be401..ac9c02a798 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditChatMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditChatMessage.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest interface EditChatMessage : SimpleRequest { val chatId: ChatIdentifier diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt index e20a5d9083..5f57497583 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditInlineMessage.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts -import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage interface EditInlineMessage : SimpleRequest { val inlineMessageId: InlineMessageIdentifier diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditTextChatMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditTextChatMessage.kt index 01a413ed18..9f87a729c1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditTextChatMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/abstracts/EditTextChatMessage.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest interface EditTextChatMessage : SimpleRequest { val text: String diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt index 6c2fc8ad94..09f219eb5f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditChatMessageCaption.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* 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.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* const val editMessageCaptionMethod = "editMessageCaption" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt index afb40f83a3..d4a6a07030 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/caption/EditInlineMessageCaption.kt @@ -1,11 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* 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.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt index 24fa044895..bcb3d96a0a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditChatMessageMedia.kt @@ -1,13 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* 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.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia import kotlinx.serialization.* -import java.lang.IllegalArgumentException const val editMessageMediaMethod = "editMessageMedia" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt index 64e1f3af0b..828941bee8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/media/EditInlineMessageMedia.kt @@ -1,14 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text -import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile 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.InputMedia.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import kotlinx.serialization.* -import java.lang.IllegalArgumentException @Serializable data class EditInlineMessageMedia( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt index 53898228bd..26e816f485 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditChatMessageText.kt @@ -1,12 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text +import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* 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.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod import kotlinx.serialization.* const val editMessageTextMethod = "editMessageText" @@ -30,6 +29,6 @@ data class EditChatMessageText( override val replyMarkup: InlineKeyboardMarkup? = null ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { - override fun method(): String = editMessageMediaMethod + override fun method(): String = editMessageTextMethod override fun resultSerializer(): KSerializer = RawMessage.serializer() } diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt index 29e7367eaa..bb853c2704 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/edit/text/EditInlineMessageText.kt @@ -1,12 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text +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.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt index ca27a73746..834cd3a8e9 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetFile.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get -import com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFile -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.fileIdField import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFile +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.fileIdField import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt index b183a9671e..c010d853a7 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetStickerSet.kt @@ -3,9 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.stickerSetNameField import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* @Serializable data class GetStickerSet( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt index 83f95a29cd..6ff1017bb8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/get/GetUserProfilePhotos.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.get -import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest +import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt index 23e73fb89a..9d4a0bdb00 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendAction.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.actions.BotAction -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt index 9850ec5ff5..500f9e7e5c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt @@ -1,9 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import kotlinx.serialization.* @Serializable @@ -45,7 +46,7 @@ data class SendContact( replyMarkup ) - override fun method(): String = "sendVenue" + override fun method(): String = "sendContact" override fun resultSerializer(): KSerializer = RawMessage.serializer() } diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt index a596500970..42593b0dd2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendLocation.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import kotlinx.serialization.* // TODO:: Add location tracker for tracking location diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt index be39134045..4216548fb4 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendMessage.kt @@ -1,12 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.DisableWebPagePreview +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.DisableWebPagePreview -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt index 30506e5509..e944cccf83 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/abstracts/DuratedSendMessageRequest.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/abstracts/DuratedSendMessageRequest.kt index 43c746c2fb..200eefdba2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/abstracts/DuratedSendMessageRequest.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/abstracts/DuratedSendMessageRequest.kt @@ -4,5 +4,5 @@ interface DuratedSendMessageRequest: SendMessageRequest { /** * Duration of media, usually in seconds */ - val duration: Int? + val duration: Long? } \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt index 8de32c9618..2704ee8be6 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/games/SendGame.kt @@ -1,15 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.games import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.types.ReplyMarkup -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Optional -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* @Serializable data class SendGame ( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt index f4842d455c..993fc8e2a7 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAnimation.kt @@ -1,23 +1,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendAnimation( chatId: ChatIdentifier, animation: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, - duration: Int? = null, + duration: Long? = null, width: Int? = null, height: Int? = null, disableNotification: Boolean = false, @@ -71,7 +71,7 @@ data class SendAnimationData internal constructor( override val parseMode: ParseMode? = null, @SerialName(durationField) @Optional - override val duration: Int? = null, + override val duration: Long? = null, @SerialName(widthField) @Optional override val width: Int? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt index 5f19b644fb..653621b317 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendAudio.kt @@ -1,23 +1,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendAudio( chatId: ChatIdentifier, audio: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, - duration: Int? = null, + duration: Long? = null, performer: String? = null, title: String? = null, disableNotification: Boolean = false, @@ -71,7 +71,7 @@ data class SendAudioData internal constructor( override val parseMode: ParseMode? = null, @SerialName(durationField) @Optional - override val duration: Int? = null, + override val duration: Long? = null, @SerialName(performerField) @Optional val performer: String? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt index b98ce44d00..05f22cc523 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendDocument.kt @@ -1,20 +1,20 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendDocument( chatId: ChatIdentifier, document: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt index 247edf9975..e3e2774435 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendMediaGroup.kt @@ -1,13 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media -import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request -import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia -import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.ThumbedInputMedia import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.ThumbedInputMedia +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import kotlinx.serialization.* import kotlinx.serialization.internal.ArrayListSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt index 6cbcfa39e5..a00684817b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendPhoto.kt @@ -1,13 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import kotlinx.serialization.* fun SendPhoto( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendStickerByFileId.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt similarity index 100% rename from src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendStickerByFileId.kt rename to src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendSticker.kt diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt index bb47ea2b2c..cdacb0f009 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideo.kt @@ -1,23 +1,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendVideo( chatId: ChatIdentifier, video: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, - duration: Int? = null, + duration: Long? = null, width: Int? = null, height: Int? = null, supportStreaming: Boolean? = null, @@ -73,7 +73,7 @@ data class SendVideoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(durationField) @Optional - override val duration: Int? = null, + override val duration: Long? = null, @SerialName(widthField) @Optional override val width: Int? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt index 33c423f3c6..3bedeec3c1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVideoNote.kt @@ -1,23 +1,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendVideoNote( chatId: ChatIdentifier, videoNote: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, - duration: Int? = null, + duration: Long? = null, size: Int? = null, // in documentation - length (size of video side) disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, @@ -69,7 +69,7 @@ data class SendVideoNoteData internal constructor( override val parseMode: ParseMode? = null, @SerialName(durationField) @Optional - override val duration: Int? = null, + override val duration: Long? = null, @SerialName(lengthField) @Optional override val width: Int? = null, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt index e859a0dbc3..2db410591b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt @@ -1,23 +1,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* 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.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import kotlinx.serialization.* fun SendVoice( chatId: ChatIdentifier, voice: InputFile, - thumb: InputFile?, + thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, - duration: Int? = null, + duration: Long? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null @@ -67,7 +67,7 @@ data class SendVoiceData internal constructor( override val parseMode: ParseMode? = null, @SerialName(durationField) @Optional - override val duration: Int? = null, + override val duration: Long? = null, @SerialName(disableNotificationField) @Optional override val disableNotification: Boolean = false, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt index 4075829a75..8f64e743b2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/DeleteStickerFromSet.kt @@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt index 930021f27f..0e97d18b6b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/stickers/SetStickerPositionInSet.kt @@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.positionField +import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField import kotlinx.serialization.* import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt index 79b353f25d..651a53c450 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatIdentifier.kt @@ -9,7 +9,7 @@ sealed class ChatIdentifier * Also used as User Identifier */ @Serializable(ChatIdentifierSerializer::class) -class ChatId( +data class ChatId( val chatId: Identifier ) : ChatIdentifier() @@ -18,7 +18,7 @@ typealias UserId = ChatId fun Identifier.toChatId(): ChatId = ChatId(this) @Serializable(ChatIdentifierSerializer::class) -class Username( +data class Username( val username: String ) : ChatIdentifier() { init { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt index f9dd24f588..0f1ec8e402 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMember.kt @@ -1,16 +1,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember -import com.github.insanusmokrassar.TelegramBotAPI.types.User - -data class AdministratorChatMember( - override val user: User, - val canBeEdited: Boolean, - val canChangeInfo: Boolean, - val canPostMessages: Boolean, - val canEditMessages: Boolean, - val canRemoveMessages: Boolean, - val canInviteUsers: Boolean, - val canRestrictMembers: Boolean, - val canPinMessages: Boolean, +interface AdministratorChatMember : ChatMember { + val canBeEdited: Boolean + val canChangeInfo: Boolean + val canPostMessages: Boolean + val canEditMessages: Boolean + val canRemoveMessages: Boolean + val canInviteUsers: Boolean + val canRestrictMembers: Boolean + val canPinMessages: Boolean val canPromoteMembers: Boolean -) : ChatMember +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt new file mode 100644 index 0000000000..dd0245717d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/AdministratorChatMemberImpl.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember + +import com.github.insanusmokrassar.TelegramBotAPI.types.User + +data class AdministratorChatMemberImpl( + override val user: User, + override val canBeEdited: Boolean, + override val canChangeInfo: Boolean, + override val canPostMessages: Boolean, + override val canEditMessages: Boolean, + override val canRemoveMessages: Boolean, + override val canInviteUsers: Boolean, + override val canRestrictMembers: Boolean, + override val canPinMessages: Boolean, + override val canPromoteMembers: Boolean +) : AdministratorChatMember diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt index 1999680d49..c6507cdd2a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/CreatorChatMember.kt @@ -2,4 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.User -data class CreatorChatMember(override val user: User) : ChatMember +data class CreatorChatMember(override val user: User) : AdministratorChatMember { + override val canBeEdited: Boolean = true + override val canChangeInfo: Boolean = true + override val canPostMessages: Boolean = true + override val canEditMessages: Boolean = true + override val canRemoveMessages: Boolean = true + override val canInviteUsers: Boolean = true + override val canRestrictMembers: Boolean = true + override val canPinMessages: Boolean = true + override val canPromoteMembers: Boolean = true +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/KickedChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/KickedChatMember.kt index b97c314669..486e30e6da 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/KickedChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/KickedChatMember.kt @@ -2,7 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate import com.github.insanusmokrassar.TelegramBotAPI.types.User -import org.joda.time.DateTime data class KickedChatMember( override val user: User, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt index f216b1fbe0..f64040c859 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RawChatMember.kt @@ -53,7 +53,7 @@ data class RawChatMember( val asChatMember: ChatMember by lazy { when (status) { "creator" -> CreatorChatMember(user) - "administrator" -> AdministratorChatMember( + "administrator" -> AdministratorChatMemberImpl( user, canBeEdited, canChangeInfo, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RestrictedChatMember.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RestrictedChatMember.kt index 0e19d60752..ce0c2df476 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RestrictedChatMember.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ChatMember/RestrictedChatMember.kt @@ -2,7 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.TelegramDate import com.github.insanusmokrassar.TelegramBotAPI.types.User -import org.joda.time.DateTime data class RestrictedChatMember( override val user: User, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt index 9a298647a0..a63459a39e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/InlineQueryResultArticle.kt @@ -4,10 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import kotlinx.serialization.Optional -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient +import kotlinx.serialization.* @Serializable class InlineQueryResultArticle( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt index 7e461c1f48..1bc539487e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt @@ -1,10 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.idField -import com.github.insanusmokrassar.TelegramBotAPI.types.replyMarkupField -import kotlinx.serialization.Optional -import kotlinx.serialization.SerialName interface InlineQueryResult { val type: String diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/DuratedInputMedia.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/DuratedInputMedia.kt index 3ba3c0820a..0162eecf42 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/DuratedInputMedia.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/DuratedInputMedia.kt @@ -1,5 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia interface DuratedInputMedia : InputMedia { - val duration: Int? + val duration: Long? } \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt index 61c681e1e8..9eb5a4446f 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAnimation.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import kotlinx.serialization.* @Serializable @@ -20,7 +20,7 @@ data class InputMediaAnimation( @Optional override val height: Int? = null, @Optional - override val duration: Int? = null, + override val duration: Long? = null, @Transient override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt index f154442e62..f7c47e0fb2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaAudio.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import kotlinx.serialization.* @Serializable @@ -16,7 +16,7 @@ data class InputMediaAudio( @Optional override val parseMode: ParseMode? = null, @Optional - override val duration: Int? = null, + override val duration: Long? = null, @Optional val performer: String? = null, @Optional diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt index 4f6afce48d..4faaa02314 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaDocument.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt index 81225da074..ed74803c65 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaPhoto.kt @@ -1,10 +1,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt index f915c0b7b6..b55eeae2a2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/InputMedia/InputMediaVideo.kt @@ -1,9 +1,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import kotlinx.serialization.* @Serializable @@ -20,7 +20,7 @@ data class InputMediaVideo( @Optional override val height: Int? = null, @Optional - override val duration: Int? = null, + override val duration: Long? = null, @Transient override val thumb: InputFile? = null ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt index 23e5f3b108..6df7fd1aa5 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/ParseMode/ParseMode.kt @@ -1,7 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode import kotlinx.serialization.* -import java.lang.IllegalArgumentException internal const val parseModeField = "parse_mode" diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt index 6db6fc6773..fb861ea9e4 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/ChannelChat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage data class ChannelChat( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/Chat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/Chat.kt index 59156434e6..5531325b90 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/Chat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/Chat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto interface Chat { val id: ChatId diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/GroupChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/GroupChat.kt index 99f52fa4b0..1e9c15bd6c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/GroupChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/GroupChat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto interface GroupChat : PublicChat { val allMembersAreAdmins: Boolean diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt index ebaec2c0de..4d1fb7ca1e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/PrivateChat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto data class PrivateChat( override val id: ChatId, diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt index 7e8fb87c20..442bb58653 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/RawChat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import kotlinx.serialization.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt index bbb2fd42b6..f555efa613 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/chat/SupergroupChat.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage data class SupergroupChat( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AnimationFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AnimationFile.kt index 4bf40ef200..59ca714b4d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AnimationFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AnimationFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AudioFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AudioFile.kt index fa653f0539..c55212869a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AudioFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/AudioFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/DocumentFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/DocumentFile.kt index 07222aa2ed..b6060f4cc3 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/DocumentFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/DocumentFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/File.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/File.kt index 5cd37e45ff..a933f0967d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/File.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/File.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt index 83c812f8ab..0e130b8c62 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PathedFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt index bb16194cd0..963554dc6b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/PhotoSize.kt @@ -1,20 +1,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* import kotlinx.serialization.internal.ArrayListSerializer typealias Photo = List -fun Photo.biggest(): PhotoSize? { - var biggest: PhotoSize = firstOrNull() ?: return null - forEach { - if (it.resolution > biggest.resolution) { - biggest = it - } - } - return biggest +fun Photo.biggest(): PhotoSize? = maxBy { + it.resolution } object PhotoSerializer : KSerializer by ArrayListSerializer( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/Sticker.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/Sticker.kt index 0b2b020545..6634b4ab42 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/Sticker.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/Sticker.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition import kotlinx.serialization.* diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/TelegramFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/TelegramFile.kt index adfbf76404..8776188bcf 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/TelegramFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/TelegramFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoFile.kt index e68d1f7bd2..1bc2bf681d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoNoteFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoNoteFile.kt index 6e906e57be..ff20f7fdad 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoNoteFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VideoNoteFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VoiceFile.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VoiceFile.kt index bcc8bfb1e5..00c5ba740d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VoiceFile.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/files/VoiceFile.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.files -import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId +import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.* import kotlinx.serialization.* @Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index 4c7694a24b..1806b20c20 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -1,7 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.* +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntitiesSerializer import com.github.insanusmokrassar.TelegramBotAPI.types.chat.* import com.github.insanusmokrassar.TelegramBotAPI.types.files.* import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/ContactContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/ContactContent.kt index 67b16e3a9c..a5cca887cf 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/ContactContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/ContactContent.kt @@ -1,8 +1,21 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content -import com.github.insanusmokrassar.TelegramBotAPI.types.Contact +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent data class ContactContent( val contact: Contact -) : MessageContent \ No newline at end of file +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendContact( + chatId, contact, disableNotification, replyToMessageId, replyMarkup + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/GameContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/GameContent.kt index 3c4eff1bc6..bbafa16285 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/GameContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/GameContent.kt @@ -1,8 +1,27 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.games.SendGame +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent data class GameContent( val game: Game -) : MessageContent \ No newline at end of file +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendGame( + chatId, + game.title, + disableNotification, + replyToMessageId, + replyMarkup + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/LocationContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/LocationContent.kt index 60f5d6b0ae..8c3c20d7b2 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/LocationContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/LocationContent.kt @@ -1,8 +1,27 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content -import com.github.insanusmokrassar.TelegramBotAPI.types.Location +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent data class LocationContent( val location: Location -) : MessageContent \ No newline at end of file +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendLocation( + chatId, + location.latitude, + location.longitude, + null, + disableNotification, + replyToMessageId, + replyMarkup + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/TextContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/TextContent.kt index 6350980692..7c1bb551b3 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/TextContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/TextContent.kt @@ -1,9 +1,32 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownText data class TextContent( val text: String, val entities: List = emptyList() -) : MessageContent +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendMessage( + chatId, + toMarkdownText(), + MarkdownParseMode, + false, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt index f86882e707..871b75ff71 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt @@ -1,8 +1,21 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content -import com.github.insanusmokrassar.TelegramBotAPI.types.Venue +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent data class VenueContent( val venue: Venue -) : MessageContent \ No newline at end of file +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendVenue( + chatId, venue, disableNotification, replyToMessageId, replyMarkup + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt index 587efd1fea..78d0a8d1af 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MediaGroupContent.kt @@ -1,3 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts -interface MediaGroupContent : MessageContent \ No newline at end of file +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia + +interface MediaGroupContent : MessageContent { + fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MessageContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MessageContent.kt index 7bf160e344..35c2c2e052 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MessageContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/MessageContent.kt @@ -1,3 +1,3 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts -interface MessageContent +interface MessageContent: ResendableContent diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/ResendableContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/ResendableContent.kt new file mode 100644 index 0000000000..0ad2ccf49d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/abstracts/ResendableContent.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts + +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage + +interface ResendableContent { + fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null + ): Request +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AnimationContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AnimationContent.kt index c6c67fb264..d4676b1c7b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AnimationContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AnimationContent.kt @@ -1,10 +1,45 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation +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 import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent data class AnimationContent( override val media: AnimationFile, val includedDocument: DocumentFile? -) : MediaContent \ No newline at end of file +) : MediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup) + + fun createResend( + chatId: ChatIdentifier, + caption: String?, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null + ): Request = SendAnimation( + chatId, + media.fileId, + media.thumb ?.fileId, + caption, + parseMode, + media.duration, + media.width, + media.height, + disableNotification, + replyToMessageId, + replyMarkup + ) +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt index e2c048f82b..e9aa329313 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/AudioContent.kt @@ -1,12 +1,39 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption data class AudioContent( override val media: AudioFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent +) : MediaContent, CaptionedMediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendAudio( + chatId, + media.fileId, + media.thumb ?.fileId, + toMarkdownCaption(), + MarkdownParseMode, + media.duration, + media.performer, + media.title, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt index dc9607adc4..1ceed1fa24 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/DocumentContent.kt @@ -1,12 +1,36 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption data class DocumentContent( override val media: DocumentFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent +) : MediaContent, CaptionedMediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendDocument( + chatId, + media.fileId, + media.thumb ?.fileId, + toMarkdownCaption(), + MarkdownParseMode, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt index 1fa526eb78..3b62698857 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/PhotoContent.kt @@ -1,11 +1,43 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMediaPhoto +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize +import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption data class PhotoContent( override val media: List, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaCollectionContent, CaptionedMediaContent, MediaGroupContent +) : MediaCollectionContent, CaptionedMediaContent, MediaGroupContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendPhoto( + chatId, + media.biggest() ?.fileId ?: throw IllegalStateException("Empty list of media"), + toMarkdownCaption(), + MarkdownParseMode, + disableNotification, + replyToMessageId, + replyMarkup + ) + + override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto( + media.biggest() ?.fileId ?: throw IllegalStateException("Can't locate any photo size for this content"), + toMarkdownCaption(), + MarkdownParseMode + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/StickerContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/StickerContent.kt index bf7bc4e48c..d326e63521 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/StickerContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/StickerContent.kt @@ -1,8 +1,27 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent data class StickerContent( override val media: Sticker -) : MediaContent +) : MediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendSticker( + chatId, + media.fileId, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt index edf2c4ae38..3312be91f0 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoContent.kt @@ -1,11 +1,51 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMediaVideo +import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption data class VideoContent( override val media: VideoFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent, MediaGroupContent +) : MediaContent, CaptionedMediaContent, MediaGroupContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendVideo( + chatId, + media.fileId, + media.thumb ?.fileId, + toMarkdownCaption(), + MarkdownParseMode, + media.duration, + media.width, + media.height, + null, + disableNotification, + replyToMessageId, + replyMarkup + ) + + override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo( + media.fileId, + toMarkdownCaption(), + MarkdownParseMode, + media.width, + media.height, + media.duration, + media.thumb ?.fileId + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoNoteContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoNoteContent.kt index ab5020d1b1..9e0ba9731b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoNoteContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VideoNoteContent.kt @@ -1,8 +1,42 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote +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 import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoNoteFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent data class VideoNoteContent( override val media: VideoNoteFile -) : MediaContent +) : MediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup) + + fun createResend( + chatId: ChatIdentifier, + caption: String?, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null + ): Request = SendVideoNote( + chatId, + media.fileId, + media.thumb ?.fileId, + caption, + parseMode, + media.duration, + media.width, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt index a54bb148c9..b61c4fc2cd 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/media/VoiceContent.kt @@ -1,12 +1,37 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent +import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption data class VoiceContent( override val media: VoiceFile, override val caption: String? = null, override val captionEntities: List = emptyList() -) : MediaContent, CaptionedMediaContent +) : MediaContent, CaptionedMediaContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request = SendVoice( + chatId, + media.fileId, + null, + toMarkdownCaption(), + MarkdownParseMode, + media.duration, + disableNotification, + replyToMessageId, + replyMarkup + ) +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/LabeledPrice.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/LabeledPrice.kt index fd1ea47baa..86617e825a 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/LabeledPrice.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/payments/LabeledPrice.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.payments -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.amountField +import com.github.insanusmokrassar.TelegramBotAPI.types.labelField import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Amounted import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/CallbackQueryUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/CallbackQueryUpdate.kt index 2912b1afc0..a17dd76254 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/CallbackQueryUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/CallbackQueryUpdate.kt @@ -7,4 +7,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update data class CallbackQueryUpdate( override val updateId: UpdateIdentifier, override val data: CallbackQuery -) : Update +) : Update diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChosenInlineResultUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChosenInlineResultUpdate.kt index 329bb77d24..6dbcde4ff9 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChosenInlineResultUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ChosenInlineResultUpdate.kt @@ -7,4 +7,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update data class ChosenInlineResultUpdate( override val updateId: UpdateIdentifier, override val data: ChosenInlineResult -) : Update \ No newline at end of file +) : Update \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/InlineQueryUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/InlineQueryUpdate.kt index a5b82a311d..2bb00ce4bc 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/InlineQueryUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/InlineQueryUpdate.kt @@ -7,4 +7,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update data class InlineQueryUpdate( override val updateId: UpdateIdentifier, override val data: InlineQuery -) : Update +) : Update diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/PreCheckoutQueryUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/PreCheckoutQueryUpdate.kt index 70c22a4027..259eba0e75 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/PreCheckoutQueryUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/PreCheckoutQueryUpdate.kt @@ -7,4 +7,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update data class PreCheckoutQueryUpdate( override val updateId: UpdateIdentifier, override val data: PreCheckoutQuery -) : Update +) : Update diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt index 63991bd96b..4c5e8699e1 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt @@ -28,7 +28,7 @@ data class RawUpdate constructor( @Optional private val pre_checkout_query: PreCheckoutQuery? = null ) { @Transient - val asUpdate: Update<*> by lazy { + val asUpdate: Update by lazy { when { message != null -> MessageUpdate(updateId, message.asMessage) edited_message != null -> EditMessageUpdate(updateId, edited_message.asMessage) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ShippingQueryUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ShippingQueryUpdate.kt index 51143da3d8..ee172c6b53 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ShippingQueryUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/ShippingQueryUpdate.kt @@ -7,4 +7,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update data class ShippingQueryUpdate( override val updateId: UpdateIdentifier, override val data: ShippingQuery -) : Update +) : Update diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/BaseMessageUpdate.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/BaseMessageUpdate.kt index 147c4edea6..2387a8b2a8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/BaseMessageUpdate.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/BaseMessageUpdate.kt @@ -2,4 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message -interface BaseMessageUpdate : Update \ No newline at end of file +interface BaseMessageUpdate : Update { + override val data: Message +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt index 8b8029724c..dacc8176ab 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt @@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier -interface Update { +interface Update { val updateId: UpdateIdentifier - val data: T + val data: Any } diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionSourcer.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionSourcer.kt new file mode 100644 index 0000000000..2af9230a2b --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionSourcer.kt @@ -0,0 +1,38 @@ +package com.github.insanusmokrassar.TelegramBotAPI.utils + +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity +import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent +import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent + +fun createMarkdownText( + text: String, + messageEntities: List +): String { + val builder = StringBuilder() + var offset = 0 + for (entity in messageEntities) { + builder.append( + text.substring(offset until entity.offset) + ) + builder.append( + entity.asMarkdownSource + ) + offset += entity.length + } + builder.append( + text.substring(offset) + ) + return builder.toString() +} + +fun CaptionedMediaContent.toMarkdownCaption(): String? = caption ?.let { + createMarkdownText( + it, + captionEntities + ) +} + +fun TextContent.toMarkdownText(): String = createMarkdownText( + text, + entities +) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/RequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/RequestsExecutor.kt index 66644ff849..5d9165a40c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/RequestsExecutor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/extensions/RequestsExecutor.kt @@ -2,27 +2,23 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor -import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery -import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.ChosenInlineResult -import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery -import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters -import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message -import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery -import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.requests.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters +import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage import com.github.insanusmokrassar.TelegramBotAPI.types.update.* +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import kotlinx.coroutines.* -typealias UpdateReceiver = suspend Update.() -> Unit +typealias UpdateReceiver = suspend (T) -> Unit fun RequestsExecutor.startGettingOfUpdates( requestsDelayMillis: Long = 1000, scope: CoroutineScope = GlobalScope, allowedUpdates: List? = null, - block: UpdateReceiver<*> + block: UpdateReceiver ): Job { return scope.launch { var lastHandledUpdate: UpdateIdentifier = 0L @@ -36,11 +32,57 @@ fun RequestsExecutor.startGettingOfUpdates( ) ) - for (rawUpdate in updates) { + val adaptedUpdates = mutableListOf() + var mediaGroup: MutableList? = null + + fun pushMediaGroup() { + mediaGroup ?.also { + adaptedUpdates.add(it) + mediaGroup = null + } + } + + updates.map { + it.asUpdate + }.forEach { update -> + val data = update.data + if (data is MediaGroupMessage) { + mediaGroup ?.let { + val message = it.first().data as MediaGroupMessage + if (message.mediaGroupId == data.mediaGroupId) { + it.add(update) + } else { + null + } + } ?: data.also { + pushMediaGroup() + mediaGroup = mutableListOf() + mediaGroup ?.add(update) + } + } else { + pushMediaGroup() + adaptedUpdates.add(update) + } + } + + mediaGroup ?.also { + adaptedUpdates.add(it) + mediaGroup = null + } + + for (update in adaptedUpdates) { + try { - val update = rawUpdate.asUpdate block(update) - lastHandledUpdate = update.updateId + lastHandledUpdate = when (update) { + is Update -> update.updateId + is List<*> -> (update.last() as? Update) ?.updateId ?: throw IllegalStateException( + "Found non-updates oriented list" + ) + else -> throw IllegalStateException( + "Unknown type of data" + ) + } } catch (e: Exception) { // TODO:: add exception handling e.printStackTrace() @@ -56,15 +98,16 @@ fun RequestsExecutor.startGettingOfUpdates( } fun RequestsExecutor.startGettingOfUpdates( - messageCallback: UpdateReceiver? = null, - editedMessageCallback: UpdateReceiver? = null, - channelPostCallback: UpdateReceiver? = null, - editedChannelPostCallback: UpdateReceiver? = null, - chosenInlineResultCallback: UpdateReceiver? = null, - inlineQueryCallback: UpdateReceiver? = null, - callbackQueryCallback: UpdateReceiver? = null, - shippingQueryCallback: UpdateReceiver? = null, - preCheckoutQueryCallback: UpdateReceiver? = null, + messageCallback: UpdateReceiver? = null, + mediaGroupCallback: UpdateReceiver>? = null, + editedMessageCallback: UpdateReceiver? = null, + channelPostCallback: UpdateReceiver? = null, + editedChannelPostCallback: UpdateReceiver? = null, + chosenInlineResultCallback: UpdateReceiver? = null, + inlineQueryCallback: UpdateReceiver? = null, + callbackQueryCallback: UpdateReceiver? = null, + shippingQueryCallback: UpdateReceiver? = null, + preCheckoutQueryCallback: UpdateReceiver? = null, requestsDelayMillis: Long = 1000, scope: CoroutineScope = GlobalScope ): Job { @@ -83,16 +126,21 @@ fun RequestsExecutor.startGettingOfUpdates( preCheckoutQueryCallback ?.let { UPDATE_PRE_CHECKOUT_QUERY } ) ) { - when (this) { - is MessageUpdate -> messageCallback ?.invoke(this) - is EditMessageUpdate -> editedMessageCallback ?.invoke(this) - is ChannelPostUpdate -> channelPostCallback ?.invoke(this) - is EditChannelPostUpdate -> editedChannelPostCallback ?.invoke(this) - is ChosenInlineResultUpdate -> chosenInlineResultCallback ?.invoke(this) - is InlineQueryUpdate -> inlineQueryCallback ?.invoke(this) - is CallbackQueryUpdate -> callbackQueryCallback ?.invoke(this) - is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(this) - is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(this) + when (it) { + is MessageUpdate -> messageCallback ?.invoke(it) + is List<*> -> mediaGroupCallback ?.invoke( + it.mapNotNull { + it as? BaseMessageUpdate + } + ) + is EditMessageUpdate -> editedMessageCallback ?.invoke(it) + is ChannelPostUpdate -> channelPostCallback ?.invoke(it) + is EditChannelPostUpdate -> editedChannelPostCallback ?.invoke(it) + is ChosenInlineResultUpdate -> chosenInlineResultCallback ?.invoke(it) + is InlineQueryUpdate -> inlineQueryCallback ?.invoke(it) + is CallbackQueryUpdate -> callbackQueryCallback ?.invoke(it) + is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(it) + is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(it) } } }