From 52c926425361ae2e2e1838ca73bf3f76fb6f7c49 Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Tue, 22 Apr 2025 12:35:04 +0300 Subject: [PATCH 1/6] dfkndsfjkdsjjdssdf --- TODO/ClassFinder.java | 136 +++++++ core/build.gradle | 19 + core/src/main/java/hdvtdev/telegram/Main.java | 55 +++ .../handlers/CallbackQueryHandler.java | 58 +++ .../handlers/TextMessageHandler.java | 61 ++++ .../telegram/annotations/util/Jsonable.java | 19 + .../telegram/annotations/util/NotTested.java | 18 + .../hdvtdev/telegram/core/InvokeMethod.java | 7 + .../main/java/hdvtdev/telegram/core/Main.java | 52 +++ .../hdvtdev/telegram/core/TelegramBot.java | 45 +++ .../hdvtdev/telegram/core/UpdateConsumer.java | 11 + .../java/hdvtdev/telegram/core/UserState.java | 4 + .../telegram/core/annotaions/Jsonable.java | 19 + .../core/exceptions/TelegramApiException.java | 30 ++ .../TelegramApiNetworkException.java | 17 + .../TelegramMethodParsingException.java | 11 + .../core/methods/AnswerCallbackQuery.java | 113 ++++++ .../core/methods/ApproveChatJoinRequest.java | 51 +++ .../telegram/core/methods/BanChatMember.java | 110 ++++++ .../core/methods/BanChatSenderChat.java | 38 ++ .../core/methods/CloseForumTopic.java | 37 ++ .../core/methods/CloseGeneralForumTopic.java | 37 ++ .../telegram/core/methods/CopyMessage.java | 244 +++++++++++++ .../telegram/core/methods/CopyMessages.java | 181 ++++++++++ .../core/methods/CreateChatInviteLink.java | 114 ++++++ .../telegram/core/methods/ForwardMessage.java | 133 +++++++ .../core/methods/ForwardMessages.java | 147 ++++++++ .../core/methods/GetChatAdministrators.java | 36 ++ .../telegram/core/methods/GetChatMember.java | 38 ++ .../telegram/core/methods/GetFile.java | 23 ++ .../hdvtdev/telegram/core/methods/GetMe.java | 22 ++ .../telegram/core/methods/GetMyCommands.java | 58 +++ .../core/methods/GetMyDescription.java | 42 +++ .../telegram/core/methods/GetMyName.java | 38 ++ .../telegram/core/methods/GetUpdates.java | 42 +++ .../core/methods/RevokeChatInviteLink.java | 37 ++ .../telegram/core/methods/SendChatAction.java | 104 ++++++ .../telegram/core/methods/SendDice.java | 133 +++++++ .../telegram/core/methods/SendMessage.java | 226 ++++++++++++ .../core/methods/SetMessageReaction.java | 100 ++++++ .../telegram/core/methods/SetMyCommands.java | 100 ++++++ .../core/methods/SetMyDescription.java | 41 +++ .../telegram/core/methods/SetMyName.java | 28 ++ .../core/methods/TelegramApiMethod.java | 13 + .../core/methods/TelegramApiMethodBody.java | 31 ++ .../telegram/core/methods/util/ParseMode.java | 7 + .../telegram/core/methods/util/Util.java | 98 +++++ .../core/objects/AnswerCallbackQuery.java | 113 ++++++ .../core/objects/ApproveChatJoinRequest.java | 51 +++ .../telegram/core/objects/BanChatMember.java | 110 ++++++ .../core/objects/BanChatSenderChat.java | 38 ++ .../core/objects/ChosenInlineResult.java | 16 + .../core/objects/CloseForumTopic.java | 37 ++ .../core/objects/CloseGeneralForumTopic.java | 37 ++ .../telegram/core/objects/Contact.java | 16 + .../telegram/core/objects/CopyMessage.java | 244 +++++++++++++ .../telegram/core/objects/CopyMessages.java | 181 ++++++++++ .../core/objects/CreateChatInviteLink.java | 114 ++++++ .../hdvtdev/telegram/core/objects/Dice.java | 13 + .../telegram/core/objects/ForwardMessage.java | 133 +++++++ .../core/objects/ForwardMessages.java | 147 ++++++++ .../hdvtdev/telegram/core/objects/Game.java | 17 + .../core/objects/GetChatAdministrators.java | 36 ++ .../telegram/core/objects/GetChatMember.java | 38 ++ .../telegram/core/objects/GetFile.java | 23 ++ .../hdvtdev/telegram/core/objects/GetMe.java | 22 ++ .../telegram/core/objects/GetMyCommands.java | 58 +++ .../core/objects/GetMyDescription.java | 42 +++ .../telegram/core/objects/GetMyName.java | 38 ++ .../telegram/core/objects/GetUpdates.java | 42 +++ .../telegram/core/objects/InlineQuery.java | 17 + .../telegram/core/objects/Location.java | 17 + .../telegram/core/objects/LoginUrl.java | 15 + .../telegram/core/objects/MaskPosition.java | 15 + .../core/objects/ProximityAlertTriggered.java | 14 + .../core/objects/ReplyParameters.java | 28 ++ .../core/objects/RevokeChatInviteLink.java | 37 ++ .../telegram/core/objects/SendChatAction.java | 104 ++++++ .../telegram/core/objects/SendDice.java | 133 +++++++ .../telegram/core/objects/SendMessage.java | 226 ++++++++++++ .../core/objects/SetMessageReaction.java | 100 ++++++ .../telegram/core/objects/SetMyCommands.java | 100 ++++++ .../core/objects/SetMyDescription.java | 41 +++ .../telegram/core/objects/SetMyName.java | 28 ++ .../telegram/core/objects/SharedUser.java | 16 + .../core/objects/TelegramApiMethod.java | 13 + .../hdvtdev/telegram/core/objects/Update.java | 139 ++++++++ .../hdvtdev/telegram/core/objects/User.java | 62 ++++ .../telegram/core/objects/UsersShared.java | 13 + .../hdvtdev/telegram/core/objects/Venue.java | 18 + .../telegram/core/objects/WebAppData.java | 10 + .../telegram/core/objects/WebAppInfo.java | 10 + .../core/objects/WriteAccessAllowed.java | 14 + .../objects/background/BackgroundFill.java | 18 + .../BackgroundFillDeserializer.java | 4 + .../BackgroundFillFreeformGradient.java | 13 + .../background/BackgroundFillGradient.java | 15 + .../background/BackgroundFillSolid.java | 13 + .../objects/background/BackgroundType.java | 19 + .../background/BackgroundTypeChatTheme.java | 13 + .../BackgroundTypeDeserializer.java | 4 + .../background/BackgroundTypeFill.java | 14 + .../background/BackgroundTypePattern.java | 16 + .../background/BackgroundTypeWallpaper.java | 16 + .../objects/business/BusinessConnection.java | 17 + .../business/BusinessMessagesDeleted.java | 15 + .../core/objects/callback/CallbackGame.java | 9 + .../core/objects/callback/CallbackQuery.java | 40 +++ .../telegram/core/objects/chat/Chat.java | 35 ++ .../objects/chat/ChatAdministratorRights.java | 26 ++ .../core/objects/chat/ChatBackground.java | 11 + .../core/objects/chat/ChatInviteLink.java | 29 ++ .../core/objects/chat/ChatJoinRequest.java | 17 + .../core/objects/chat/ChatMember.java | 28 ++ .../objects/chat/ChatMemberAdministrator.java | 30 ++ .../core/objects/chat/ChatMemberBanned.java | 14 + .../core/objects/chat/ChatMemberLeft.java | 13 + .../core/objects/chat/ChatMemberMember.java | 14 + .../core/objects/chat/ChatMemberOwner.java | 15 + .../objects/chat/ChatMemberRestricted.java | 29 ++ .../core/objects/chat/ChatMemberUpdated.java | 19 + .../core/objects/chat/ChatShared.java | 16 + .../core/objects/chatboost/ChatBoost.java | 15 + .../objects/chatboost/ChatBoostAdded.java | 12 + .../objects/chatboost/ChatBoostRemoved.java | 15 + .../objects/chatboost/ChatBoostSource.java | 18 + .../chatboost/ChatBoostSourceGiftCode.java | 13 + .../chatboost/ChatBoostSourceGiveaway.java | 16 + .../chatboost/ChatBoostSourcePremium.java | 13 + .../objects/chatboost/ChatBoostUpdated.java | 13 + .../core/objects/command/BotCommand.java | 13 + .../core/objects/command/BotCommandScope.java | 22 ++ .../BotCommandScopeAllChatAdministrators.java | 10 + .../command/BotCommandScopeAllGroupChats.java | 10 + .../BotCommandScopeAllPrivateChats.java | 10 + .../objects/command/BotCommandScopeChat.java | 14 + .../BotCommandScopeChatAdministrators.java | 14 + .../command/BotCommandScopeChatMember.java | 27 ++ .../command/BotCommandScopeDefault.java | 10 + .../core/objects/forum/ForumTopicClosed.java | 9 + .../core/objects/forum/ForumTopicCreated.java | 14 + .../core/objects/forum/ForumTopicEdited.java | 13 + .../objects/forum/ForumTopicReopened.java | 9 + .../forum/GeneralForumTopicHidden.java | 9 + .../forum/GeneralForumTopicUnhidden.java | 9 + .../core/objects/giveaway/Giveaway.java | 21 ++ .../objects/giveaway/GiveawayCompleted.java | 16 + .../objects/giveaway/GiveawayCreated.java | 10 + .../objects/giveaway/GiveawayWinners.java | 24 ++ .../core/objects/markup/CopyTextButton.java | 10 + .../core/objects/markup/ForceReply.java | 15 + .../objects/markup/InlineKeyboardButton.java | 250 +++++++++++++ .../objects/markup/InlineKeyboardMarkup.java | 35 ++ .../objects/markup/InlineKeyboardRow.java | 69 ++++ .../core/objects/markup/KeyboardButton.java | 18 + .../markup/KeyboardButtonPollType.java | 12 + .../markup/KeyboardButtonRequestChat.java | 23 ++ .../markup/KeyboardButtonRequestUsers.java | 18 + .../objects/markup/ReplyKeyboardMarkup.java | 17 + .../objects/markup/ReplyKeyboardRemove.java | 13 + .../core/objects/markup/ReplyMarkup.java | 16 + .../markup/SwitchInlineQueryChosenChat.java | 16 + .../core/objects/media/Animation.java | 37 ++ .../telegram/core/objects/media/Audio.java | 37 ++ .../telegram/core/objects/media/Document.java | 21 ++ .../core/objects/media/PhotoSize.java | 16 + .../telegram/core/objects/media/Sticker.java | 26 ++ .../telegram/core/objects/media/Story.java | 14 + .../core/objects/media/TelegramFile.java | 17 + .../telegram/core/objects/media/Voice.java | 16 + .../objects/media/paidmedia/PaidMedia.java | 17 + .../media/paidmedia/PaidMediaInfo.java | 13 + .../media/paidmedia/PaidMediaPhoto.java | 13 + .../media/paidmedia/PaidMediaPreview.java | 15 + .../media/paidmedia/PaidMediaPurchased.java | 13 + .../media/paidmedia/PaidMediaVideo.java | 13 + .../core/objects/media/video/Video.java | 22 ++ .../objects/media/video/VideoChatEnded.java | 10 + .../video/VideoChatParticipantsInvited.java | 10 + .../media/video/VideoChatScheduled.java | 10 + .../objects/media/video/VideoChatStarted.java | 9 + .../core/objects/media/video/VideoNote.java | 17 + .../objects/message/ExternalReplyInfo.java | 46 +++ .../objects/message/InaccessibleMessage.java | 15 + .../objects/message/LinkPreviewOptions.java | 17 + .../message/MaybeInaccessibleMessage.java | 15 + .../MaybeInaccessibleMessageDeserializer.java | 16 + .../core/objects/message/Message.java | 275 ++++++++++++++ .../MessageAutoDeleteTimerChanged.java | 10 + .../core/objects/message/MessageEntity.java | 18 + .../core/objects/message/MessageOrigin.java | 19 + .../objects/message/MessageOriginChannel.java | 16 + .../objects/message/MessageOriginChat.java | 15 + .../message/MessageOriginHiddenUser.java | 14 + .../objects/message/MessageOriginUser.java | 14 + .../message/MessageReactionCountUpdated.java | 15 + .../message/MessageReactionUpdated.java | 18 + .../core/objects/message/TextQuote.java | 12 + .../passport/EncryptedCredentials.java | 14 + .../passport/EncryptedPassportElement.java | 21 ++ .../core/objects/passport/PassportData.java | 13 + .../core/objects/passport/PassportFile.java | 15 + .../core/objects/payment/Invoice.java | 16 + .../core/objects/payment/OrderInfo.java | 15 + .../objects/payment/PreCheckoutQuery.java | 18 + .../core/objects/payment/RefundedPayment.java | 16 + .../core/objects/payment/ShippingAddress.java | 17 + .../core/objects/payment/ShippingQuery.java | 15 + .../objects/payment/SuccessfulPayment.java | 21 ++ .../telegram/core/objects/poll/Poll.java | 26 ++ .../core/objects/poll/PollAnswer.java | 16 + .../core/objects/poll/PollOption.java | 15 + .../core/objects/reaction/ReactionCount.java | 13 + .../core/objects/reaction/ReactionType.java | 17 + .../reaction/ReactionTypeCustomEmoji.java | 13 + .../objects/reaction/ReactionTypeEmoji.java | 16 + .../objects/reaction/ReactionTypePaid.java | 12 + .../exceptions/TelegramApiException.java | 30 ++ .../TelegramApiNetworkException.java | 17 + .../TelegramMethodParsingException.java | 11 + .../telegram/methods/AnswerCallbackQuery.java | 113 ++++++ .../methods/ApproveChatJoinRequest.java | 51 +++ .../telegram/methods/BanChatMember.java | 110 ++++++ .../telegram/methods/BanChatSenderChat.java | 38 ++ .../telegram/methods/CloseForumTopic.java | 37 ++ .../methods/CloseGeneralForumTopic.java | 37 ++ .../hdvtdev/telegram/methods/CopyMessage.java | 244 +++++++++++++ .../telegram/methods/CopyMessages.java | 181 ++++++++++ .../methods/CreateChatInviteLink.java | 114 ++++++ .../telegram/methods/ForwardMessage.java | 133 +++++++ .../telegram/methods/ForwardMessages.java | 147 ++++++++ .../methods/GetChatAdministrators.java | 36 ++ .../telegram/methods/GetChatMember.java | 38 ++ .../hdvtdev/telegram/methods/GetFile.java | 23 ++ .../java/hdvtdev/telegram/methods/GetMe.java | 22 ++ .../telegram/methods/GetMyCommands.java | 58 +++ .../telegram/methods/GetMyDescription.java | 42 +++ .../hdvtdev/telegram/methods/GetMyName.java | 38 ++ .../hdvtdev/telegram/methods/GetUpdates.java | 42 +++ .../methods/RevokeChatInviteLink.java | 37 ++ .../telegram/methods/SendChatAction.java | 104 ++++++ .../hdvtdev/telegram/methods/SendDice.java | 133 +++++++ .../hdvtdev/telegram/methods/SendMessage.java | 226 ++++++++++++ .../telegram/methods/SetMessageReaction.java | 100 ++++++ .../telegram/methods/SetMyCommands.java | 100 ++++++ .../telegram/methods/SetMyDescription.java | 41 +++ .../hdvtdev/telegram/methods/SetMyName.java | 28 ++ .../telegram/methods/TelegramApiMethod.java | 13 + .../hdvtdev/telegram/objects/Animation.java | 37 ++ .../java/hdvtdev/telegram/objects/Audio.java | 37 ++ .../telegram/objects/BackgroundFill.java | 18 + .../BackgroundFillFreeformGradient.java | 13 + .../objects/BackgroundFillGradient.java | 15 + .../telegram/objects/BackgroundFillSolid.java | 13 + .../telegram/objects/BackgroundType.java | 19 + .../objects/BackgroundTypeChatTheme.java | 13 + .../telegram/objects/BackgroundTypeFill.java | 14 + .../objects/BackgroundTypePattern.java | 16 + .../objects/BackgroundTypeWallpaper.java | 16 + .../telegram/objects/BusinessConnection.java | 17 + .../objects/BusinessMessagesDeleted.java | 14 + .../telegram/objects/CallbackGame.java | 9 + .../telegram/objects/CallbackQuery.java | 39 ++ .../java/hdvtdev/telegram/objects/Chat.java | 35 ++ .../objects/ChatAdministratorRights.java | 26 ++ .../telegram/objects/ChatBackground.java | 10 + .../hdvtdev/telegram/objects/ChatBoost.java | 15 + .../telegram/objects/ChatBoostAdded.java | 12 + .../telegram/objects/ChatBoostRemoved.java | 15 + .../telegram/objects/ChatBoostSource.java | 18 + .../objects/ChatBoostSourceGiftCode.java | 13 + .../objects/ChatBoostSourceGiveaway.java | 16 + .../objects/ChatBoostSourcePremium.java | 13 + .../telegram/objects/ChatBoostUpdated.java | 13 + .../telegram/objects/ChatInviteLink.java | 29 ++ .../telegram/objects/ChatJoinRequest.java | 17 + .../hdvtdev/telegram/objects/ChatMember.java | 28 ++ .../objects/ChatMemberAdministrator.java | 30 ++ .../telegram/objects/ChatMemberBanned.java | 14 + .../telegram/objects/ChatMemberLeft.java | 13 + .../telegram/objects/ChatMemberMember.java | 14 + .../telegram/objects/ChatMemberOwner.java | 15 + .../objects/ChatMemberRestricted.java | 29 ++ .../telegram/objects/ChatMemberUpdated.java | 19 + .../hdvtdev/telegram/objects/ChatShared.java | 16 + .../telegram/objects/ChosenInlineResult.java | 16 + .../hdvtdev/telegram/objects/Contact.java | 16 + .../telegram/objects/CopyTextButton.java | 10 + .../java/hdvtdev/telegram/objects/Dice.java | 13 + .../hdvtdev/telegram/objects/Document.java | 21 ++ .../objects/EncryptedCredentials.java | 14 + .../objects/EncryptedPassportElement.java | 21 ++ .../telegram/objects/ExternalReplyInfo.java | 35 ++ .../hdvtdev/telegram/objects/ForceReply.java | 14 + .../telegram/objects/ForumTopicClosed.java | 9 + .../telegram/objects/ForumTopicCreated.java | 14 + .../telegram/objects/ForumTopicEdited.java | 13 + .../telegram/objects/ForumTopicReopened.java | 9 + .../java/hdvtdev/telegram/objects/Game.java | 17 + .../objects/GeneralForumTopicHidden.java | 9 + .../objects/GeneralForumTopicUnhidden.java | 9 + .../hdvtdev/telegram/objects/Giveaway.java | 20 ++ .../telegram/objects/GiveawayCompleted.java | 15 + .../telegram/objects/GiveawayCreated.java | 10 + .../telegram/objects/GiveawayWinners.java | 23 ++ .../telegram/objects/InaccessibleMessage.java | 15 + .../objects/InlineKeyboardButton.java | 250 +++++++++++++ .../objects/InlineKeyboardMarkup.java | 35 ++ .../telegram/objects/InlineKeyboardRow.java | 69 ++++ .../hdvtdev/telegram/objects/InlineQuery.java | 17 + .../hdvtdev/telegram/objects/Invoice.java | 16 + .../telegram/objects/KeyboardButton.java | 18 + .../objects/KeyboardButtonPollType.java | 12 + .../objects/KeyboardButtonRequestChat.java | 22 ++ .../objects/KeyboardButtonRequestUsers.java | 18 + .../telegram/objects/LinkPreviewOptions.java | 17 + .../hdvtdev/telegram/objects/Location.java | 17 + .../hdvtdev/telegram/objects/LoginUrl.java | 15 + .../telegram/objects/MaskPosition.java | 15 + .../objects/MaybeInaccessibleMessage.java | 15 + .../MaybeInaccessibleMessageDeserializer.java | 16 + .../hdvtdev/telegram/objects/Message.java | 274 ++++++++++++++ .../MessageAutoDeleteTimerChanged.java | 10 + .../telegram/objects/MessageEntity.java | 18 + .../telegram/objects/MessageOrigin.java | 19 + .../objects/MessageOriginChannel.java | 16 + .../telegram/objects/MessageOriginChat.java | 15 + .../objects/MessageOriginHiddenUser.java | 14 + .../telegram/objects/MessageOriginUser.java | 14 + .../objects/MessageReactionCountUpdated.java | 15 + .../objects/MessageReactionUpdated.java | 18 + .../hdvtdev/telegram/objects/OrderInfo.java | 15 + .../hdvtdev/telegram/objects/PaidMedia.java | 17 + .../telegram/objects/PaidMediaInfo.java | 13 + .../telegram/objects/PaidMediaPhoto.java | 13 + .../telegram/objects/PaidMediaPreview.java | 15 + .../telegram/objects/PaidMediaPurchased.java | 13 + .../telegram/objects/PaidMediaVideo.java | 13 + .../telegram/objects/PassportData.java | 13 + .../telegram/objects/PassportFile.java | 15 + .../hdvtdev/telegram/objects/PhotoSize.java | 16 + .../java/hdvtdev/telegram/objects/Poll.java | 25 ++ .../hdvtdev/telegram/objects/PollAnswer.java | 15 + .../hdvtdev/telegram/objects/PollOption.java | 14 + .../telegram/objects/PreCheckoutQuery.java | 18 + .../objects/ProximityAlertTriggered.java | 14 + .../telegram/objects/ReactionCount.java | 13 + .../telegram/objects/ReactionType.java | 17 + .../objects/ReactionTypeCustomEmoji.java | 13 + .../telegram/objects/ReactionTypeEmoji.java | 16 + .../telegram/objects/ReactionTypePaid.java | 12 + .../telegram/objects/RefundedPayment.java | 16 + .../telegram/objects/ReplyKeyboardMarkup.java | 17 + .../telegram/objects/ReplyKeyboardRemove.java | 13 + .../hdvtdev/telegram/objects/ReplyMarkup.java | 16 + .../telegram/objects/ReplyParameters.java | 28 ++ .../hdvtdev/telegram/objects/SharedUser.java | 16 + .../telegram/objects/ShippingAddress.java | 17 + .../telegram/objects/ShippingQuery.java | 15 + .../hdvtdev/telegram/objects/Sticker.java | 26 ++ .../java/hdvtdev/telegram/objects/Story.java | 13 + .../telegram/objects/SuccessfulPayment.java | 21 ++ .../objects/SwitchInlineQueryChosenChat.java | 16 + .../telegram/objects/TelegramFile.java | 17 + .../hdvtdev/telegram/objects/TextQuote.java | 11 + .../java/hdvtdev/telegram/objects/Update.java | 139 ++++++++ .../java/hdvtdev/telegram/objects/User.java | 62 ++++ .../hdvtdev/telegram/objects/UsersShared.java | 13 + .../java/hdvtdev/telegram/objects/Venue.java | 18 + .../java/hdvtdev/telegram/objects/Video.java | 22 ++ .../telegram/objects/VideoChatEnded.java | 10 + .../objects/VideoChatParticipantsInvited.java | 10 + .../telegram/objects/VideoChatScheduled.java | 10 + .../telegram/objects/VideoChatStarted.java | 9 + .../hdvtdev/telegram/objects/VideoNote.java | 17 + .../java/hdvtdev/telegram/objects/Voice.java | 16 + .../hdvtdev/telegram/objects/WebAppData.java | 10 + .../hdvtdev/telegram/objects/WebAppInfo.java | 10 + .../telegram/objects/WriteAccessAllowed.java | 14 + .../telegram/objects/bot/BotCommand.java | 13 + .../telegram/objects/bot/BotCommandScope.java | 22 ++ .../BotCommandScopeAllChatAdministrators.java | 10 + .../bot/BotCommandScopeAllGroupChats.java | 10 + .../bot/BotCommandScopeAllPrivateChats.java | 10 + .../objects/bot/BotCommandScopeChat.java | 14 + .../BotCommandScopeChatAdministrators.java | 14 + .../bot/BotCommandScopeChatMember.java | 27 ++ .../objects/bot/BotCommandScopeDefault.java | 10 + .../hdvtdev/telegram/util/ClassFinder.java | 136 +++++++ .../hdvtdev/telegram/util/InvokeMethod.java | 7 + .../java/hdvtdev/telegram/util/ParseMode.java | 7 + .../main/java/hdvtdev/telegram/util/Util.java | 98 +++++ core/src/main/java/module-info.java | 3 + longpolling-okhttp/build.gradle | 24 ++ .../longpolling/okhttp/OkHttpTelegramBot.java | 335 ++++++++++++++++++ .../src/main/java/module-info.java | 6 + test/build.gradle | 17 + test/src/main/java/Main.java | 4 + 398 files changed, 14324 insertions(+) create mode 100644 TODO/ClassFinder.java create mode 100644 core/build.gradle create mode 100644 core/src/main/java/hdvtdev/telegram/Main.java create mode 100644 core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java create mode 100644 core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java create mode 100644 core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java create mode 100644 core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/Main.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/TelegramBot.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/UserState.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/annotaions/Jsonable.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/GetUpdates.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/RevokeChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ChosenInlineResult.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Contact.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Dice.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Game.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/InlineQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Location.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/LoginUrl.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/MaskPosition.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ProximityAlertTriggered.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Update.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/User.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/UsersShared.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/Venue.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/WebAppData.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/WebAppInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/WriteAccessAllowed.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java create mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java create mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java create mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMe.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendDice.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyName.java create mode 100644 core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Animation.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Audio.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Chat.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatShared.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Contact.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Dice.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Document.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForceReply.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Game.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Giveaway.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Invoice.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Location.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Message.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PassportData.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PassportFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Poll.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PollOption.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionType.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/SharedUser.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Sticker.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Story.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/TextQuote.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Update.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/User.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/UsersShared.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Venue.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Video.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoNote.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/Voice.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/WebAppData.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java create mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java create mode 100644 core/src/main/java/hdvtdev/telegram/util/ClassFinder.java create mode 100644 core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java create mode 100644 core/src/main/java/hdvtdev/telegram/util/ParseMode.java create mode 100644 core/src/main/java/hdvtdev/telegram/util/Util.java create mode 100644 core/src/main/java/module-info.java create mode 100644 longpolling-okhttp/build.gradle create mode 100644 longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java create mode 100644 longpolling-okhttp/src/main/java/module-info.java create mode 100644 test/build.gradle create mode 100644 test/src/main/java/Main.java diff --git a/TODO/ClassFinder.java b/TODO/ClassFinder.java new file mode 100644 index 0000000..c29b0ae --- /dev/null +++ b/TODO/ClassFinder.java @@ -0,0 +1,136 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler; +import hdvtdev.telegram.annotations.handlers.TextMessageHandler; +import hdvtdev.telegram.objects.CallbackQuery; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.Update; + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.security.CodeSource; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +public abstract class ClassFinder { + + private static final Set> annotationsToSearch = Set.of(TextMessageHandler.class, CallbackQueryHandler.class); + private static final Set> methodsArgumentType = Set.of(Message.class, Update.class, CallbackQuery.class); + + private static ErrorHandler errorHandler; + + public static Map, Map> getClasses() { + + Map, Map> allMethods = new HashMap<>(); + annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); + + CodeSource codeSource = ClassFinder.class.getProtectionDomain().getCodeSource(); + if (codeSource != null) { + try { + String path = codeSource.getLocation().toURI().getPath(); + File file = new File(URLDecoder.decode(path, StandardCharsets.UTF_8)); + + if (file.isFile() && file.getName().endsWith(".jar")) { + processJar(file, allMethods); + } else if (file.isDirectory()) { + processDirectory(file, "", allMethods); + } + } catch (Exception e) { + return Map.of(); + } + } + + return Collections.unmodifiableMap(allMethods); + } + + private static void processDirectory(File directory, String packageName, Map, Map> methods) { + File[] files = directory.listFiles(); + if (files == null) return; + + for (File file : files) { + if (file.isDirectory()) { + processDirectory(file, packageName + file.getName() + ".", methods); + } else if (file.getName().endsWith(".class")) { + + String className = packageName + file.getName().replace(".class", ""); + loadClass(className, methods); + } + } + } + + private static void processJar(File jarFile, Map, Map> methods) { + try (JarFile jar = new JarFile(jarFile)) { + Enumeration entries = jar.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + if (entry.getName().endsWith(".class")) { + String className = entry.getName() + .replace("/", ".") + .replace(".class", ""); + + loadClass(className, methods); + } + } + } catch (IOException ignored) { + } + } + + public static Map, Map> localScan(Class cls) { + Map, Map> allMethods = new HashMap<>(); + annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); + loadClass(cls.getName(), allMethods); + return allMethods; + } + + + private static void loadClass(String className, Map, Map> methods) { + try { + Class c = Class.forName(className); + + for (Method method : c.getDeclaredMethods()) { + + Class[] parameters = method.getParameterTypes(); + + if (parameters.length != 0 && !methodsArgumentType.contains(parameters[0])) { + continue; + } + + if (method.isAnnotationPresent(CallbackQueryHandler.class)) { + if (Modifier.isStatic(method.getModifiers())) { + for (String value : method.getAnnotation(CallbackQueryHandler.class).value()) { + methods.get(CallbackQueryHandler.class).put(value, new InvokeMethod(method, parameters[0])); + } + } else + System.err.println(method + " is annotated with @CallbackQueryHandler, but it is not static. For the annotation to work, the method must be static."); + } + + if (method.isAnnotationPresent(TextMessageHandler.class)) { + if (Modifier.isStatic(method.getModifiers())) { + for (String value : method.getAnnotation(TextMessageHandler.class).value()) { + methods.get(TextMessageHandler.class).put(value, new InvokeMethod(method, parameters[0])); + } + } else + System.err.println(method + " is annotated with @TextMessageHandler, but it is not static. For the annotation to work, the method must be static."); + } + + } + } catch (NoClassDefFoundError | UnsupportedClassVersionError | ClassNotFoundException e) { + if (errorHandler != null) errorHandler.onError(e); + } + } + + public void setErrorHandler(ErrorHandler errorHandler) { + ClassFinder.errorHandler = errorHandler; + } + + public interface ErrorHandler { + void onError(Throwable throwable); + } + +} diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..e472613 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,19 @@ +plugins { + id 'java' +} + +group = 'com.github.hdvtdev' +version = '1.0.0' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' +} + +jar { + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} diff --git a/core/src/main/java/hdvtdev/telegram/Main.java b/core/src/main/java/hdvtdev/telegram/Main.java new file mode 100644 index 0000000..a7be11d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/Main.java @@ -0,0 +1,55 @@ +package hdvtdev.telegram; + +import com.fasterxml.jackson.databind.ObjectMapper; +import hdvtdev.telegram.annotations.handlers.TextMessageHandler; +import hdvtdev.telegram.core.OkHttpTelegramBot; +import hdvtdev.telegram.core.TelegramBot; +import hdvtdev.telegram.core.UpdateConsumer; +import hdvtdev.telegram.exceptions.TelegramApiException; +import hdvtdev.telegram.methods.*; +import hdvtdev.telegram.objects.*; +import hdvtdev.telegram.util.ClassFinder; + +import java.util.Arrays; +import java.util.List; + + +public class Main { + + private static String apiKey; + + private static long idd = 2027845508; + + public static TelegramBot bot; + + @TextMessageHandler("пинг") + private static void ping(Message message) { + bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing()))); + } + + public static void main(String[] args) throws Exception { + + bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build(); + bot.enableDefaultUpdateConsumer(); + + apiKey = args[2]; + } + + + + private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler { + + @Override + public void onError(Throwable throwable) { + throwable.printStackTrace(); + } + + + @Override + public void getUpdates(List updates) { + updates.forEach(System.out::println); + } + } + + +} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java b/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java new file mode 100644 index 0000000..68e13e4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java @@ -0,0 +1,58 @@ +package hdvtdev.telegram.annotations.handlers; + +import hdvtdev.telegram.objects.CallbackQuery; +import hdvtdev.telegram.objects.Update; + +import org.jetbrains.annotations.NotNull; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a static method as a handler for {@link CallbackQuery} updates with specific data values. + *

+ * If {@code value} is set to "*", the method will handle all {@link CallbackQuery} data, + * and other {@code @CallbackQueryHandler} methods will be ignored. + *

+ * The annotated method must be {@code static} and may accept: + *

    + *
  • {@link Void} {@code (no params)}
  • + *
  • {@link Update}
  • + *
  • {@link CallbackQuery}
  • + *
+ * Only one parameter is allowed. + *

+ * You do not need to call {@link CallbackQuery#hasData()} or {@link Update#hasCallbackQuery()}, + * as these checks are performed automatically before invocation. + * + *

Usage example:

+ *

+ * {@code @CallbackQueryHandler({"stop",}  "shutdown"})
+ * private static void stop(CallbackQuery callbackQuery) {
+ *     long id = callbackQuery.message.chatId;
+ *     if (DatabaseManager.isAdmin(id)) {
+ *         bot.awaitExecute(new SendMessage(id, "Shutting down..."));
+ *         System.exit(0);
+ *     }
+ * }
+ * 
+ *
Last documentation update: 2025-04-05
+ * @see Update + * @see CallbackQuery + * @since 1.0.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface CallbackQueryHandler { + /** + * Values to match against {@link CallbackQuery#data()}. + * If set to "*", this method will handle all {@link CallbackQuery} updates, + * overriding any other {@code @CallbackQueryHandler} annotations. + * + * @return array of matching strings + */ + @NotNull String[] value() default "*"; +} + diff --git a/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java b/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java new file mode 100644 index 0000000..89837b8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java @@ -0,0 +1,61 @@ +package hdvtdev.telegram.annotations.handlers; + +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.Update; + +import org.jetbrains.annotations.NotNull; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marks a static method as a handler for {@link Message} updates with specific data values. + *

+ * If {@code value} is set to "*", the method will handle all {@link Message} text, + * and other {@code @TextMessageHandler} methods will be ignored. + *

+ * The annotated method must be {@code static} and may accept: + *

    + *
  • {@link Void} {@code (no params)}
  • + *
  • {@link Update}
  • + *
  • {@link Message}
  • + *
+ * Only one parameter is allowed. + *

+ * You do not need to call {@link Message#hasText()} or {@link Update#hasMessage()}, + * as these checks are performed automatically before invocation. + * + *

Usage example:

+ *

+ * {@code @TextMessageHandler}({"rock", "paper", "scissors"})
+ * private static void cheaterRockPaperScissors(Message message) {
+ *     bot.execute(new SendMessage(message.chatId(), switch(message.text()) {
+ *         case "rock" -> "paper";
+ *         case "paper" -> "scissors";
+ *         default -> "rock";
+ *     }));
+ *
+ * {@code @TextMessageHandler}("/ping")
+ * private static void ping(Message message) {
+ *     bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing())));
+ * }
+ * 
+ *
Last documentation update: 2025-04-05
+ * @see Update + * @see Message + * @since 1.0.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface TextMessageHandler { + /** + * Values to match against {@link Message#text()}. + * If set to "*", this method will handle all {@link Message} updates, + * overriding any other {@code @TextMessageHandler} annotations. + * + * @return array of matching strings + */ + @NotNull String[] value() default "*"; +} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java b/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java new file mode 100644 index 0000000..d4bf8fa --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.annotations.util; + +import hdvtdev.telegram.methods.TelegramApiMethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation is used to indicate {@link TelegramApiMethod} that should be serialized into JSON. + *
Last documentation update: 2025-04-05
+ * @see com.fasterxml.jackson.databind.ObjectMapper + * @since 1.0.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Jsonable { +} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java b/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java new file mode 100644 index 0000000..4f75c06 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.annotations.util; + +import hdvtdev.telegram.methods.TelegramApiMethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation is used to indicate {@link TelegramApiMethod} that is not tested, usually used if the method was created recently. + * @since 1.0.0 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.SOURCE) +public @interface NotTested { + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java b/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java new file mode 100644 index 0000000..0f70fa3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java @@ -0,0 +1,7 @@ +package hdvtdev.telegram.core.objects; + +import java.lang.reflect.Method; + +public record InvokeMethod(Method method, Class parameterType) { + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/Main.java b/core/src/main/java/hdvtdev/telegram/core/Main.java new file mode 100644 index 0000000..d3da0f0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/Main.java @@ -0,0 +1,52 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.handlers.TextMessageHandler; +import hdvtdev.telegram.longpolling +import hdvtdev.telegram.core.TelegramBot; +import hdvtdev.telegram.core.UpdateConsumer; +import hdvtdev.telegram.methods.*; +import hdvtdev.telegram.objects.*; +import hdvtdev.telegram.util.ClassFinder; + +import java.util.List; + + +public class Main { + + private static String apiKey; + + private static long idd = 2027845508; + + public static TelegramBot bot; + + @TextMessageHandler("пинг") + private static void ping(Message message) { + bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing()))); + } + + public static void main(String[] args) throws Exception { + + bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build(); + bot.enableDefaultUpdateConsumer(); + + apiKey = args[2]; + } + + + + private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler { + + @Override + public void onError(Throwable throwable) { + throwable.printStackTrace(); + } + + + @Override + public void getUpdates(List updates) { + updates.forEach(System.out::println); + } + } + + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java new file mode 100644 index 0000000..a32029e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java @@ -0,0 +1,45 @@ +package hdvtdev.telegram.core.bot; + +import hdvtdev.telegram.exceptions.TelegramApiException; +import hdvtdev.telegram.exceptions.TelegramApiNetworkException; +import hdvtdev.telegram.exceptions.TelegramMethodParsingException; +import hdvtdev.telegram.methods.TelegramApiMethod; +import hdvtdev.telegram.objects.TelegramFile; + +import java.io.File; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.nio.file.Path; +import java.util.concurrent.CompletableFuture; + +public interface TelegramBot { + + T awaitExecute(TelegramApiMethod telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException; + + File awaitDownloadFile(TelegramFile telegramFile, Path targetDirectory); + + default CompletableFuture downloadFile(TelegramFile telegramFile, Path targetDirectory) throws TelegramApiException, TelegramApiNetworkException { + return CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory)); + } + + default CompletableFuture execute(TelegramApiMethod telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException { + return CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod)); + } + + default int getPing() throws TelegramApiNetworkException { + URI uri = URI.create("https://api.telegram.org"); + long startTime = System.currentTimeMillis(); + try { + HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection(); + connection.setRequestMethod("GET"); + connection.setConnectTimeout(15000); + connection.connect(); + } catch (IOException e) { + throw new TelegramApiNetworkException(e); + } + + return (int) (System.currentTimeMillis() - startTime); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java new file mode 100644 index 0000000..2348807 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java @@ -0,0 +1,11 @@ +package hdvtdev.telegram.core.bot; + +import hdvtdev.telegram.core.objects.Update; + +import java.util.List; + +public interface UpdateConsumer { + + void getUpdates(List updates); + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/UserState.java b/core/src/main/java/hdvtdev/telegram/core/UserState.java new file mode 100644 index 0000000..3008cd7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/UserState.java @@ -0,0 +1,4 @@ +package hdvtdev.telegram.core.bot; + +public interface UserState { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/annotaions/Jsonable.java b/core/src/main/java/hdvtdev/telegram/core/annotaions/Jsonable.java new file mode 100644 index 0000000..835b973 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/annotaions/Jsonable.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.core.annotaions; + +import hdvtdev.telegram.core.methods.TelegramApiMethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation is used to indicate {@link TelegramApiMethod} that should be serialized into JSON. + *
Last documentation update: 2025-04-05
+ * @see com.fasterxml.jackson.databind.ObjectMapper + * @since 1.0.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Jsonable { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java new file mode 100644 index 0000000..4808610 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java @@ -0,0 +1,30 @@ +package hdvtdev.telegram.exceptions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class TelegramApiException extends IllegalArgumentException { + + public TelegramApiException(String message) { + super(message); + } + + public TelegramApiException() { + super(); + } + + public TelegramApiException(ErrorResponse errorResponse) { + super(errorResponse.description); + } + + public TelegramApiException(Throwable throwable) { + super(throwable); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public record ErrorResponse(boolean ok, @JsonProperty("error_code") int errorCode, String description) { + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java new file mode 100644 index 0000000..8ee9c6a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.exceptions; + +import java.io.IOException; + +public class TelegramApiNetworkException extends RuntimeException { + public TelegramApiNetworkException(String message) { + super(message); + } + + public TelegramApiNetworkException(IOException e) { + super(e); + } + + public TelegramApiNetworkException(String s, IOException e) { + super(s, e); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java new file mode 100644 index 0000000..cad5c01 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java @@ -0,0 +1,11 @@ +package hdvtdev.telegram.exceptions; + +public class TelegramMethodParsingException extends RuntimeException { + public TelegramMethodParsingException(String message) { + super(message); + } + + public TelegramMethodParsingException(Throwable throwable) { + super(throwable); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java new file mode 100644 index 0000000..13b9a17 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java @@ -0,0 +1,113 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Game; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to send answers to callback queries sent from inline keyboards. + * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. + * Alternatively, the user can be redirected to the specified {@link Game} URL. + * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote On success, {@code Boolean == true} is returned. + * @since 1.0.0 + */ + +@NotTested +public class AnswerCallbackQuery implements TelegramApiMethod { + + /** + * Unique identifier for the query to be answered + */ + private final String callbackQueryId; + /** + * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters + */ + private String text; + /** + * If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. + */ + private Boolean showAlert; + /** + * URL that will be opened by the user's client. + * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. + * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote this will only work if the query comes from a callback_game button. + */ + private String url; + /** + * The maximum amount of time in seconds that the result of the callback query may be cached client-side. + * Telegram apps will support caching starting in version 3.14. Defaults to 0. + */ + private Integer cacheTime; + + public AnswerCallbackQuery(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + private AnswerCallbackQuery(Builder builder) { + callbackQueryId = builder.callbackQueryId; + text = builder.text; + showAlert = builder.showAlert; + url = builder.url; + cacheTime = builder.cacheTime; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); + if (text != null) builder.add("text", this.text); + if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); + if (url != null) builder.add("url", this.url); + if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "answerCallbackQuery"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String callbackQueryId; + private String text; + private Boolean showAlert; + private String url; + private Integer cacheTime; + + public Builder(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + public Builder text(String text) { + this.text = text; + return this; + } + + public Builder showAlert(Boolean showAlert) { + this.showAlert = showAlert; + return this; + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder cacheTime(Integer cacheTime) { + this.cacheTime = cacheTime; + return this; + } + + public AnswerCallbackQuery build() { + return new AnswerCallbackQuery(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java new file mode 100644 index 0000000..7338266 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java @@ -0,0 +1,51 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.Chat; +import hdvtdev.telegram.objects.User; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to approve a chat join request. + * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. + * Returns True on success. + * @param chatId Unique username of the target channel in the format @channelusername + * @param userId Unique identifier of the target user + * @see ChatAdministratorRights + * @see Chat + * @see Chat#id() + * @since 0.1.0 + */ +@NotTested +public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { + + /** + * @param chatId Unique identifier for the target chat + * @param userId Unique identifier of the target user + * @see User#id() + * @see Chat#id() + */ + public ApproveChatJoinRequest(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "approveChatJoinRequest"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java new file mode 100644 index 0000000..17622c3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java @@ -0,0 +1,110 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to ban a user in a group, a supergroup or a channel. + * In the case of supergroups and channels, the user will not be able to return + * to the chat on their own using invite links, etc., unless unbanned first. + * The bot must be an administrator in the chat for this to work and must have + * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. + * @see ChatAdministratorRights + * @since 0.1.1 + */ +@NotTested +public final class BanChatMember implements TelegramApiMethod { + + /** + * Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) + */ + private final String chatId; + /** + * Unique identifier of the target user + */ + private final long userId; + /** + * Date when the user will be unbanned; Unix time. + * If user is banned for more than 366 days or less than 30 seconds from + * the current time they are considered to be banned forever. + * Applied for supergroups and channels only. + */ + private Long untilDate; + /** + * Pass true to delete all messages from the chat for the user that is being removed. + * If false, the user will be able to see messages in the group that were sent before the user was removed. + * Always True for supergroups and channels. + */ + private Boolean revokeMessages; + + public BanChatMember(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public BanChatMember(long chatId, long userId) { + this.chatId = String.valueOf(chatId); + this.userId = userId; + } + + private BanChatMember(Builder builder) { + chatId = builder.chatId; + userId = builder.userId; + setUntilDate(builder.untilDate); + setRevokeMessages(builder.revokeMessages); + } + + public void setUntilDate(Long untilDate) { + this.untilDate = untilDate; + } + + public void setRevokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); + if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); + if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "banChatMember"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long userId; + private Long untilDate; + private Boolean revokeMessages; + + public Builder(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public Builder untilDate(Long untilDate) { + this.untilDate = untilDate; + return this; + } + + public Builder revokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + return this; + } + + public BanChatMember build() { + return new BanChatMember(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java new file mode 100644 index 0000000..323e677 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to ban a channel chat in a supergroup or a channel. + * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of + * their channels. The bot must be an administrator in the supergroup or channel for this to + * work and must have the appropriate administrator rights. Returns True on success. + * @since 1.0.0 + */ +@NotTested +public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public BanChatSenderChat(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "banChatSenderChat"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java new file mode 100644 index 0000000..debe5e5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, + * unless it is the creator of the topic. Returns {@code true} on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @see ChatAdministratorRights#canManageTopics() + */ +@NotTested +public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { + + public CloseForumTopic(long chatId, long messageThreadId) { + this(String.valueOf(chatId), messageThreadId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); + } + + @Override + public String getMethodName() { + return "closeForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java new file mode 100644 index 0000000..2d2ed8e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open 'General' topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. + * Returns {@code true} on success. + * @see ChatAdministratorRights#canManageTopics() + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + */ +@NotTested +public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { + + public CloseGeneralForumTopic(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "closeGeneralForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java new file mode 100644 index 0000000..a910879 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java @@ -0,0 +1,244 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.MessageEntity; +import hdvtdev.telegram.objects.Poll; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. + * Returns the messageId as {@link Long} of the sent message on success. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@NotTested +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + @JsonProperty("caption") + private String caption; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("caption_entities") + private List captionEntities; + @JsonProperty("show_caption_above_media") + private Boolean showCaptionAboveMedia; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public CopyMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public CopyMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public CopyMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + public CopyMessage(String chatId, long fromChatId, long messageId) { + this(chatId, String.valueOf(fromChatId), messageId); + } + + private CopyMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setVideoStartTimestamp(builder.videoStartTimestamp); + setCaption(builder.caption); + setParseMode(builder.parseMode); + setCaptionEntities(builder.captionEntities); + setShowCaptionAboveMedia(builder.showCaptionAboveMedia); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + public void setCaption(String caption) { + this.caption = caption; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setCaptionEntities(List captionEntities) { + this.captionEntities = captionEntities; + } + + public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private long videoStartTimestamp; + private String caption; + private ParseMode parseMode; + private List captionEntities; + private Boolean showCaptionAboveMedia; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public Builder caption(String caption) { + this.caption = caption; + return this; + } + + public Builder parseMode(ParseMode parseMode) { + this.parseMode = parseMode; + return this; + } + + public Builder captionEntities(List captionEntities) { + this.captionEntities = captionEntities; + return this; + } + + public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + return this; + } + + public Builder replyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + return this; + } + + public Builder replyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + return this; + } + + public CopyMessage build() { + return new CopyMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java new file mode 100644 index 0000000..b5bc081 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java @@ -0,0 +1,181 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Poll; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * If some of the specified messages can't be found or copied, they are skipped. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. + * Album grouping is kept for copied messages. + * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("remove_caption") + private Boolean removeCaption; + + /** + * @param chatId Username of the target channel (in the format @channelusername) + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Unique identifier for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + /** + * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param fromChatId Unique identifier for the target chat + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + private CopyMessages(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setRemoveCaption(builder.removeCaption); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setRemoveCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean removeCaption; + + public Builder(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder removeCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + return this; + } + + public CopyMessages build() { + return new CopyMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java new file mode 100644 index 0000000..45bcd68 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java @@ -0,0 +1,114 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to create an additional invite link for a chat. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. + * @see ChatAdministratorRights#canInviteUsers() + */ +public final class CreateChatInviteLink implements TelegramApiMethod { + + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public CreateChatInviteLink(String chatId) { + this.chatId = chatId; + } + + public CreateChatInviteLink(long chatId) { + this(String.valueOf(chatId)); + } + + private CreateChatInviteLink(Builder builder) { + chatId = builder.chatId; + setName(builder.name); + setExpireDate(builder.expireDate); + setMemberLimit(builder.memberLimit); + setCreatesJoinRequest(builder.createsJoinRequest); + } + + public void setName(String name) { + this.name = name; + } + + public void setExpireDate(Long expireDate) { + this.expireDate = expireDate; + } + + public void setMemberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + } + + public void setCreatesJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + } + + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId); + if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate)); + if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit)); + if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "createChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } + + public static final class Builder { + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public Builder(String chatId) { + this.chatId = chatId; + } + + public Builder(long chatId) { + this(String.valueOf(chatId)); + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder expireDate(Long expireDate) { + this.expireDate = expireDate; + return this; + } + + public Builder memberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + return this; + } + + public Builder createsJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + return this; + } + + public CreateChatInviteLink build() { + return new CreateChatInviteLink(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessage.java b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessage.java new file mode 100644 index 0000000..f6bb9d1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessage.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +/** + * Use this method to forward messages of any kind. + * Service messages and messages with protected content can't be forwarded. + * On success, the sent {@link Message} is returned. + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + + public ForwardMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public ForwardMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public ForwardMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + private ForwardMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setVideoStartTimestamp(builder.videoStartTimestamp); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private Boolean disableNotification; + private Boolean protectContent; + private long videoStartTimestamp; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public ForwardMessage build() { + return new ForwardMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java new file mode 100644 index 0000000..7ff9110 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java @@ -0,0 +1,147 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. + * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. + * On success, an array of MessageId as {@link Long} of the sent messages is returned. + * @see Message#hasProtectedContent() + */ +@Jsonable +@NotTested +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + + public ForwardMessages(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public ForwardMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public ForwardMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public ForwardMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + private ForwardMessages(Builder builder) { + chatId = builder.chatId; + messageThreadId = builder.messageThreadId; + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + disableNotification = builder.disableNotification; + protectContent = builder.protectContent; + } + + public void setMessageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(boolean protectContent) { + this.protectContent = protectContent; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + + public Builder(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public ForwardMessages build() { + return new ForwardMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java new file mode 100644 index 0000000..8a0ad7a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java @@ -0,0 +1,36 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. + * @param chatId + */ +@NotTested +public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { + + public GetChatAdministrators(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "getChatAdministrators"; + } + + @Override + public Class getResponseClass() { + return ChatMember[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java new file mode 100644 index 0000000..1c0065c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public GetChatMember(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + public GetChatMember(String chatId, String userId) { + this(chatId, Long.parseLong(userId)); + } + + public GetChatMember(long chatId, String userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "getChatMember"; + } + + @Override + public Class getResponseClass() { + return ChatMember.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java new file mode 100644 index 0000000..96bfbd5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java @@ -0,0 +1,23 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.TelegramFile; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record GetFile(String fileId) implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("file_id", fileId).build(); + } + + @Override + public String getMethodName() { + return "getFile"; + } + + @Override + public Class getResponseClass() { + return TelegramFile.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java new file mode 100644 index 0000000..cfe2819 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.User; +import okhttp3.RequestBody; + +public final class GetMe implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + return "getMe"; + } + + @Override + public Class getResponseClass() { + return User.Bot.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java new file mode 100644 index 0000000..aebee4d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java @@ -0,0 +1,58 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; + +import okhttp3.RequestBody; + +/** + * Use this method to get the current list of the bot's commands for the given scope and user language. + * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. + * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. + * @param languageCode A two-letter ISO 639-1 language code or an empty string + * @see BotCommandScope + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public record GetMyCommands( + @JsonProperty("scope") BotCommandScope scope, + @JsonProperty("language_code") String languageCode +) implements TelegramApiMethod { + + public GetMyCommands() { + this(null, null); + } + + public GetMyCommands(String languageCode) { + this(null, languageCode); + } + + public GetMyCommands(BotCommandScope scope) { + this(scope, null); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "getMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return BotCommand[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java new file mode 100644 index 0000000..a351910 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetMyDescription(String languageCode) implements TelegramApiMethod { + + public GetMyDescription() { + this(null); + } + + @Override + public RequestBody getBody() { + return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyDescription"; + } + + @Override + public Class getResponseClass() { + return BotDescription.class; + } + + public record BotDescription(String description) { + @NotNull + @Override + public String toString() { + return description; + } + + public boolean isEmpty() { + return description.isEmpty(); + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java new file mode 100644 index 0000000..af83b33 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; +import org.jetbrains.annotations.NotNull; + +public record GetMyName(String languageCode) implements TelegramApiMethod { + + public GetMyName() { + this(null); + } + + @Override + public RequestBody getBody() { + return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyName"; + } + + @Override + public Class getResponseClass() { + return BotName.class; + } + + public record BotName(String name) { + + @NotNull + @Override + public String toString() { + return this.name; + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetUpdates.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetUpdates.java new file mode 100644 index 0000000..2f12900 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetUpdates.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.core.objects; + + +import hdvtdev.telegram.objects.Update; +import okhttp3.RequestBody; + +import java.util.ArrayList; + +public record GetUpdates( + Long offset, + Integer limit, + Integer timeout +) implements TelegramApiMethod { + + public GetUpdates() { + this(null, null, null); + } + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + ArrayList params = new ArrayList<>(3); + if (offset != null) params.add("offset=" + offset); + if (limit != null) params.add("limit=" + limit); + if (timeout != null) params.add("timeout=" + timeout); + + if (params.isEmpty()) { + return "getUpdates"; + } else { + return "getUpdates?" + String.join("&", params); + } + } + + @Override + public Class getResponseClass() { + return Update[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/RevokeChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/methods/RevokeChatInviteLink.java new file mode 100644 index 0000000..f3324f2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/RevokeChatInviteLink.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * Returns the revoked invite link as {@link ChatInviteLink} object. + * @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername) + * @param link The invite link to revoke + */ +public record RevokeChatInviteLink(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod { + + public RevokeChatInviteLink(long chatId, @NotNull String link) { + this(String.valueOf(chatId), link); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); + } + + @Override + public String getMethodName() { + return "revokeChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java new file mode 100644 index 0000000..9f59abd --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java @@ -0,0 +1,104 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class SendChatAction implements TelegramApiMethod { + + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { + this.businessConnectionId = businessConnectionId; + this.chatId = chatId; + this.messageThreadId = messageThreadId; + this.chatAction = chatAction; + } + + public SendChatAction(String chatId, ChatAction chatAction) { + this(null, chatId, null, chatAction); + } + + public SendChatAction(long chatId, ChatAction chatAction) { + this(String.valueOf(chatId), chatAction); + } + + private SendChatAction(Builder builder) { + this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction); + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + @Override + public RequestBody getBody() { + + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); + + if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); + if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); + + return builder.build(); + } + + @Override + public String getMethodName() { + return "sendChatAction"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public enum ChatAction { + TYPING, + UPLOAD_PHOTO, + RECORD_VIDEO, + UPLOAD_VIDEO, + RECORD_VOICE, + UPLOAD_VOICE, + UPLOAD_DOCUMENT, + UPLOAD_FILE, + CHOOSE_STICKER, + FIND_LOCATION, + RECORD_VIDEO_NOTE, + UPLOAD_VIDEO_NOTE + } + + public static final class Builder { + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public Builder(String chatId, ChatAction chatAction) { + this.chatId = chatId; + this.chatAction = chatAction; + } + + public Builder businessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + return this; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public SendChatAction build() { + return new SendChatAction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java new file mode 100644 index 0000000..3bb16dc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendDice implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("emoji") + private String emoji; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public SendDice(String chatId) { + this.chatId = chatId; + } + + public SendDice(long chatId) { + this(String.valueOf(chatId)); + } + + public SendDice(String chatId, Emoji emoji) { + this.emoji = emoji.getEmoji(); + this.chatId = chatId; + } + + public SendDice(long chatId, Emoji emoji) { + this(String.valueOf(chatId), emoji); + } + + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setEmoji(Emoji emoji) { + this.emoji = emoji.getEmoji(); + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendDice"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public enum Emoji { + DICE("🎲"), + DART("🎯"), + BASKETBALL("🏀"), + FOOTBALL("⚽"), + BOWLING("🎳"), + SLOT_MACHINE("🎰"); + + private final String emoji; + + Emoji(String emoji) { + this.emoji = emoji; + } + + public String getEmoji() { + return emoji; + } + + } + + + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java new file mode 100644 index 0000000..6187da7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java @@ -0,0 +1,226 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.*; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("text") + private final String text; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("entities") + private MessageEntity[] entities; + @JsonProperty("link_preview_options") + private LinkPreviewOptions linkPreviewOptions; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + private SendMessage(Builder builder) { + chatId = builder.chatId; + text = builder.text; + setBusinessConnectionId(builder.businessConnectionId); + setMessageThreadId(builder.messageThreadId); + setParseMode(builder.parseMode); + setEntities(builder.entities); + setLinkPreviewOptions(builder.linkPreviewOptions); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setMessageEffectId(builder.messageEffectId); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + this.linkPreviewOptions = linkPreviewOptions; + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setEntities(MessageEntity[] entities) { + this.entities = entities; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyToMessage(long messageId) { + this.replyParameters = new ReplyParameters(messageId, chatId); + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + public SendMessage(String chatId, String text) { + if (chatId.isEmpty() || text.isEmpty()) + throw new IllegalArgumentException("chatId or/and message (text) cannot be empty."); + this.chatId = chatId; + this.text = text; + } + + public SendMessage(long chatIdAsLong, String text) { + this(String.valueOf(chatIdAsLong), text); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private final String text; + private String businessConnectionId; + private Long messageThreadId; + private ParseMode parseMode; + private MessageEntity[] entities; + private LinkPreviewOptions linkPreviewOptions; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private String messageEffectId; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(long chatId, String text) { + this(String.valueOf(chatId), text); + } + + public Builder(String chatId, String text) { + this.chatId = chatId; + this.text = text; + } + + public Builder businessConnectionId(String val) { + businessConnectionId = val; + return this; + } + + public Builder messageThreadId(Long val) { + messageThreadId = val; + return this; + } + + public Builder parseMode(ParseMode val) { + parseMode = val; + return this; + } + + public Builder entities(MessageEntity[] val) { + entities = val; + return this; + } + + public Builder linkPreviewOptions(LinkPreviewOptions val) { + linkPreviewOptions = val; + return this; + } + + public Builder disableNotification() { + disableNotification = true; + return this; + } + + public Builder protectContent() { + protectContent = true; + return this; + } + + public Builder allowPaidBroadcast() { + allowPaidBroadcast = true; + return this; + } + + public Builder messageEffectId(String val) { + messageEffectId = val; + return this; + } + + public Builder replyParameters(ReplyParameters val) { + replyParameters = val; + return this; + } + + public Builder replyToMessage(long val) { + replyParameters = new ReplyParameters(val, this.chatId); + return this; + } + + public Builder replyMarkup(ReplyMarkup val) { + replyMarkup = val; + return this; + } + + public SendMessage build() { + return new SendMessage(this); + } + } +} + diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java new file mode 100644 index 0000000..3aecda3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.ReactionType; + +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SetMessageReaction implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("reaction") + private List reactions; + @JsonProperty("is_big") + private Boolean isBig; + + public SetMessageReaction(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public SetMessageReaction(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + private SetMessageReaction(Builder builder) { + chatId = builder.chatId; + messageId = builder.messageId; + setReactions(builder.reactions); + isBig = builder.isBig; + } + + public void setReactions(List reactions) { + this.reactions = reactions; + } + + public void setBig(Boolean big) { + isBig = big; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMessageReaction"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long messageId; + private List reactions; + private Boolean isBig; + + public Builder(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public Builder(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + public Builder reactions(List reactions) { + this.reactions = reactions; + return this; + } + + public Builder isBig(Boolean isBig) { + this.isBig = isBig; + return this; + } + + public SetMessageReaction build() { + return new SetMessageReaction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java new file mode 100644 index 0000000..8dac79a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SetMyCommands implements TelegramApiMethod { + + @JsonProperty("commands") + private final List commands; + @JsonProperty("scope") + private Object scope; + @JsonProperty("language_code") + private String languageCode; + + public SetMyCommands(List commands, Object scope, String languageCode) { + this.commands = commands; + this.scope = scope; + this.languageCode = languageCode; + } + + public SetMyCommands(BotCommand... commands) { + this.commands = List.of(commands); + } + + public SetMyCommands(List commands) { + this.commands = commands; + } + + private SetMyCommands(Builder builder) { + commands = builder.commands; + setScope(builder.scope); + setLanguageCode(builder.languageCode); + } + + public void setScope(Object scope) { + this.scope = scope; + } + + public void setLanguageCode(String languageCode) { + this.languageCode = languageCode; + } + + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + + public static final class Builder { + private final List commands; + private Object scope; + private String languageCode; + + public Builder(List commands) { + this.commands = commands; + } + + public Builder(BotCommand... commands) { + this.commands = List.of(commands); + } + + public Builder scope(BotCommandScope scope) { + this.scope = scope; + return this; + } + + public Builder languageCode(String languageCode) { + this.languageCode = languageCode; + return this; + } + + public SetMyCommands build() { + return new SetMyCommands(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java new file mode 100644 index 0000000..2dc5c26 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java @@ -0,0 +1,41 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. + * Returns {@code true} on success. + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. + */ +public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { + + public SetMyDescription() { + this(null, null); + } + + public SetMyDescription(String description) { + this(description, null); + } + + @Override + public RequestBody getBody() { + if (description == null) { + return null; + } + FormBody.Builder builder = new FormBody.Builder().add("description", description); + if (languageCode != null) builder.add("language_code", languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyDescription"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java new file mode 100644 index 0000000..fb7eff3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record SetMyName(String name, String languageCode) implements TelegramApiMethod { + + public SetMyName(String name) { + this(name, null); + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("name", this.name); + if (languageCode != null) builder.add("language_code", this.languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyName"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java new file mode 100644 index 0000000..1035ba3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.RequestBody; + +public interface TelegramApiMethod { + + RequestBody getBody(); + + String getMethodName(); + + Class getResponseClass(); + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java new file mode 100644 index 0000000..3f65f96 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java @@ -0,0 +1,31 @@ +package hdvtdev.telegram.core.bot; + +import java.util.ArrayList; +import java.util.function.Consumer; + +public final class TelegramApiMethodBody { + + private final ArrayList elements; + + public TelegramApiMethodBody(int size) { + elements = new ArrayList<>(size); + } + + public TelegramApiMethodBody() { + elements = new ArrayList<>(); + } + + public void add(String name, String value) { + if (value != null) this.elements.add(new Element(name, value)); + } + + public void forEach(Consumer action) { + this.elements.forEach(action); + } + + public record Element(String name, String value) { + + } + +} + diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java b/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java new file mode 100644 index 0000000..5ceaa73 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java @@ -0,0 +1,7 @@ +package hdvtdev.telegram.core; + +public enum ParseMode { + MARKDOWN, + MARKDOWNV2, + HTML +} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java b/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java new file mode 100644 index 0000000..d955f77 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java @@ -0,0 +1,98 @@ +package hdvtdev.telegram.core; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public class Util { + + public static void pretty(Path filePath) { + try { + if (filePath.toString().contains("InlineKeyboard")) return; + List lines = Files.readAllLines(filePath); + HashSet linesSet = new HashSet<>(lines); + ArrayList res = new ArrayList<>(lines.size()); + + if (!linesSet.contains("import com.fasterxml.jackson.annotation.JsonProperty;")) + lines.add(2, "import com.fasterxml.jackson.annotation.JsonProperty;"); + boolean inRecord = false; + for (String line : lines) { + if (line.contains("@JsonProperty\\(.*?\\)")) { + res.add(line); + continue; + } + if (!line.contains("@") && !line.contains("class") && !line.contains("=")) { + if (line.contains("record")) { + String bufferLine = line; + if (bufferLine.replaceAll("[{}]", "").trim().endsWith(")")) { + if (bufferLine.contains("()")) { + res.add(line); + continue; + } + bufferLine = bufferLine.split("\\(", 2)[1]; + bufferLine = bufferLine.split("\\)", 2)[0]; + + if (bufferLine.contains(",")) { + for (String element : bufferLine.split(",")) { + element = element.strip(); + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); + line = line.replace(element, ann); + } + } else { + String element = bufferLine.strip(); + if (element.isEmpty()) continue; + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); + line = line.replace(element, ann); + } + } else { + inRecord = true; + res.add(line); + continue; + } + } + if (inRecord) { + if (line.contains("{") && line.contains(")")) { + inRecord = false; + } else { + if (line.isEmpty() || line.contains("}")) { + res.add(line); + continue; + } + String element = line.strip(); + if (element.isEmpty()) continue; + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1].replace(",", ""), element); + line = line.replace(element, ann); + } + } + + } + res.add(line); + } + BufferedWriter writer = new BufferedWriter(new FileWriter(filePath.toFile())); + for (String s : res) { + writer.write(s); + writer.newLine(); + } + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void date() { + LocalDate today = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; // формат ГГГГ-ММ-ДД + + String formattedDate = today.format(formatter); + System.out.println(formattedDate); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java new file mode 100644 index 0000000..13b9a17 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java @@ -0,0 +1,113 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Game; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to send answers to callback queries sent from inline keyboards. + * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. + * Alternatively, the user can be redirected to the specified {@link Game} URL. + * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote On success, {@code Boolean == true} is returned. + * @since 1.0.0 + */ + +@NotTested +public class AnswerCallbackQuery implements TelegramApiMethod { + + /** + * Unique identifier for the query to be answered + */ + private final String callbackQueryId; + /** + * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters + */ + private String text; + /** + * If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. + */ + private Boolean showAlert; + /** + * URL that will be opened by the user's client. + * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. + * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote this will only work if the query comes from a callback_game button. + */ + private String url; + /** + * The maximum amount of time in seconds that the result of the callback query may be cached client-side. + * Telegram apps will support caching starting in version 3.14. Defaults to 0. + */ + private Integer cacheTime; + + public AnswerCallbackQuery(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + private AnswerCallbackQuery(Builder builder) { + callbackQueryId = builder.callbackQueryId; + text = builder.text; + showAlert = builder.showAlert; + url = builder.url; + cacheTime = builder.cacheTime; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); + if (text != null) builder.add("text", this.text); + if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); + if (url != null) builder.add("url", this.url); + if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "answerCallbackQuery"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String callbackQueryId; + private String text; + private Boolean showAlert; + private String url; + private Integer cacheTime; + + public Builder(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + public Builder text(String text) { + this.text = text; + return this; + } + + public Builder showAlert(Boolean showAlert) { + this.showAlert = showAlert; + return this; + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder cacheTime(Integer cacheTime) { + this.cacheTime = cacheTime; + return this; + } + + public AnswerCallbackQuery build() { + return new AnswerCallbackQuery(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java new file mode 100644 index 0000000..7338266 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java @@ -0,0 +1,51 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.Chat; +import hdvtdev.telegram.objects.User; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to approve a chat join request. + * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. + * Returns True on success. + * @param chatId Unique username of the target channel in the format @channelusername + * @param userId Unique identifier of the target user + * @see ChatAdministratorRights + * @see Chat + * @see Chat#id() + * @since 0.1.0 + */ +@NotTested +public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { + + /** + * @param chatId Unique identifier for the target chat + * @param userId Unique identifier of the target user + * @see User#id() + * @see Chat#id() + */ + public ApproveChatJoinRequest(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "approveChatJoinRequest"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java new file mode 100644 index 0000000..17622c3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java @@ -0,0 +1,110 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to ban a user in a group, a supergroup or a channel. + * In the case of supergroups and channels, the user will not be able to return + * to the chat on their own using invite links, etc., unless unbanned first. + * The bot must be an administrator in the chat for this to work and must have + * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. + * @see ChatAdministratorRights + * @since 0.1.1 + */ +@NotTested +public final class BanChatMember implements TelegramApiMethod { + + /** + * Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) + */ + private final String chatId; + /** + * Unique identifier of the target user + */ + private final long userId; + /** + * Date when the user will be unbanned; Unix time. + * If user is banned for more than 366 days or less than 30 seconds from + * the current time they are considered to be banned forever. + * Applied for supergroups and channels only. + */ + private Long untilDate; + /** + * Pass true to delete all messages from the chat for the user that is being removed. + * If false, the user will be able to see messages in the group that were sent before the user was removed. + * Always True for supergroups and channels. + */ + private Boolean revokeMessages; + + public BanChatMember(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public BanChatMember(long chatId, long userId) { + this.chatId = String.valueOf(chatId); + this.userId = userId; + } + + private BanChatMember(Builder builder) { + chatId = builder.chatId; + userId = builder.userId; + setUntilDate(builder.untilDate); + setRevokeMessages(builder.revokeMessages); + } + + public void setUntilDate(Long untilDate) { + this.untilDate = untilDate; + } + + public void setRevokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); + if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); + if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "banChatMember"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long userId; + private Long untilDate; + private Boolean revokeMessages; + + public Builder(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public Builder untilDate(Long untilDate) { + this.untilDate = untilDate; + return this; + } + + public Builder revokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + return this; + } + + public BanChatMember build() { + return new BanChatMember(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java new file mode 100644 index 0000000..323e677 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to ban a channel chat in a supergroup or a channel. + * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of + * their channels. The bot must be an administrator in the supergroup or channel for this to + * work and must have the appropriate administrator rights. Returns True on success. + * @since 1.0.0 + */ +@NotTested +public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public BanChatSenderChat(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "banChatSenderChat"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ChosenInlineResult.java b/core/src/main/java/hdvtdev/telegram/core/objects/ChosenInlineResult.java new file mode 100644 index 0000000..97dfb43 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ChosenInlineResult.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChosenInlineResult( + @JsonProperty("result_id") String resultId, + @JsonProperty("from") User from, + @JsonProperty("location") Location location, + @JsonProperty("inline_message_id") String inlineMessageId, + @JsonProperty("query") String query +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java new file mode 100644 index 0000000..debe5e5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, + * unless it is the creator of the topic. Returns {@code true} on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @see ChatAdministratorRights#canManageTopics() + */ +@NotTested +public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { + + public CloseForumTopic(long chatId, long messageThreadId) { + this(String.valueOf(chatId), messageThreadId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); + } + + @Override + public String getMethodName() { + return "closeForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java new file mode 100644 index 0000000..2d2ed8e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open 'General' topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. + * Returns {@code true} on success. + * @see ChatAdministratorRights#canManageTopics() + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + */ +@NotTested +public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { + + public CloseGeneralForumTopic(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "closeGeneralForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Contact.java b/core/src/main/java/hdvtdev/telegram/core/objects/Contact.java new file mode 100644 index 0000000..36539bb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Contact.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Contact( + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("user_id") long userId, + @JsonProperty("vcard") String vcard +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java new file mode 100644 index 0000000..a910879 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java @@ -0,0 +1,244 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.MessageEntity; +import hdvtdev.telegram.objects.Poll; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. + * Returns the messageId as {@link Long} of the sent message on success. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@NotTested +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + @JsonProperty("caption") + private String caption; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("caption_entities") + private List captionEntities; + @JsonProperty("show_caption_above_media") + private Boolean showCaptionAboveMedia; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public CopyMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public CopyMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public CopyMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + public CopyMessage(String chatId, long fromChatId, long messageId) { + this(chatId, String.valueOf(fromChatId), messageId); + } + + private CopyMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setVideoStartTimestamp(builder.videoStartTimestamp); + setCaption(builder.caption); + setParseMode(builder.parseMode); + setCaptionEntities(builder.captionEntities); + setShowCaptionAboveMedia(builder.showCaptionAboveMedia); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + public void setCaption(String caption) { + this.caption = caption; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setCaptionEntities(List captionEntities) { + this.captionEntities = captionEntities; + } + + public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private long videoStartTimestamp; + private String caption; + private ParseMode parseMode; + private List captionEntities; + private Boolean showCaptionAboveMedia; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public Builder caption(String caption) { + this.caption = caption; + return this; + } + + public Builder parseMode(ParseMode parseMode) { + this.parseMode = parseMode; + return this; + } + + public Builder captionEntities(List captionEntities) { + this.captionEntities = captionEntities; + return this; + } + + public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + return this; + } + + public Builder replyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + return this; + } + + public Builder replyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + return this; + } + + public CopyMessage build() { + return new CopyMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java new file mode 100644 index 0000000..b5bc081 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java @@ -0,0 +1,181 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Poll; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * If some of the specified messages can't be found or copied, they are skipped. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. + * Album grouping is kept for copied messages. + * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("remove_caption") + private Boolean removeCaption; + + /** + * @param chatId Username of the target channel (in the format @channelusername) + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Unique identifier for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + /** + * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param fromChatId Unique identifier for the target chat + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + private CopyMessages(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setRemoveCaption(builder.removeCaption); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setRemoveCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean removeCaption; + + public Builder(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder removeCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + return this; + } + + public CopyMessages build() { + return new CopyMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java new file mode 100644 index 0000000..45bcd68 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java @@ -0,0 +1,114 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to create an additional invite link for a chat. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. + * @see ChatAdministratorRights#canInviteUsers() + */ +public final class CreateChatInviteLink implements TelegramApiMethod { + + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public CreateChatInviteLink(String chatId) { + this.chatId = chatId; + } + + public CreateChatInviteLink(long chatId) { + this(String.valueOf(chatId)); + } + + private CreateChatInviteLink(Builder builder) { + chatId = builder.chatId; + setName(builder.name); + setExpireDate(builder.expireDate); + setMemberLimit(builder.memberLimit); + setCreatesJoinRequest(builder.createsJoinRequest); + } + + public void setName(String name) { + this.name = name; + } + + public void setExpireDate(Long expireDate) { + this.expireDate = expireDate; + } + + public void setMemberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + } + + public void setCreatesJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + } + + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId); + if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate)); + if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit)); + if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "createChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } + + public static final class Builder { + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public Builder(String chatId) { + this.chatId = chatId; + } + + public Builder(long chatId) { + this(String.valueOf(chatId)); + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder expireDate(Long expireDate) { + this.expireDate = expireDate; + return this; + } + + public Builder memberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + return this; + } + + public Builder createsJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + return this; + } + + public CreateChatInviteLink build() { + return new CreateChatInviteLink(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Dice.java b/core/src/main/java/hdvtdev/telegram/core/objects/Dice.java new file mode 100644 index 0000000..4f3b25e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Dice.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Dice( + @JsonProperty("emoji") String emoji, + @JsonProperty("value") int value +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java new file mode 100644 index 0000000..f6bb9d1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +/** + * Use this method to forward messages of any kind. + * Service messages and messages with protected content can't be forwarded. + * On success, the sent {@link Message} is returned. + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + + public ForwardMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public ForwardMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public ForwardMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + private ForwardMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setVideoStartTimestamp(builder.videoStartTimestamp); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private Boolean disableNotification; + private Boolean protectContent; + private long videoStartTimestamp; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public ForwardMessage build() { + return new ForwardMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java new file mode 100644 index 0000000..7ff9110 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java @@ -0,0 +1,147 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. + * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. + * On success, an array of MessageId as {@link Long} of the sent messages is returned. + * @see Message#hasProtectedContent() + */ +@Jsonable +@NotTested +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + + public ForwardMessages(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public ForwardMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public ForwardMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public ForwardMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + private ForwardMessages(Builder builder) { + chatId = builder.chatId; + messageThreadId = builder.messageThreadId; + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + disableNotification = builder.disableNotification; + protectContent = builder.protectContent; + } + + public void setMessageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(boolean protectContent) { + this.protectContent = protectContent; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + + public Builder(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public ForwardMessages build() { + return new ForwardMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Game.java b/core/src/main/java/hdvtdev/telegram/core/objects/Game.java new file mode 100644 index 0000000..6019a26 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Game.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Game( + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("text") String text, + @JsonProperty("text_entities") MessageEntity[] textEntities, + @JsonProperty("animation") Animation animation +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java new file mode 100644 index 0000000..8a0ad7a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java @@ -0,0 +1,36 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. + * @param chatId + */ +@NotTested +public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { + + public GetChatAdministrators(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "getChatAdministrators"; + } + + @Override + public Class getResponseClass() { + return ChatMember[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java new file mode 100644 index 0000000..1c0065c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public GetChatMember(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + public GetChatMember(String chatId, String userId) { + this(chatId, Long.parseLong(userId)); + } + + public GetChatMember(long chatId, String userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "getChatMember"; + } + + @Override + public Class getResponseClass() { + return ChatMember.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java new file mode 100644 index 0000000..96bfbd5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java @@ -0,0 +1,23 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.TelegramFile; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record GetFile(String fileId) implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("file_id", fileId).build(); + } + + @Override + public String getMethodName() { + return "getFile"; + } + + @Override + public Class getResponseClass() { + return TelegramFile.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java new file mode 100644 index 0000000..cfe2819 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.User; +import okhttp3.RequestBody; + +public final class GetMe implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + return "getMe"; + } + + @Override + public Class getResponseClass() { + return User.Bot.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java new file mode 100644 index 0000000..aebee4d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java @@ -0,0 +1,58 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; + +import okhttp3.RequestBody; + +/** + * Use this method to get the current list of the bot's commands for the given scope and user language. + * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. + * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. + * @param languageCode A two-letter ISO 639-1 language code or an empty string + * @see BotCommandScope + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public record GetMyCommands( + @JsonProperty("scope") BotCommandScope scope, + @JsonProperty("language_code") String languageCode +) implements TelegramApiMethod { + + public GetMyCommands() { + this(null, null); + } + + public GetMyCommands(String languageCode) { + this(null, languageCode); + } + + public GetMyCommands(BotCommandScope scope) { + this(scope, null); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "getMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return BotCommand[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java new file mode 100644 index 0000000..a351910 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetMyDescription(String languageCode) implements TelegramApiMethod { + + public GetMyDescription() { + this(null); + } + + @Override + public RequestBody getBody() { + return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyDescription"; + } + + @Override + public Class getResponseClass() { + return BotDescription.class; + } + + public record BotDescription(String description) { + @NotNull + @Override + public String toString() { + return description; + } + + public boolean isEmpty() { + return description.isEmpty(); + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java new file mode 100644 index 0000000..af83b33 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; +import org.jetbrains.annotations.NotNull; + +public record GetMyName(String languageCode) implements TelegramApiMethod { + + public GetMyName() { + this(null); + } + + @Override + public RequestBody getBody() { + return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyName"; + } + + @Override + public Class getResponseClass() { + return BotName.class; + } + + public record BotName(String name) { + + @NotNull + @Override + public String toString() { + return this.name; + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java new file mode 100644 index 0000000..2f12900 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.core.objects; + + +import hdvtdev.telegram.objects.Update; +import okhttp3.RequestBody; + +import java.util.ArrayList; + +public record GetUpdates( + Long offset, + Integer limit, + Integer timeout +) implements TelegramApiMethod { + + public GetUpdates() { + this(null, null, null); + } + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + ArrayList params = new ArrayList<>(3); + if (offset != null) params.add("offset=" + offset); + if (limit != null) params.add("limit=" + limit); + if (timeout != null) params.add("timeout=" + timeout); + + if (params.isEmpty()) { + return "getUpdates"; + } else { + return "getUpdates?" + String.join("&", params); + } + } + + @Override + public Class getResponseClass() { + return Update[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/InlineQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/InlineQuery.java new file mode 100644 index 0000000..566c0f9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/InlineQuery.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record InlineQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("query") String query, + @JsonProperty("offset") String offset, + @JsonProperty("chat_type") String chatType, + @JsonProperty("location") Location location +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Location.java b/core/src/main/java/hdvtdev/telegram/core/objects/Location.java new file mode 100644 index 0000000..29dbf94 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Location.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Location( + @JsonProperty("latitude") float latitude, + @JsonProperty("longitude") float longitude, + @JsonProperty("horizontal_accuracy") float horizontalAccuracy, + @JsonProperty("live_period") int livePeriod, + @JsonProperty("heading") int heading, + @JsonProperty("proximity_alert_radius") int proximityAlertRadius +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/LoginUrl.java b/core/src/main/java/hdvtdev/telegram/core/objects/LoginUrl.java new file mode 100644 index 0000000..67b9344 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/LoginUrl.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record LoginUrl( + @JsonProperty("url") String url, + @JsonProperty("forward_text") String forwardText, + @JsonProperty("bot_username") String botUsername, + @JsonProperty("request_write_access") boolean requestWriteAccess +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/MaskPosition.java b/core/src/main/java/hdvtdev/telegram/core/objects/MaskPosition.java new file mode 100644 index 0000000..e9de212 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/MaskPosition.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MaskPosition( + @JsonProperty("point") String point, + @JsonProperty("x_shift") float xShift, + @JsonProperty("y_shift") float yShift, + @JsonProperty("scale") float scale +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ProximityAlertTriggered.java b/core/src/main/java/hdvtdev/telegram/core/objects/ProximityAlertTriggered.java new file mode 100644 index 0000000..b111773 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ProximityAlertTriggered.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ProximityAlertTriggered( + @JsonProperty("traveler") User traveler, + @JsonProperty("watcher") User watcher, + @JsonProperty("distance") int distance +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java b/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java new file mode 100644 index 0000000..c14a787 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyParameters( + @JsonProperty("message_id") long messageId, + @JsonProperty("chat_id") String chatId, + @JsonProperty("allow_sending_without_reply") boolean allowSendingWithoutReply, + @JsonProperty("quote") String quote, + @JsonProperty("quote_parse_mode") String quoteParseMode, + @JsonProperty("quote_entities") MessageEntity[] quoteEntities, + @JsonProperty("quote_position") Integer quotePosition +) { + + public ReplyParameters(long messageId, String chatId) { + this(messageId, chatId, false, null, null, null, null); + } + + public ReplyParameters(long messageId, long chatId) { + this(messageId, String.valueOf(chatId)); + } + + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java new file mode 100644 index 0000000..f3324f2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * Returns the revoked invite link as {@link ChatInviteLink} object. + * @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername) + * @param link The invite link to revoke + */ +public record RevokeChatInviteLink(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod { + + public RevokeChatInviteLink(long chatId, @NotNull String link) { + this(String.valueOf(chatId), link); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); + } + + @Override + public String getMethodName() { + return "revokeChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java new file mode 100644 index 0000000..9f59abd --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java @@ -0,0 +1,104 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class SendChatAction implements TelegramApiMethod { + + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { + this.businessConnectionId = businessConnectionId; + this.chatId = chatId; + this.messageThreadId = messageThreadId; + this.chatAction = chatAction; + } + + public SendChatAction(String chatId, ChatAction chatAction) { + this(null, chatId, null, chatAction); + } + + public SendChatAction(long chatId, ChatAction chatAction) { + this(String.valueOf(chatId), chatAction); + } + + private SendChatAction(Builder builder) { + this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction); + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + @Override + public RequestBody getBody() { + + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); + + if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); + if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); + + return builder.build(); + } + + @Override + public String getMethodName() { + return "sendChatAction"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public enum ChatAction { + TYPING, + UPLOAD_PHOTO, + RECORD_VIDEO, + UPLOAD_VIDEO, + RECORD_VOICE, + UPLOAD_VOICE, + UPLOAD_DOCUMENT, + UPLOAD_FILE, + CHOOSE_STICKER, + FIND_LOCATION, + RECORD_VIDEO_NOTE, + UPLOAD_VIDEO_NOTE + } + + public static final class Builder { + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public Builder(String chatId, ChatAction chatAction) { + this.chatId = chatId; + this.chatAction = chatAction; + } + + public Builder businessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + return this; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public SendChatAction build() { + return new SendChatAction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java new file mode 100644 index 0000000..3bb16dc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendDice implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("emoji") + private String emoji; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public SendDice(String chatId) { + this.chatId = chatId; + } + + public SendDice(long chatId) { + this(String.valueOf(chatId)); + } + + public SendDice(String chatId, Emoji emoji) { + this.emoji = emoji.getEmoji(); + this.chatId = chatId; + } + + public SendDice(long chatId, Emoji emoji) { + this(String.valueOf(chatId), emoji); + } + + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setEmoji(Emoji emoji) { + this.emoji = emoji.getEmoji(); + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendDice"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public enum Emoji { + DICE("🎲"), + DART("🎯"), + BASKETBALL("🏀"), + FOOTBALL("⚽"), + BOWLING("🎳"), + SLOT_MACHINE("🎰"); + + private final String emoji; + + Emoji(String emoji) { + this.emoji = emoji; + } + + public String getEmoji() { + return emoji; + } + + } + + + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java new file mode 100644 index 0000000..6187da7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java @@ -0,0 +1,226 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.*; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("text") + private final String text; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("entities") + private MessageEntity[] entities; + @JsonProperty("link_preview_options") + private LinkPreviewOptions linkPreviewOptions; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + private SendMessage(Builder builder) { + chatId = builder.chatId; + text = builder.text; + setBusinessConnectionId(builder.businessConnectionId); + setMessageThreadId(builder.messageThreadId); + setParseMode(builder.parseMode); + setEntities(builder.entities); + setLinkPreviewOptions(builder.linkPreviewOptions); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setMessageEffectId(builder.messageEffectId); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + this.linkPreviewOptions = linkPreviewOptions; + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setEntities(MessageEntity[] entities) { + this.entities = entities; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyToMessage(long messageId) { + this.replyParameters = new ReplyParameters(messageId, chatId); + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + public SendMessage(String chatId, String text) { + if (chatId.isEmpty() || text.isEmpty()) + throw new IllegalArgumentException("chatId or/and message (text) cannot be empty."); + this.chatId = chatId; + this.text = text; + } + + public SendMessage(long chatIdAsLong, String text) { + this(String.valueOf(chatIdAsLong), text); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private final String text; + private String businessConnectionId; + private Long messageThreadId; + private ParseMode parseMode; + private MessageEntity[] entities; + private LinkPreviewOptions linkPreviewOptions; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private String messageEffectId; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(long chatId, String text) { + this(String.valueOf(chatId), text); + } + + public Builder(String chatId, String text) { + this.chatId = chatId; + this.text = text; + } + + public Builder businessConnectionId(String val) { + businessConnectionId = val; + return this; + } + + public Builder messageThreadId(Long val) { + messageThreadId = val; + return this; + } + + public Builder parseMode(ParseMode val) { + parseMode = val; + return this; + } + + public Builder entities(MessageEntity[] val) { + entities = val; + return this; + } + + public Builder linkPreviewOptions(LinkPreviewOptions val) { + linkPreviewOptions = val; + return this; + } + + public Builder disableNotification() { + disableNotification = true; + return this; + } + + public Builder protectContent() { + protectContent = true; + return this; + } + + public Builder allowPaidBroadcast() { + allowPaidBroadcast = true; + return this; + } + + public Builder messageEffectId(String val) { + messageEffectId = val; + return this; + } + + public Builder replyParameters(ReplyParameters val) { + replyParameters = val; + return this; + } + + public Builder replyToMessage(long val) { + replyParameters = new ReplyParameters(val, this.chatId); + return this; + } + + public Builder replyMarkup(ReplyMarkup val) { + replyMarkup = val; + return this; + } + + public SendMessage build() { + return new SendMessage(this); + } + } +} + diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java new file mode 100644 index 0000000..3aecda3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.ReactionType; + +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SetMessageReaction implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("reaction") + private List reactions; + @JsonProperty("is_big") + private Boolean isBig; + + public SetMessageReaction(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public SetMessageReaction(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + private SetMessageReaction(Builder builder) { + chatId = builder.chatId; + messageId = builder.messageId; + setReactions(builder.reactions); + isBig = builder.isBig; + } + + public void setReactions(List reactions) { + this.reactions = reactions; + } + + public void setBig(Boolean big) { + isBig = big; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMessageReaction"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long messageId; + private List reactions; + private Boolean isBig; + + public Builder(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public Builder(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + public Builder reactions(List reactions) { + this.reactions = reactions; + return this; + } + + public Builder isBig(Boolean isBig) { + this.isBig = isBig; + return this; + } + + public SetMessageReaction build() { + return new SetMessageReaction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java new file mode 100644 index 0000000..8dac79a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SetMyCommands implements TelegramApiMethod { + + @JsonProperty("commands") + private final List commands; + @JsonProperty("scope") + private Object scope; + @JsonProperty("language_code") + private String languageCode; + + public SetMyCommands(List commands, Object scope, String languageCode) { + this.commands = commands; + this.scope = scope; + this.languageCode = languageCode; + } + + public SetMyCommands(BotCommand... commands) { + this.commands = List.of(commands); + } + + public SetMyCommands(List commands) { + this.commands = commands; + } + + private SetMyCommands(Builder builder) { + commands = builder.commands; + setScope(builder.scope); + setLanguageCode(builder.languageCode); + } + + public void setScope(Object scope) { + this.scope = scope; + } + + public void setLanguageCode(String languageCode) { + this.languageCode = languageCode; + } + + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + + public static final class Builder { + private final List commands; + private Object scope; + private String languageCode; + + public Builder(List commands) { + this.commands = commands; + } + + public Builder(BotCommand... commands) { + this.commands = List.of(commands); + } + + public Builder scope(BotCommandScope scope) { + this.scope = scope; + return this; + } + + public Builder languageCode(String languageCode) { + this.languageCode = languageCode; + return this; + } + + public SetMyCommands build() { + return new SetMyCommands(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java new file mode 100644 index 0000000..2dc5c26 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java @@ -0,0 +1,41 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. + * Returns {@code true} on success. + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. + */ +public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { + + public SetMyDescription() { + this(null, null); + } + + public SetMyDescription(String description) { + this(description, null); + } + + @Override + public RequestBody getBody() { + if (description == null) { + return null; + } + FormBody.Builder builder = new FormBody.Builder().add("description", description); + if (languageCode != null) builder.add("language_code", languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyDescription"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java new file mode 100644 index 0000000..fb7eff3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record SetMyName(String name, String languageCode) implements TelegramApiMethod { + + public SetMyName(String name) { + this(name, null); + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("name", this.name); + if (languageCode != null) builder.add("language_code", this.languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyName"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java new file mode 100644 index 0000000..59f7864 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SharedUser( + @JsonProperty("user_id") long userId, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("photo") PhotoSize[] photo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java new file mode 100644 index 0000000..1035ba3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import okhttp3.RequestBody; + +public interface TelegramApiMethod { + + RequestBody getBody(); + + String getMethodName(); + + Class getResponseClass(); + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Update.java b/core/src/main/java/hdvtdev/telegram/core/objects/Update.java new file mode 100644 index 0000000..450da73 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Update.java @@ -0,0 +1,139 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Update( + @JsonProperty("update_id") long updateId, + @JsonProperty("message") Message message, + @JsonProperty("edited_message") Message editedMessage, + @JsonProperty("channel_post") Message channelPost, + @JsonProperty("edited_channel_post") Message editedChannelPost, + @JsonProperty("business_connection") BusinessConnection businessConnection, + @JsonProperty("business_message") Message businessMessage, + @JsonProperty("edited_business_message") Message editedBusinessMessage, + @JsonProperty("deleted_business_messages") BusinessMessagesDeleted businessMessagesDeleted, + @JsonProperty("message_reaction") MessageReactionUpdated messageReaction, + @JsonProperty("message_reaction_count") MessageReactionCountUpdated messageReactionCount, + @JsonProperty("inline_query") InlineQuery inlineQuery, + @JsonProperty("chosen_inline_result") ChosenInlineResult chosenInlineResult, + @JsonProperty("callback_query") CallbackQuery callbackQuery, + @JsonProperty("shipping_query") ShippingQuery shippingQuery, + @JsonProperty("pre_checkout_query") PreCheckoutQuery preCheckoutQuery, + @JsonProperty("purchased_paid_media") PaidMediaPurchased paidMediaPurchased, + @JsonProperty("poll") Poll poll, + @JsonProperty("poll_answer") PollAnswer pollAnswer, + @JsonProperty("my_chat_member") ChatMemberUpdated myChatMember, + @JsonProperty("chat_member") ChatMemberUpdated chatMember, + @JsonProperty("chat_join_request") ChatJoinRequest chatJoinRequest, + @JsonProperty("chat_boost") ChatBoostUpdated chatBoost, + @JsonProperty("removed_chat_boost") ChatBoostRemoved chatBoostRemoved +) { + + public boolean hasMessage() { + return this.message != null; + } + + public boolean hasEditedMessage() { + return this.editedMessage != null; + } + + public boolean hasChannelPost() { + return this.channelPost != null; + } + + public boolean hasEditedChannelPost() { + return this.editedChannelPost != null; + } + + public boolean hasBusinessConnection() { + return this.businessConnection != null; + } + + public boolean hasBusinessMessage() { + return this.businessMessage != null; + } + + public boolean hasEditedBusinessMessage() { + return this.editedBusinessMessage != null; + } + + public boolean hasDeletedBusinessMessages() { + return this.businessMessagesDeleted != null; + } + + public boolean hasMessageReaction() { + return this.messageReaction != null; + } + + public boolean hasMessageReactionCount() { + return this.messageReactionCount != null; + } + + public boolean hasInlineQuery() { + return this.inlineQuery != null; + } + + public boolean hasChosenInlineResult() { + return this.chosenInlineResult != null; + } + + public boolean hasCallbackQuery() { + return this.callbackQuery != null; + } + + public boolean hasShippingQuery() { + return this.shippingQuery != null; + } + + public boolean hasPreCheckoutQuery() { + return this.preCheckoutQuery != null; + } + + public boolean hasPurchasedPaidMedia() { + return this.paidMediaPurchased != null; + } + + public boolean hasPoll() { + return this.poll != null; + } + + public boolean hasPollAnswer() { + return this.pollAnswer != null; + } + + public boolean hasMyChatMember() { + return this.myChatMember != null; + } + + public boolean hasChatMember() { + return this.chatMember != null; + } + + public boolean hasChatJoinRequest() { + return this.chatJoinRequest != null; + } + + public boolean hasChatBoost() { + return this.chatBoost != null; + } + + public boolean hasRemovedChatBoost() { + return this.chatBoostRemoved != null; + } + + public Optional getAnyText() { + if (hasMessage()) { + if (message.hasText()) return Optional.of(message.text()); + if (message.hasCaption()) return Optional.of(message.caption()); + } + return Optional.empty(); + } + +} + diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/User.java b/core/src/main/java/hdvtdev/telegram/core/objects/User.java new file mode 100644 index 0000000..3f0f29d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/User.java @@ -0,0 +1,62 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record User( + @JsonProperty("id") long id, + @JsonProperty("is_bot") boolean isBot, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("language_code") String languageCode, + @JsonProperty("is_premium") boolean isPremium, + @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu +) { + + public boolean hasLastName() { + return this.lastName != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasLanguageCode() { + return this.languageCode != null; + } + + public record Bot( + @JsonProperty("id") long id, + @JsonProperty("is_bot") Boolean isBot, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("language_code") String languageCode, + @JsonProperty("is_premium") boolean isPremium, + @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu, + @JsonProperty("can_join_groups") boolean canJoinGroups, + @JsonProperty("can_read_all_group_messages") boolean canReadAllGroupMessages, + @JsonProperty("supports_inline_queries") boolean supportsInlineQueries, + @JsonProperty("can_connect_to_business") boolean canConnectToBusiness, + @JsonProperty("has_main_web_app") boolean hasMainWebApp + ) { + + public boolean hasLastName() { + return this.lastName != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasLanguageCode() { + return this.languageCode != null; + } + + + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/UsersShared.java b/core/src/main/java/hdvtdev/telegram/core/objects/UsersShared.java new file mode 100644 index 0000000..5d9231d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/UsersShared.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record UsersShared( + @JsonProperty("request_id") int requestId, + @JsonProperty("users") SharedUser[] users +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Venue.java b/core/src/main/java/hdvtdev/telegram/core/objects/Venue.java new file mode 100644 index 0000000..7a1d746 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Venue.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Venue( + @JsonProperty("location") Location location, + @JsonProperty("title") String title, + @JsonProperty("address") String address, + @JsonProperty("foursquare_id") String foursquareId, + @JsonProperty("foursquare_type") String foursquareType, + @JsonProperty("google_place_id") String googlePlaceId, + @JsonProperty("google_place_type") String googlePlaceType +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/WebAppData.java b/core/src/main/java/hdvtdev/telegram/core/objects/WebAppData.java new file mode 100644 index 0000000..4ca6087 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/WebAppData.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WebAppData(String data, @JsonProperty("button_text") String buttonText) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/WebAppInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/WebAppInfo.java new file mode 100644 index 0000000..61ef90a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/WebAppInfo.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WebAppInfo(@JsonProperty("url") String url) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/WriteAccessAllowed.java b/core/src/main/java/hdvtdev/telegram/core/objects/WriteAccessAllowed.java new file mode 100644 index 0000000..4513ab0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/WriteAccessAllowed.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WriteAccessAllowed( + @JsonProperty("from_request") boolean fromRequest, + @JsonProperty("web_app_name") String webAppName, + @JsonProperty("from_attachment_menu") boolean fromAttachmentMenu +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java new file mode 100644 index 0000000..dd020c9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BackgroundFillSolid.class, name = "solid"), + @JsonSubTypes.Type(value = BackgroundFillGradient.class, name = "gradient"), + @JsonSubTypes.Type(value = BackgroundFillFreeformGradient.class, name = "freeform_gradient") +}) +public interface BackgroundFill { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java new file mode 100644 index 0000000..5dd0c4f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java @@ -0,0 +1,4 @@ +package hdvtdev.telegram.core.objects.background; + +public class BackgroundFillDeserializer { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java new file mode 100644 index 0000000..c6ada4e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillFreeformGradient( + @JsonProperty("type") String type, + @JsonProperty("colors") int[] colors +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java new file mode 100644 index 0000000..bf70298 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillGradient( + @JsonProperty("type") String type, + @JsonProperty("top_color") int topColor, + @JsonProperty("bottom_color") int bottomColor, + @JsonProperty("rotation_angle") int rotationAngle +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java new file mode 100644 index 0000000..3ef193e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillSolid( + @JsonProperty("type") String type, + @JsonProperty("color") int color +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java new file mode 100644 index 0000000..3073a05 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BackgroundTypeFill.class, name = "fill"), + @JsonSubTypes.Type(value = BackgroundTypeWallpaper.class, name = "wallpaper"), + @JsonSubTypes.Type(value = BackgroundTypePattern.class, name = "pattern"), + @JsonSubTypes.Type(value = BackgroundTypeChatTheme.class, name = "chat_theme") +}) +public interface BackgroundType { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java new file mode 100644 index 0000000..f6b9110 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeChatTheme( + @JsonProperty("type") String type, + @JsonProperty("theme_name") String themeName +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java new file mode 100644 index 0000000..ed96f2b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java @@ -0,0 +1,4 @@ +package hdvtdev.telegram.core.objects.background; + +public class BackgroundTypeDeserializer { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java new file mode 100644 index 0000000..c327930 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeFill( + @JsonProperty("type") String type, + @JsonProperty("fill") BackgroundFill fill, + @JsonProperty("dark_theme_dimming") int darkThemeDimming +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java new file mode 100644 index 0000000..1d8cca6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypePattern( + @JsonProperty("type") String type, + @JsonProperty("document") Document document, + @JsonProperty("fill") BackgroundFill fill, + @JsonProperty("is_inverted") boolean isInverted, + @JsonProperty("is_moving") boolean isMoving +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java new file mode 100644 index 0000000..79d88ee --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeWallpaper( + @JsonProperty("type") String type, + @JsonProperty("document") Document document, + @JsonProperty("dark_theme_dimming") int darkThemeDimming, + @JsonProperty("is_blurred") boolean isBlurred, + @JsonProperty("is_moving") boolean isMoving +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java new file mode 100644 index 0000000..af94133 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BusinessConnection( + @JsonProperty("id") String id, + @JsonProperty("user") User user, + @JsonProperty("user_chat_id") long userChatId, + @JsonProperty("date") long date, + @JsonProperty("can_reply") boolean canReply, + @JsonProperty("is_enabled") boolean isEnabled +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java new file mode 100644 index 0000000..3f544b9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BusinessMessagesDeleted( + @JsonProperty("business_connection_id") String businessConnectionId, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_ids") long[] messageIds +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java new file mode 100644 index 0000000..7cce5fd --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CallbackGame() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java new file mode 100644 index 0000000..2856d32 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java @@ -0,0 +1,40 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.MaybeInaccessibleMessage; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CallbackQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("message") MaybeInaccessibleMessage message, + @JsonProperty("inline_message_id") String inlineMessageId, + @JsonProperty("chat_instance") String chatInstance, + @JsonProperty("data") String data, + @JsonProperty("game_short_name") String gameShortName +) { + + public boolean hasMessage() { + return this.message != null; + } + + public boolean hasInlineMessageId() { + return this.inlineMessageId != null; + } + + public boolean hasChatInstance() { + return this.chatInstance != null; + } + + public boolean hasData() { + return this.data != null; + } + + public boolean hasGameShortName() { + return this.gameShortName != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java new file mode 100644 index 0000000..15e8385 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java @@ -0,0 +1,35 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Chat( + @JsonProperty("id") long id, + @JsonProperty("type") String type, + @JsonProperty("title") String title, + @JsonProperty("username") String username, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("is_forum") boolean isForum +) { + + public boolean hasTitle() { + return this.title != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasFirstName() { + return this.firstName != null; + } + + public boolean hasLastName() { + return this.lastName != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java new file mode 100644 index 0000000..4d5310c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java @@ -0,0 +1,26 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatAdministratorRights( + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("can_manage_chat") boolean canManageChat, + @JsonProperty("can_delete_messages") boolean canDeleteMessages, + @JsonProperty("can_manage_video_chats") boolean canManageVideoChats, + @JsonProperty("can_restrict_members") boolean canRestrictMembers, + @JsonProperty("can_promote_members") boolean canPromoteMembers, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_post_stories") boolean canPostStories, + @JsonProperty("can_edit_stories") boolean canEditStories, + @JsonProperty("can_delete_stories") boolean canDeleteStories, + @JsonProperty("can_post_messages") boolean canPostMessages, + @JsonProperty("can_edit_messages") boolean canEditMessages, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java new file mode 100644 index 0000000..debb727 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java @@ -0,0 +1,11 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.background.BackgroundType; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBackground(@JsonProperty("type") BackgroundType type) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java new file mode 100644 index 0000000..677f38b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java @@ -0,0 +1,29 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatInviteLink( + @JsonProperty("invite_link") String inviteLink, + @JsonProperty("creator") User creator, + @JsonProperty("creates_join_request") boolean createsJoinRequest, + @JsonProperty("is_primary") boolean isPrimary, + @JsonProperty("is_revoked") boolean isRevoked, + @JsonProperty("name") String name, + @JsonProperty("expire_date") long expireDate, + @JsonProperty("member_limit") int memberLimit, + @JsonProperty("pending_join_request_count") int pendingJoinRequestCount, + @JsonProperty("subscription_period") int subscriptionPeriod, + @JsonProperty("subscription_price") int subscriptionPrice +) { + @NotNull + @Override + public String toString() { + return this.inviteLink; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java new file mode 100644 index 0000000..8ff0772 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatJoinRequest( + @JsonProperty("chat") Chat chat, + @JsonProperty("from") User from, + @JsonProperty("user_chat_id") long userChatId, + @JsonProperty("date") long date, + @JsonProperty("bio") String bio, + @JsonProperty("invite_link") ChatInviteLink chatInviteLink +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java new file mode 100644 index 0000000..fe32e82 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "status" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatMemberAdministrator.class, name = "administrator"), + @JsonSubTypes.Type(value = ChatMemberBanned.class, name = "kicked"), + @JsonSubTypes.Type(value = ChatMemberLeft.class, name = "left"), + @JsonSubTypes.Type(value = ChatMemberMember.class, name = "member"), + @JsonSubTypes.Type(value = ChatMemberOwner.class, name = "creator"), + @JsonSubTypes.Type(value = ChatMemberRestricted.class, name = "restricted"), +}) +public interface ChatMember { + User user(); + String status(); + + default ChatMemberAdministrator getAsChatMemberAdministrator() { + return (ChatMemberAdministrator) this; + } + +} + diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java new file mode 100644 index 0000000..e3b69d3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java @@ -0,0 +1,30 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberAdministrator( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("can_be_edited") boolean canBeEdited, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("can_manage_chat") boolean canManageChat, + @JsonProperty("can_delete_messages") boolean canDeleteMessages, + @JsonProperty("can_manage_video_chats") boolean canManageVideoChat, + @JsonProperty("can_restrict_members") boolean canRestrictMembers, + @JsonProperty("can_promote_members") boolean canPromoteMembers, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_post_stories") boolean canPostStories, + @JsonProperty("can_edit_stories") boolean canEditStories, + @JsonProperty("can_delete_stories") boolean canDeleteStories, + @JsonProperty("can_post_messages") boolean canPostMessages, + @JsonProperty("can_edit_messages") boolean canEditMessages, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics, + @JsonProperty("custom_title") boolean hasCustomTitle +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java new file mode 100644 index 0000000..6c620b1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberBanned( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java new file mode 100644 index 0000000..c2c6173 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberLeft( + @JsonProperty("status") String status, + @JsonProperty("user") User user +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java new file mode 100644 index 0000000..d1c72b1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberMember( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java new file mode 100644 index 0000000..15a79c9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberOwner( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("custom_title") String customTitle +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java new file mode 100644 index 0000000..cfc94d3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java @@ -0,0 +1,29 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberRestricted( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("is_member") boolean isMember, + @JsonProperty("can_send_messages") boolean canSendMessage, + @JsonProperty("can_send_audios") boolean canSendAudios, + @JsonProperty("can_send_documents") boolean canSendDocuments, + @JsonProperty("can_send_photos") boolean canSendPhotos, + @JsonProperty("can_send_videos") boolean canSendVideos, + @JsonProperty("can_send_video_notes") boolean canSendVideoNotes, + @JsonProperty("can_send_voice_notes") boolean canSendVoiceNotes, + @JsonProperty("can_send_polls") boolean canSendPolls, + @JsonProperty("can_send_other_messages") boolean canSendOtherMessages, + @JsonProperty("can_add_web_page_previews") boolean canAddWebPagePreviews, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java new file mode 100644 index 0000000..ebd92be --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("from") User from, + @JsonProperty("date") long date, + @JsonProperty("old_chat_member") ChatMember oldChatMember, + @JsonProperty("new_chat_member") ChatMember newChatMember, + @JsonProperty("invite_link") ChatInviteLink chatInviteLink, + @JsonProperty("via_join_request") boolean viaJoinRequest, + @JsonProperty("via_chat_folder_invite_link") boolean viaChatFolderInviteLink +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java new file mode 100644 index 0000000..5c0c9a0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatShared( + @JsonProperty("request_id") int requestId, + @JsonProperty("chat_id") long chatId, + @JsonProperty("title") String title, + @JsonProperty("username") String username, + @JsonProperty("photo") PhotoSize[] photo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java new file mode 100644 index 0000000..c7a0bfb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoost( + @JsonProperty("boost_id") String boostId, + @JsonProperty("add_date") long addDate, + @JsonProperty("expiration_date") long expirationDate, + @JsonProperty("source") ChatBoostSource source +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java new file mode 100644 index 0000000..917b417 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostAdded( + @JsonProperty("boost_count") int boostCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java new file mode 100644 index 0000000..8f8cd8a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostRemoved( + @JsonProperty("chat") Chat chat, + @JsonProperty("boost_id") String boostId, + @JsonProperty("remove_date") long removeDate, + @JsonProperty("source") ChatBoostSource source +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java new file mode 100644 index 0000000..3352393 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "source" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatBoostSourcePremium.class, name = "premium"), + @JsonSubTypes.Type(value = ChatBoostSourceGiveaway.class, name = "giveaway"), + @JsonSubTypes.Type(value = ChatBoostSourceGiftCode.class, name = "gift_code") +}) +public interface ChatBoostSource { + String source(); +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java new file mode 100644 index 0000000..2c4addb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourceGiftCode( + @JsonProperty("source") String source, + @JsonProperty("user") User user +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java new file mode 100644 index 0000000..69d90c6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourceGiveaway( + @JsonProperty("source") String source, + @JsonProperty("giveaway_message_id") long giveawayMessageId, + @JsonProperty("user") User user, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("is_unclaimed") boolean isUnclaimed +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java new file mode 100644 index 0000000..a97339a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourcePremium( + @JsonProperty("source") String source, + @JsonProperty("user") User user +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java new file mode 100644 index 0000000..fe965d6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("boost") ChatBoost boost +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java new file mode 100644 index 0000000..a6b0845 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommand( + @JsonProperty("command") String name, + @JsonProperty("description") String description +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java new file mode 100644 index 0000000..8413da0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BotCommandScopeDefault.class, name = "default"), + @JsonSubTypes.Type(value = BotCommandScopeAllPrivateChats.class, name = "all_private_chats"), + @JsonSubTypes.Type(value = BotCommandScopeAllGroupChats.class, name = "all_group_chats"), + @JsonSubTypes.Type(value = BotCommandScopeAllChatAdministrators.class, name = "all_chat_administrators"), + @JsonSubTypes.Type(value = BotCommandScopeChat.class, name = "chat"), + @JsonSubTypes.Type(value = BotCommandScopeChatAdministrators.class, name = "chat_administrators"), + @JsonSubTypes.Type(value = BotCommandScopeChatMember.class, name = "chat_member") +}) +public interface BotCommandScope { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java new file mode 100644 index 0000000..99df70b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllChatAdministrators(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java new file mode 100644 index 0000000..52febd0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllGroupChats(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java new file mode 100644 index 0000000..4bc5332 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllPrivateChats(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java new file mode 100644 index 0000000..0defde5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChat(@JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId) implements BotCommandScope { + public BotCommandScopeChat(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { + this(type, String.valueOf(chatId)); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java new file mode 100644 index 0000000..9820090 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChatAdministrators(@JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId) implements BotCommandScope { + public BotCommandScopeChatAdministrators(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { + this(type, String.valueOf(chatId)); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java new file mode 100644 index 0000000..7b2fbdc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java @@ -0,0 +1,27 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChatMember( + @JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId, + @JsonProperty("user_id") long userId +) implements BotCommandScope { + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") long userId) { + this(type, String.valueOf(chatId), userId); + } + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") String userId) { + this(type, String.valueOf(chatId), Long.parseLong(userId)); + } + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") String chatId, @JsonProperty("user_id") String userId) { + this(type, chatId, Long.parseLong(userId)); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java new file mode 100644 index 0000000..9e8f73d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeDefault(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java new file mode 100644 index 0000000..c1363d9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicClosed() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java new file mode 100644 index 0000000..251cff6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicCreated( + @JsonProperty("name") String name, + @JsonProperty("icon_color") int iconColor, + @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java new file mode 100644 index 0000000..fb5d498 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicEdited( + @JsonProperty("name") String name, + @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java new file mode 100644 index 0000000..9d025e1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicReopened() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java new file mode 100644 index 0000000..78bae5d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GeneralForumTopicHidden() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java new file mode 100644 index 0000000..1469725 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GeneralForumTopicUnhidden() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java new file mode 100644 index 0000000..955e52c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Giveaway( + @JsonProperty("chats") Chat[] chats, + @JsonProperty("winners_selection_date") long winnersSelectionDate, + @JsonProperty("winner_count") int winnerCount, + @JsonProperty("only_new_members") boolean onlyNewMembers, + @JsonProperty("has_public_winners") boolean hasPublicWinners, + @JsonProperty("prize_description") String prizeDescription, + @JsonProperty("country_codes") String[] countryCodes, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java new file mode 100644 index 0000000..22bee08 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.Message; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayCompleted( + @JsonProperty("winner_count") int winnerCount, + @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, + @JsonProperty("giveaway_message") Message giveawayMessage, + @JsonProperty("is_star_giveaway") boolean isStarGiveaway +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java new file mode 100644 index 0000000..30312b9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayCreated(@JsonProperty("prize_star_count") int prizeStarCount) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java new file mode 100644 index 0000000..c356fb4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java @@ -0,0 +1,24 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayWinners( + @JsonProperty("chat") Chat chat, + @JsonProperty("giveaway_message_id") long giveawayMessageId, + @JsonProperty("winners_selection_date") long winnersSelectionDate, + @JsonProperty("winners_count") int winnersCount, + @JsonProperty("winners") User[] winners, + @JsonProperty("additional_chat_count") int additionalChatCount, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount, + @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, + @JsonProperty("only_new_members") boolean onlyNewMembers, + @JsonProperty("was_refunded") boolean wasRefunded, + @JsonProperty("prize_description") String prizeDescription +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java new file mode 100644 index 0000000..d770957 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CopyTextButton(@JsonProperty("text") String text) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java new file mode 100644 index 0000000..52edddc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.markup.ReplyMarkup; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForceReply( + @JsonProperty("force_reply") boolean forceReply, + @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java new file mode 100644 index 0000000..a4e7586 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java @@ -0,0 +1,250 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class InlineKeyboardButton { + + @JsonProperty("text") + private final String text; + @JsonProperty("url") + private String url; + @JsonProperty("callback_data") + private String callbackData; + @JsonProperty("web_app") + private WebAppInfo webApp; + @JsonProperty("login_url") + private LoginUrl loginUrl; + @JsonProperty("switch_inline_query") + private String switchInlineQuery; + @JsonProperty("switch_inline_query_current_chat") + private String switchInlineQueryCurrentChat; + @JsonProperty("switch_inline_query_chosen_chat") + private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; + @JsonProperty("copy_text") + private CopyTextButton copyTextButton; + @JsonProperty("callback_game") + private CallbackGame callbackGame; + @JsonProperty("pay") + private Boolean pay; + + @JsonCreator + public InlineKeyboardButton( + @JsonProperty("text") String text, + @JsonProperty("url") String url, + @JsonProperty("callback_data") String callbackData, + @JsonProperty("web_app") WebAppInfo webApp, + @JsonProperty("login_url") LoginUrl loginUrl, + @JsonProperty("switch_inline_query") String switchInlineQuery, + @JsonProperty("switch_inline_query_current_chat") String switchInlineQueryCurrentChat, + @JsonProperty("switch_inline_query_chosen_chat") SwitchInlineQueryChosenChat switchInlineQueryChosenChat, + @JsonProperty("copy_text") CopyTextButton copyTextButton, + @JsonProperty("callback_game") CallbackGame callbackGame, + @JsonProperty("pay") Boolean pay + ) { + this.text = text; + this.url = url; + this.callbackData = callbackData; + this.webApp = webApp; + this.loginUrl = loginUrl; + this.switchInlineQuery = switchInlineQuery; + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + this.copyTextButton = copyTextButton; + this.callbackGame = callbackGame; + this.pay = pay; + } + + private InlineKeyboardButton(Builder builder) { + this.text = builder.text; + setUrl(builder.url); + setCallbackData(builder.callbackData); + setWebApp(builder.webApp); + setLoginUrl(builder.loginUrl); + setSwitchInlineQuery(builder.switchInlineQuery); + setSwitchInlineQueryCurrentChat(builder.switchInlineQueryCurrentChat); + setSwitchInlineQueryChosenChat(builder.switchInlineQueryChosenChat); + setCopyTextButton(builder.copyTextButton); + setCallbackGame(builder.callbackGame); + setPay(builder.pay); + } + + public InlineKeyboardButton(String text) { + this.text = text; + } + + public InlineKeyboardButton(String text, String data) { + this.text = text; + this.callbackData = data; + } + + @JsonIgnore + public String getText() { + return text; + } + + @JsonIgnore + public String getUrl() { + return url; + } + + @JsonIgnore + public String getCallbackData() { + return callbackData; + } + + @JsonIgnore + public WebAppInfo getWebApp() { + return webApp; + } + + @JsonIgnore + public LoginUrl getLoginUrl() { + return loginUrl; + } + + @JsonIgnore + public String getSwitchInlineQuery() { + return switchInlineQuery; + } + + @JsonIgnore + public String getSwitchInlineQueryCurrentChat() { + return switchInlineQueryCurrentChat; + } + + @JsonIgnore + public SwitchInlineQueryChosenChat getSwitchInlineQueryChosenChat() { + return switchInlineQueryChosenChat; + } + + @JsonIgnore + public CopyTextButton getCopyTextButton() { + return copyTextButton; + } + + @JsonIgnore + public CallbackGame getCallbackGame() { + return callbackGame; + } + + @JsonIgnore + public Boolean getPay() { + return pay; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public void setWebApp(WebAppInfo webApp) { + this.webApp = webApp; + } + + public void setLoginUrl(LoginUrl loginUrl) { + this.loginUrl = loginUrl; + } + + public void setSwitchInlineQuery(String switchInlineQuery) { + this.switchInlineQuery = switchInlineQuery; + } + + public void setSwitchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + } + + public void setSwitchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + } + + public void setCopyTextButton(CopyTextButton copyTextButton) { + this.copyTextButton = copyTextButton; + } + + public void setCallbackGame(CallbackGame callbackGame) { + this.callbackGame = callbackGame; + } + + public void setPay(Boolean pay) { + this.pay = pay; + } + + public static final class Builder { + private final String text; + private String url; + private String callbackData; + private WebAppInfo webApp; + private LoginUrl loginUrl; + private String switchInlineQuery; + private String switchInlineQueryCurrentChat; + private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; + private CopyTextButton copyTextButton; + private CallbackGame callbackGame; + private Boolean pay; + + public Builder(String text) { + this.text = text; + } + + public Builder pay(boolean pay) { + this.pay = pay; + return this; + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder callbackData(String callbackData) { + this.callbackData = callbackData; + return this; + } + + public Builder webApp(WebAppInfo webApp) { + this.webApp = webApp; + return this; + } + + public Builder loginUrl(LoginUrl loginUrl) { + this.loginUrl = loginUrl; + return this; + } + + public Builder switchInlineQuery(String switchInlineQuery) { + this.switchInlineQuery = switchInlineQuery; + return this; + } + + public Builder switchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + return this; + } + + public Builder switchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + return this; + } + + public Builder copyTextButton(CopyTextButton copyTextButton) { + this.copyTextButton = copyTextButton; + return this; + } + + public Builder callbackGame(CallbackGame callbackGame) { + this.callbackGame = callbackGame; + return this; + } + + public InlineKeyboardButton build() { + return new InlineKeyboardButton(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java new file mode 100644 index 0000000..9eae0f4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java @@ -0,0 +1,35 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.*; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public record InlineKeyboardMarkup( + @JsonProperty("inline_keyboard") InlineKeyboardRow... keyboard) implements ReplyMarkup { + + @JsonCreator + public InlineKeyboardMarkup(@JsonProperty("inline_keyboard") InlineKeyboardButton[][] keyboardButtons) { + this(convertToInlineKeyboardRow(keyboardButtons)); + } + + public InlineKeyboardMarkup(List inlineKeyboardRows) { + this(inlineKeyboardRows.toArray(new InlineKeyboardRow[0])); + } + + @JsonIgnore + private static InlineKeyboardRow[] convertToInlineKeyboardRow(InlineKeyboardButton[][] keyboardButtons) { + InlineKeyboardRow[] rows = new InlineKeyboardRow[keyboardButtons.length]; + for (int i = 0; i < keyboardButtons.length; i++) { + rows[i] = new InlineKeyboardRow(keyboardButtons[i]); + } + return rows; + } + + @JsonIgnore + public static InlineKeyboardMarkup ofSingleButton(InlineKeyboardButton button) { + return new InlineKeyboardMarkup(new InlineKeyboardRow(button)); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java new file mode 100644 index 0000000..f951109 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java @@ -0,0 +1,69 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jetbrains.annotations.NotNull; + +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + + +public final class InlineKeyboardRow extends AbstractList { + + @JsonIgnore + private final ArrayList buttonsList = new ArrayList<>(); + + public InlineKeyboardRow() { + + } + + public InlineKeyboardButton remove(int i) { + return this.buttonsList.remove(i); + } + + @JsonIgnore + @Override + public void clear() { + this.buttonsList.clear(); + } + + @JsonIgnore + @Override + public int size() { + return this.buttonsList.size(); + } + + @JsonIgnore + @Override + public boolean addAll(@NotNull Collection buttons) { + return this.buttonsList.addAll(buttons); + } + + public void addAll(InlineKeyboardButton... buttons) { + this.buttonsList.addAll(List.of(buttons)); + } + + public InlineKeyboardRow(InlineKeyboardButton... buttons) { + this.buttonsList.addAll(List.of(buttons)); + } + + @JsonIgnore + @Override + public boolean add(InlineKeyboardButton button) { + return this.buttonsList.add(button); + } + + @JsonIgnore + @Override + public InlineKeyboardButton get(int i) { + return this.buttonsList.get(i); + } + + @JsonValue + public List buttons() { + return buttonsList; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java new file mode 100644 index 0000000..f653db7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButton( + @JsonProperty("text") String text, + @JsonProperty("request_users") KeyboardButtonRequestUsers requestUsers, + @JsonProperty("request_chat") KeyboardButtonRequestChat requestChat, + @JsonProperty("request_contact") boolean requestContact, + @JsonProperty("request_location") boolean requestLocation, + @JsonProperty("request_poll") KeyboardButtonPollType requestPoll, + @JsonProperty("web_app") WebAppInfo webApp +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java new file mode 100644 index 0000000..74be5d4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonPollType( + @JsonProperty("type") String type +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java new file mode 100644 index 0000000..90c805f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java @@ -0,0 +1,23 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonRequestChat( + @JsonProperty("request_id") Integer requestId, + @JsonProperty("chat_is_channel") boolean chatIsChannel, + @JsonProperty("chat_is_forum") boolean chatIsForum, + @JsonProperty("chat_has_username") boolean chatHasUsername, + @JsonProperty("chat_is_created") boolean chatIsCreated, + @JsonProperty("user_administrator_rights") ChatAdministratorRights userAdministratorRights, + @JsonProperty("bot_administrator_rights") ChatAdministratorRights botAdministratorRights, + @JsonProperty("bot_is_member") boolean botIsMember, + @JsonProperty("request_title") boolean requestTitle, + @JsonProperty("request_username") boolean requestUsername, + @JsonProperty("request_photo") boolean requestPhoto +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java new file mode 100644 index 0000000..022c06b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonRequestUsers( + @JsonProperty("request_id") Integer requestId, + @JsonProperty("user_is_bot") boolean userIsBot, + @JsonProperty("user_is_premium") boolean userIsPremium, + @JsonProperty("max_quantity") Integer maxQuantity, + @JsonProperty("request_name") Boolean requestName, + @JsonProperty("request_username") Boolean requestUsername, + @JsonProperty("request_photo") Boolean requestPhoto +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java new file mode 100644 index 0000000..af1be9e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyKeyboardMarkup( + @JsonProperty("keyboard") KeyboardButton[][] keyboard, + @JsonProperty("is_persistent") boolean isPersistent, + @JsonProperty("resize_keyboard") boolean resizeKeyboard, + @JsonProperty("one_time_keyboard") boolean oneTimeKeyboard, + @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java new file mode 100644 index 0000000..e320039 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyKeyboardRemove( + @JsonProperty("remove_keyboard") boolean removeKeyboard, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java new file mode 100644 index 0000000..9325e99 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.DEDUCTION, + defaultImpl = Void.class +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ReplyKeyboardMarkup.class), + @JsonSubTypes.Type(value = InlineKeyboardMarkup.class), + @JsonSubTypes.Type(value = ReplyKeyboardRemove.class) +}) +public interface ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java new file mode 100644 index 0000000..65044dd --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SwitchInlineQueryChosenChat( + @JsonProperty("query") String query, + @JsonProperty("allow_user_chats") boolean allowUserChats, + @JsonProperty("allow_bot_chats") boolean allowBotChats, + @JsonProperty("allow_group_chats") boolean allowGroupChats, + @JsonProperty("allow_channel_chats") boolean allowChannelChats +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java new file mode 100644 index 0000000..693eaf1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public record Animation( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") Long fileSize +) { + + public boolean hasThumbnail() { + return this.thumbnail != null; + } + + public boolean hasFileName() { + return this.fileName != null; + } + + public boolean hasMimeType() { + return this.mimeType != null; + } + + public boolean hasFileSize() { + return this.fileSize != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java new file mode 100644 index 0000000..0d27c8c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Audio( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("duration") int duration, + @JsonProperty("performer") String performer, + @JsonProperty("title") String title, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") Long fileSize, + @JsonProperty("thumbnail") PhotoSize thumbnail +) { + + public boolean hasThumbnail() { + return this.thumbnail != null; + } + + public boolean hasFileName() { + return this.fileName != null; + } + + public boolean hasMimeType() { + return this.mimeType != null; + } + + public boolean hasFileSize() { + return this.fileSize != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java new file mode 100644 index 0000000..230e080 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.methods.GetFile; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Document( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { + public GetFile getFile() { + return new GetFile(this.fileId); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java new file mode 100644 index 0000000..1337781 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PhotoSize( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("file_size") long file_size +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java new file mode 100644 index 0000000..ae66739 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java @@ -0,0 +1,26 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Sticker( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("type") String type, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("is_animated") boolean isAnimated, + @JsonProperty("is_video") boolean isVideo, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("emoji") String emoji, + @JsonProperty("set_name") String setName, + @JsonProperty("premium_animation") TelegramFile premiumAnimation, + @JsonProperty("mask_position") MaskPosition maskPosition, + @JsonProperty("custom_emoji_id") String customEmojiId, + @JsonProperty("needs_repairing") boolean needsRepairing, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java new file mode 100644 index 0000000..fd95027 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Story( + @JsonProperty("chat") Chat chat, + @JsonProperty("id") long id +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java new file mode 100644 index 0000000..60426f1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("file") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record TelegramFile( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("file_size") long fileSize, + @JsonProperty("file_path") String filePath //link to file +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java new file mode 100644 index 0000000..6fc5d3c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Voice( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("duration") int duration, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java new file mode 100644 index 0000000..405cf76 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = PaidMediaPreview.class, name = "preview"), + @JsonSubTypes.Type(value = PaidMediaPhoto.class, name = "photo"), + @JsonSubTypes.Type(value = PaidMediaVideo.class, name = "video") +}) +public interface PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java new file mode 100644 index 0000000..34a488a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaInfo( + @JsonProperty("star_count") int startCount, + @JsonProperty("paid_media") PaidMedia[] paidMedia +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java new file mode 100644 index 0000000..a952f23 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPhoto( + @JsonProperty("type") String type, + @JsonProperty("photo") PhotoSize[] photo +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java new file mode 100644 index 0000000..f4464e7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPreview( + @JsonProperty("type") String type, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java new file mode 100644 index 0000000..841da3b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPurchased( + @JsonProperty("from") User from, + @JsonProperty("paid_media_payload") String paidMediaPayload +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java new file mode 100644 index 0000000..b32b07e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaVideo( + @JsonProperty("type") String type, + @JsonProperty("video") Video video +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java new file mode 100644 index 0000000..4cddbd3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.core.objects.media; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Video( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("cover") PhotoSize[] cover, + @JsonProperty("start_timestamp") int startTimestamp, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java new file mode 100644 index 0000000..47c6741 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatEnded(@JsonProperty("duration") long duration) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java new file mode 100644 index 0000000..4c43c69 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatParticipantsInvited(@JsonProperty("users") User[] users) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java new file mode 100644 index 0000000..dff9e28 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatScheduled(@JsonProperty("start_date") long startDate) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java new file mode 100644 index 0000000..82bc832 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatStarted() { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java new file mode 100644 index 0000000..d2f1c3f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects.media; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoNote( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("length") long length, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java new file mode 100644 index 0000000..9cecc55 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java @@ -0,0 +1,46 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; +import hdvtdev.telegram.core.objects.giveaway.Giveaway; +import hdvtdev.telegram.core.objects.giveaway.GiveawayWinners; +import hdvtdev.telegram.core.objects.media.*; +import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaInfo; +import hdvtdev.telegram.core.objects.media.video.Video; +import hdvtdev.telegram.core.objects.media.video.VideoNote; +import hdvtdev.telegram.core.objects.message.LinkPreviewOptions; +import hdvtdev.telegram.core.objects.message.MessageOrigin; +import hdvtdev.telegram.core.objects.payment.Invoice; +import hdvtdev.telegram.core.objects.poll.Poll; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ExternalReplyInfo( + @JsonProperty("origin") MessageOrigin origin, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, + @JsonProperty("animation") Animation animation, + @JsonProperty("audio") Audio audio, + @JsonProperty("document") Document document, + @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("sticker") Sticker sticker, + @JsonProperty("story") Story story, + @JsonProperty("video") Video video, + @JsonProperty("video_note") VideoNote videoNote, + @JsonProperty("voice") Voice voice, + @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, + @JsonProperty("contact") Contact contact, + @JsonProperty("dice") Dice dice, + @JsonProperty("game") Game game, + @JsonProperty("giveaway") Giveaway giveaway, + @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, + @JsonProperty("invoice") Invoice invoice, + @JsonProperty("location") Location location, + @JsonProperty("poll") Poll poll, + @JsonProperty("venue") Venue venue +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java new file mode 100644 index 0000000..5c106ae --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record InaccessibleMessage(Chat chat, @JsonProperty("message_id") int messageId, + long date) implements MaybeInaccessibleMessage { + @Override + public long chatId() { + return chat.id(); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java new file mode 100644 index 0000000..f1af977 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record LinkPreviewOptions( + @JsonProperty("is_disabled") boolean isDisabled, + @JsonProperty("url") String url, + @JsonProperty("prefer_small_media") boolean preferSmallMedia, + @JsonProperty("prefer_large_media") boolean preferLargeMedia, + @JsonProperty("show_above_text") boolean showAboveText + +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java new file mode 100644 index 0000000..701308c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = MaybeInaccessibleMessageDeserializer.class) +public interface MaybeInaccessibleMessage { + long chatId(); + + Chat chat(); + + int messageId(); + + long date(); + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java new file mode 100644 index 0000000..70c96e6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +import java.io.IOException; + +public class MaybeInaccessibleMessageDeserializer extends JsonDeserializer { + + @Override + public MaybeInaccessibleMessage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + Message msg = p.getCodec().readValue(p, Message.class); + return msg.date() == 0 ? new InaccessibleMessage(msg.chat(), msg.messageId(), 0) : msg; + } +} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java new file mode 100644 index 0000000..74fdf14 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java @@ -0,0 +1,275 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostAdded; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Message( + @JsonProperty("message_id") int messageId, + @JsonProperty("message_thread_id") Long messageThreadId, + @JsonProperty("from") User user, + @JsonProperty("sender_chat") Chat senderChat, + @JsonProperty("sender_boost_count") Integer senderBoostCount, + @JsonProperty("sender_business_bot") User senderBusinessBot, + @JsonProperty("date") long date, + @JsonProperty("business_connection_id") String businessConnectionId, + @JsonProperty("chat") Chat chat, + @JsonProperty("forward_origin") MessageOrigin forwardOrigin, + @JsonProperty("is_topic_message") boolean isTopicMessage, + @JsonProperty("is_automatic_forward") boolean isAutomaticForward, + @JsonProperty("reply_to_message") Message replyToMessage, + @JsonProperty("external_reply") ExternalReplyInfo externalReply, + @JsonProperty("quote") TextQuote quote, + @JsonProperty("reply_to_story") Story replyToStory, + @JsonProperty("via_bot") User viaBot, + @JsonProperty("edit_date") long editDate, + @JsonProperty("has_protected_content") boolean hasProtectedContent, + @JsonProperty("is_from_offline") boolean isFromOnline, + @JsonProperty("media_group_id") String mediaGroupId, + @JsonProperty("author_signature") String authorSignature, + @JsonProperty("text") String text, + @JsonProperty("entities") MessageEntity[] entities, + @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, + @JsonProperty("effect_id") String effectId, + @JsonProperty("animation") Animation animation, + @JsonProperty("audio") Audio audio, + @JsonProperty("document") Document document, + @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("sticker") Sticker sticker, + @JsonProperty("story") Story story, + @JsonProperty("video") Video video, + @JsonProperty("video_note") VideoNote videoNote, + @JsonProperty("voice") Voice voice, + @JsonProperty("caption") String caption, + @JsonProperty("caption_entities") MessageEntity[] captionEntities, + @JsonProperty("show_caption_above_media") boolean showCaptionAboveMedia, + @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, + @JsonProperty("contact") Contact contact, + @JsonProperty("dice") Dice dice, + @JsonProperty("game") Game game, + @JsonProperty("poll") Poll poll, + @JsonProperty("venue") Venue venue, + @JsonProperty("location") Location location, + @JsonProperty("new_chat_members") User[] newChatMembers, + @JsonProperty("left_chat_member") User leftChatMember, + @JsonProperty("new_chat_title") String newChatTitle, + @JsonProperty("new_chat_photo") PhotoSize[] newChatPhoto, + @JsonProperty("delete_chat_photo") boolean deleteChatPhoto, + @JsonProperty("group_chat_created") boolean groupChatCreated, + @JsonProperty("supergroup_chat_created") boolean supergroupChatCreated, + @JsonProperty("channel_chat_created") boolean channelChatCreated, + @JsonProperty("message_auto_delete_timer_changed") MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged, + @JsonProperty("migrate_to_chat_id") Long migrateToChatId, + @JsonProperty("migrate_from_chat_id") Long migrateFromChatId, + @JsonProperty("pinned_message") MaybeInaccessibleMessage pinnedMessage, + @JsonProperty("invoice") Invoice invoice, + @JsonProperty("successful_payment") SuccessfulPayment successfulPayment, + @JsonProperty("refunded_payment") RefundedPayment refundedPayment, + @JsonProperty("users_shared") UsersShared usersShared, + @JsonProperty("chat_shared") ChatShared chatShared, + @JsonProperty("connected_website") String connectedWebsite, + @JsonProperty("write_access_allowed") WriteAccessAllowed writeAccessAllowed, + @JsonProperty("passport_data") PassportData passportData, + @JsonProperty("proximity_alert_triggered") ProximityAlertTriggered proximityAlertTriggered, + @JsonProperty("boost_added") ChatBoostAdded chatBoostAdded, + @JsonProperty("chat_background_set") ChatBackground chatBackground, + @JsonProperty("forum_topic_created") ForumTopicCreated forumTopicCreated, + @JsonProperty("forum_topic_edited") ForumTopicEdited forumTopicEdited, + @JsonProperty("forum_topic_closed") ForumTopicClosed forumTopicClosed, + @JsonProperty("forum_topic_reopened") ForumTopicReopened forumTopicReopened, + @JsonProperty("general_forum_topic_hidden") GeneralForumTopicHidden generalForumTopicHidden, + @JsonProperty("general_forum_topic_unhidden") GeneralForumTopicUnhidden generalForumTopicUnhidden, + @JsonProperty("giveaway_created") GiveawayCreated giveawayCreated, + @JsonProperty("giveaway") Giveaway giveaway, + @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, + @JsonProperty("giveaway_completed") GiveawayCompleted giveawayCompleted, + @JsonProperty("video_chat_scheduled") VideoChatScheduled videoChatScheduled, + @JsonProperty("video_chat_started") VideoChatStarted videoChatStarted, + @JsonProperty("video_chat_ended") VideoChatEnded videoChatEnded, + @JsonProperty("video_chat_participants_invited") VideoChatParticipantsInvited videoChatParticipantsInvited, + @JsonProperty("web_app_data") WebAppData webAppData, + @JsonProperty("reply_markup") InlineKeyboardMarkup inlineKeyboardMarkup + +) implements MaybeInaccessibleMessage { + + public boolean hasMessageThreadId() { + return messageThreadId != null; + } + + public boolean hasSenderChat() { + return senderChat != null; + } + + public boolean hasSenderBoostCount() { + return senderBoostCount != null; + } + + public boolean hasSenderBusinessBot() { + return senderBusinessBot != null; + } + + public boolean hasBusinessConnectionId() { + return businessConnectionId != null; + } + + public boolean hasForwardOrigin() { + return forwardOrigin != null; + } + + public boolean hasReplyToMessage() { + return replyToMessage != null; + } + + public boolean hasExternalReply() { + return externalReply != null; + } + + public boolean hasQuote() { + return quote != null; + } + + public boolean hasReplyToStory() { + return replyToStory != null; + } + + public boolean hasViaBot() { + return viaBot != null; + } + + public boolean hasEditDate() { + return editDate != 0; + } + + public boolean hasMediaGroupId() { + return mediaGroupId != null; + } + + public boolean hasAuthorSignature() { + return authorSignature != null; + } + + public boolean hasText() { + return text != null; + } + + public boolean hasEntities() { + return entities != null; + } + + public boolean hasLinkPreviewOptions() { + return linkPreviewOptions != null; + } + + public boolean hasEffectId() { + return effectId != null; + } + + public boolean hasAnimation() { + return animation != null; + } + + public boolean hasAudio() { + return audio != null; + } + + public boolean hasDocument() { + return document != null; + } + + public boolean hasPaidMediaInfo() { + return paidMediaInfo != null; + } + + public boolean hasPhoto() { + return photo != null; + } + + public boolean hasSticker() { + return sticker != null; + } + + public boolean hasStory() { + return story != null; + } + + public boolean hasVideo() { + return video != null; + } + + public boolean hasVideoNote() { + return videoNote != null; + } + + public boolean hasVoice() { + return voice != null; + } + + public boolean hasCaption() { + return caption != null; + } + + public boolean hasCaptionEntities() { + return captionEntities != null; + } + + public boolean hasContact() { + return contact != null; + } + + public boolean hasDice() { + return dice != null; + } + + public boolean hasGame() { + return game != null; + } + + public boolean hasPoll() { + return poll != null; + } + + public boolean hasVenue() { + return venue != null; + } + + public boolean hasLocation() { + return location != null; + } + + public boolean hasNewChatMembers() { + return newChatMembers != null; + } + + public boolean hasLeftChatMember() { + return leftChatMember != null; + } + + public boolean hasNewChatTitle() { + return newChatTitle != null; + } + + public boolean hasNewChatPhoto() { + return newChatPhoto != null; + } + + public boolean hasMessageAutoDeleteTimerChanged() { + return messageAutoDeleteTimerChanged != null; + } + + public boolean hasMigrateToChatId() { + return migrateToChatId != null; + } + + public boolean hasMigrateFromChatId() { + return migrateFromChatId != null; + } + + @Override + public long chatId() { + return this.chat.id(); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java new file mode 100644 index 0000000..c0908eb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageAutoDeleteTimerChanged(@JsonProperty("message_auto_delete_time") long messageAutoDeleteTime) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java new file mode 100644 index 0000000..abc075f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageEntity( + @JsonProperty("type") String type, + @JsonProperty("offset") int offset, + @JsonProperty("length") int length, + @JsonProperty("url") String url, + @JsonProperty("user") User user, + @JsonProperty("language") String language, + @JsonProperty("custom_emoji_id") String customEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java new file mode 100644 index 0000000..9de39a2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = MessageOriginUser.class, name = "user"), + @JsonSubTypes.Type(value = MessageOriginHiddenUser.class, name = "hidden_user"), + @JsonSubTypes.Type(value = MessageOriginChat.class, name = "chat"), + @JsonSubTypes.Type(value = MessageOriginChannel.class, name = "channel") +}) +public interface MessageOrigin { + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java new file mode 100644 index 0000000..aeb5c4d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginChannel( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("author_signature") String authorSignature +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java new file mode 100644 index 0000000..3873b5c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginChat( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_chat") Chat senderChat, + @JsonProperty("author_signature") String authorSignature +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java new file mode 100644 index 0000000..1fa924e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginHiddenUser( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_user_name") String senderUserName +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java new file mode 100644 index 0000000..3a19e38 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginUser( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_user") User senderUser +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java new file mode 100644 index 0000000..f389b84 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageReactionCountUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("date") long date, + @JsonProperty("reactions") ReactionCount[] reactions +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java new file mode 100644 index 0000000..7135efb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageReactionUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("user") User user, + @JsonProperty("actor_chat") Chat actorChat, + @JsonProperty("date") long date, + @JsonProperty("old_reaction") ReactionType[] oldReaction, + @JsonProperty("new_reaction") ReactionType[] newReaction +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java new file mode 100644 index 0000000..0a1a389 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.MessageEntity; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record TextQuote(String text, MessageEntity[] entities, int position, + @JsonProperty("is_manual") boolean isManual) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java new file mode 100644 index 0000000..520fdc0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record EncryptedCredentials( + @JsonProperty("data") String data, + @JsonProperty("hash") String hash, + @JsonProperty("secret") String secret +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java new file mode 100644 index 0000000..38dcb8a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record EncryptedPassportElement( + @JsonProperty("type") String type, + @JsonProperty("data") String data, + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("email") String email, + @JsonProperty("files") PassportFile[] files, + @JsonProperty("front_side") PassportFile frontSide, + @JsonProperty("reverse_side") PassportFile reverseSide, + @JsonProperty("selfie") PassportFile selfie, + @JsonProperty("translation") PassportFile[] translation, + @JsonProperty("hash") String hash +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java new file mode 100644 index 0000000..f34b0bb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PassportData( + @JsonProperty("data") EncryptedPassportElement[] data, + @JsonProperty("credentials") EncryptedCredentials credentials +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java new file mode 100644 index 0000000..9019afa --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PassportFile( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("file_size") long fileSize, + @JsonProperty("file_date") long fileDate +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java new file mode 100644 index 0000000..df557d6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Invoice( + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("start_parameter") String startParameter, + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java new file mode 100644 index 0000000..af6dce5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record OrderInfo( + @JsonProperty("name") String name, + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("email") String email, + @JsonProperty("shipping_address") ShippingAddress shippingAddress +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java new file mode 100644 index 0000000..d0037b5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PreCheckoutQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("shipping_option_id") String shippingOptionId, + @JsonProperty("order_info") OrderInfo orderInfo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java new file mode 100644 index 0000000..78ac21a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record RefundedPayment( + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, + @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java new file mode 100644 index 0000000..07c8693 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ShippingAddress( + @JsonProperty("country_code") String countryCode, + @JsonProperty("state") String state, + @JsonProperty("city") String city, + @JsonProperty("street_line1") String firstStreetLine, + @JsonProperty("street_line2") String secondStreetLine, + @JsonProperty("post_code") String postCode +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java new file mode 100644 index 0000000..1d4a95d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ShippingQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("shipping_address") ShippingAddress shippingAddress +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java new file mode 100644 index 0000000..88840ad --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SuccessfulPayment( + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, //price + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("subscription_expiration_date") long subscriptionExpirationDate, + @JsonProperty("is_recurring") boolean isRecurring, + @JsonProperty("is_first_recurring") boolean isFirstRecurring, + @JsonProperty("shipping_option_id") String shippingOptionId, + @JsonProperty("order_info") OrderInfo orderInfo, + @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, + @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java new file mode 100644 index 0000000..b25fd4c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java @@ -0,0 +1,26 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.MessageEntity; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Poll( + @JsonProperty("id") String id, + @JsonProperty("question") String question, + @JsonProperty("question_entities") MessageEntity[] questionEntities, + @JsonProperty("options") PollOption[] options, + @JsonProperty("total_voter_count") int totalVoterCount, + @JsonProperty("is_closed") boolean isClosed, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("type") String type, + @JsonProperty("allows_multiple_answers") boolean allowMultipleAnswers, + @JsonProperty("correct_option_id") int correctOptionId, + @JsonProperty("explanation") String explanation, + @JsonProperty("explanation_entities") MessageEntity[] explanationEntities, + @JsonProperty("open_period") long openPeriod, + @JsonProperty("close_date") long closeDate +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java new file mode 100644 index 0000000..05bab19 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PollAnswer( + @JsonProperty("poll_id") String pollId, + @JsonProperty("voter_chat") Chat voterChat, + @JsonProperty("user") User user, + @JsonProperty("option_ids") int[] optionsIds +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java new file mode 100644 index 0000000..2e09c91 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.MessageEntity; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PollOption( + @JsonProperty("text") String text, + @JsonProperty("text_entities") MessageEntity[] textEntities, + @JsonProperty("voter_count") int voterCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java new file mode 100644 index 0000000..3d0ec3c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionCount( + @JsonProperty("type") ReactionType type, + @JsonProperty("total_count") int totalCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java new file mode 100644 index 0000000..93a2a1d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ReactionTypeEmoji.class, name = "emoji"), + @JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = "custom_emoji"), + @JsonSubTypes.Type(value = ReactionTypePaid.class, name = "paid") +}) +public interface ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java new file mode 100644 index 0000000..8c9a561 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypeCustomEmoji( + @JsonProperty("type") String type, + @JsonProperty("custom_emoji_id") String customEmojiId +) implements ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java new file mode 100644 index 0000000..8d483bf --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypeEmoji( + @JsonProperty("type") String type, + @JsonProperty("emoji") String emoji +) implements ReactionType { + public ReactionTypeEmoji(String emoji) { + this("emoji", emoji); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java new file mode 100644 index 0000000..645b4f5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.core.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypePaid( + @JsonProperty("type") String type +) implements ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java new file mode 100644 index 0000000..4808610 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java @@ -0,0 +1,30 @@ +package hdvtdev.telegram.exceptions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class TelegramApiException extends IllegalArgumentException { + + public TelegramApiException(String message) { + super(message); + } + + public TelegramApiException() { + super(); + } + + public TelegramApiException(ErrorResponse errorResponse) { + super(errorResponse.description); + } + + public TelegramApiException(Throwable throwable) { + super(throwable); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public record ErrorResponse(boolean ok, @JsonProperty("error_code") int errorCode, String description) { + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java new file mode 100644 index 0000000..8ee9c6a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.exceptions; + +import java.io.IOException; + +public class TelegramApiNetworkException extends RuntimeException { + public TelegramApiNetworkException(String message) { + super(message); + } + + public TelegramApiNetworkException(IOException e) { + super(e); + } + + public TelegramApiNetworkException(String s, IOException e) { + super(s, e); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java new file mode 100644 index 0000000..cad5c01 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java @@ -0,0 +1,11 @@ +package hdvtdev.telegram.exceptions; + +public class TelegramMethodParsingException extends RuntimeException { + public TelegramMethodParsingException(String message) { + super(message); + } + + public TelegramMethodParsingException(Throwable throwable) { + super(throwable); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java new file mode 100644 index 0000000..3c983b2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java @@ -0,0 +1,113 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Game; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to send answers to callback queries sent from inline keyboards. + * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. + * Alternatively, the user can be redirected to the specified {@link Game} URL. + * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote On success, {@code Boolean == true} is returned. + * @since 1.0.0 + */ + +@NotTested +public class AnswerCallbackQuery implements TelegramApiMethod { + + /** + * Unique identifier for the query to be answered + */ + private final String callbackQueryId; + /** + * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters + */ + private String text; + /** + * If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. + */ + private Boolean showAlert; + /** + * URL that will be opened by the user's client. + * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. + * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * @apiNote this will only work if the query comes from a callback_game button. + */ + private String url; + /** + * The maximum amount of time in seconds that the result of the callback query may be cached client-side. + * Telegram apps will support caching starting in version 3.14. Defaults to 0. + */ + private Integer cacheTime; + + public AnswerCallbackQuery(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + private AnswerCallbackQuery(Builder builder) { + callbackQueryId = builder.callbackQueryId; + text = builder.text; + showAlert = builder.showAlert; + url = builder.url; + cacheTime = builder.cacheTime; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); + if (text != null) builder.add("text", this.text); + if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); + if (url != null) builder.add("url", this.url); + if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "answerCallbackQuery"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String callbackQueryId; + private String text; + private Boolean showAlert; + private String url; + private Integer cacheTime; + + public Builder(String callbackQueryId) { + this.callbackQueryId = callbackQueryId; + } + + public Builder text(String text) { + this.text = text; + return this; + } + + public Builder showAlert(Boolean showAlert) { + this.showAlert = showAlert; + return this; + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder cacheTime(Integer cacheTime) { + this.cacheTime = cacheTime; + return this; + } + + public AnswerCallbackQuery build() { + return new AnswerCallbackQuery(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java new file mode 100644 index 0000000..7438c51 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java @@ -0,0 +1,51 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.Chat; +import hdvtdev.telegram.objects.User; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to approve a chat join request. + * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. + * Returns True on success. + * @param chatId Unique username of the target channel in the format @channelusername + * @param userId Unique identifier of the target user + * @see ChatAdministratorRights + * @see Chat + * @see Chat#id() + * @since 0.1.0 + */ +@NotTested +public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { + + /** + * @param chatId Unique identifier for the target chat + * @param userId Unique identifier of the target user + * @see User#id() + * @see Chat#id() + */ + public ApproveChatJoinRequest(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "approveChatJoinRequest"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java new file mode 100644 index 0000000..a0829fb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java @@ -0,0 +1,110 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to ban a user in a group, a supergroup or a channel. + * In the case of supergroups and channels, the user will not be able to return + * to the chat on their own using invite links, etc., unless unbanned first. + * The bot must be an administrator in the chat for this to work and must have + * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. + * @see ChatAdministratorRights + * @since 0.1.1 + */ +@NotTested +public final class BanChatMember implements TelegramApiMethod { + + /** + * Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) + */ + private final String chatId; + /** + * Unique identifier of the target user + */ + private final long userId; + /** + * Date when the user will be unbanned; Unix time. + * If user is banned for more than 366 days or less than 30 seconds from + * the current time they are considered to be banned forever. + * Applied for supergroups and channels only. + */ + private Long untilDate; + /** + * Pass true to delete all messages from the chat for the user that is being removed. + * If false, the user will be able to see messages in the group that were sent before the user was removed. + * Always True for supergroups and channels. + */ + private Boolean revokeMessages; + + public BanChatMember(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public BanChatMember(long chatId, long userId) { + this.chatId = String.valueOf(chatId); + this.userId = userId; + } + + private BanChatMember(Builder builder) { + chatId = builder.chatId; + userId = builder.userId; + setUntilDate(builder.untilDate); + setRevokeMessages(builder.revokeMessages); + } + + public void setUntilDate(Long untilDate) { + this.untilDate = untilDate; + } + + public void setRevokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); + if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); + if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "banChatMember"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long userId; + private Long untilDate; + private Boolean revokeMessages; + + public Builder(String chatId, long userId) { + this.chatId = chatId; + this.userId = userId; + } + + public Builder untilDate(Long untilDate) { + this.untilDate = untilDate; + return this; + } + + public Builder revokeMessages(Boolean revokeMessages) { + this.revokeMessages = revokeMessages; + return this; + } + + public BanChatMember build() { + return new BanChatMember(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java new file mode 100644 index 0000000..5bb2d4b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to ban a channel chat in a supergroup or a channel. + * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of + * their channels. The bot must be an administrator in the supergroup or channel for this to + * work and must have the appropriate administrator rights. Returns True on success. + * @since 1.0.0 + */ +@NotTested +public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public BanChatSenderChat(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "banChatSenderChat"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java new file mode 100644 index 0000000..36d35b0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, + * unless it is the creator of the topic. Returns {@code true} on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @see ChatAdministratorRights#canManageTopics() + */ +@NotTested +public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { + + public CloseForumTopic(long chatId, long messageThreadId) { + this(String.valueOf(chatId), messageThreadId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); + } + + @Override + public String getMethodName() { + return "closeForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java new file mode 100644 index 0000000..17cff82 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatAdministratorRights; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to close an open 'General' topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. + * Returns {@code true} on success. + * @see ChatAdministratorRights#canManageTopics() + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + */ +@NotTested +public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { + + public CloseGeneralForumTopic(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "closeGeneralForumTopic"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java new file mode 100644 index 0000000..46ece7d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java @@ -0,0 +1,244 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.MessageEntity; +import hdvtdev.telegram.objects.Poll; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. + * Returns the messageId as {@link Long} of the sent message on success. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@NotTested +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + @JsonProperty("caption") + private String caption; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("caption_entities") + private List captionEntities; + @JsonProperty("show_caption_above_media") + private Boolean showCaptionAboveMedia; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public CopyMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public CopyMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public CopyMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + public CopyMessage(String chatId, long fromChatId, long messageId) { + this(chatId, String.valueOf(fromChatId), messageId); + } + + private CopyMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setVideoStartTimestamp(builder.videoStartTimestamp); + setCaption(builder.caption); + setParseMode(builder.parseMode); + setCaptionEntities(builder.captionEntities); + setShowCaptionAboveMedia(builder.showCaptionAboveMedia); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + public void setCaption(String caption) { + this.caption = caption; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setCaptionEntities(List captionEntities) { + this.captionEntities = captionEntities; + } + + public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private long videoStartTimestamp; + private String caption; + private ParseMode parseMode; + private List captionEntities; + private Boolean showCaptionAboveMedia; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public Builder caption(String caption) { + this.caption = caption; + return this; + } + + public Builder parseMode(ParseMode parseMode) { + this.parseMode = parseMode; + return this; + } + + public Builder captionEntities(List captionEntities) { + this.captionEntities = captionEntities; + return this; + } + + public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) { + this.showCaptionAboveMedia = showCaptionAboveMedia; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + return this; + } + + public Builder replyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + return this; + } + + public Builder replyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + return this; + } + + public CopyMessage build() { + return new CopyMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java new file mode 100644 index 0000000..ceafa51 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java @@ -0,0 +1,181 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Poll; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to copy messages of any kind. + * If some of the specified messages can't be found or copied, they are skipped. + * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. + * Album grouping is kept for copied messages. + * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. + * @see Poll#correctOptionId() + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class CopyMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("remove_caption") + private Boolean removeCaption; + + /** + * @param chatId Username of the target channel (in the format @channelusername) + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + /** + * @param chatId Unique identifier for the target chat + * @param fromChatId Unique identifier for the chat where the original messages were sent + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + /** + * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param fromChatId Unique identifier for the target chat + * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + */ + public CopyMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + private CopyMessages(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setRemoveCaption(builder.removeCaption); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setRemoveCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "copyMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean removeCaption; + + public Builder(String chatId, String fromChatId, List messageIds) { + this.chatId = chatId; + this.fromChatId = fromChatId; + ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); + sortedMessageIds.sort(null); + this.messageIds = sortedMessageIds; + } + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder removeCaption(Boolean removeCaption) { + this.removeCaption = removeCaption; + return this; + } + + public CopyMessages build() { + return new CopyMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java new file mode 100644 index 0000000..8294d9a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java @@ -0,0 +1,114 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.objects.ChatAdministratorRights; +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to create an additional invite link for a chat. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. + * @see ChatAdministratorRights#canInviteUsers() + */ +public final class CreateChatInviteLink implements TelegramApiMethod { + + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public CreateChatInviteLink(String chatId) { + this.chatId = chatId; + } + + public CreateChatInviteLink(long chatId) { + this(String.valueOf(chatId)); + } + + private CreateChatInviteLink(Builder builder) { + chatId = builder.chatId; + setName(builder.name); + setExpireDate(builder.expireDate); + setMemberLimit(builder.memberLimit); + setCreatesJoinRequest(builder.createsJoinRequest); + } + + public void setName(String name) { + this.name = name; + } + + public void setExpireDate(Long expireDate) { + this.expireDate = expireDate; + } + + public void setMemberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + } + + public void setCreatesJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + } + + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId); + if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate)); + if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit)); + if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest)); + return builder.build(); + } + + @Override + public String getMethodName() { + return "createChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } + + public static final class Builder { + private final String chatId; + private String name; + private Long expireDate; + private Integer memberLimit; + private Boolean createsJoinRequest; + + public Builder(String chatId) { + this.chatId = chatId; + } + + public Builder(long chatId) { + this(String.valueOf(chatId)); + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder expireDate(Long expireDate) { + this.expireDate = expireDate; + return this; + } + + public Builder memberLimit(Integer memberLimit) { + this.memberLimit = memberLimit; + return this; + } + + public Builder createsJoinRequest(Boolean createsJoinRequest) { + this.createsJoinRequest = createsJoinRequest; + return this; + } + + public CreateChatInviteLink build() { + return new CreateChatInviteLink(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java new file mode 100644 index 0000000..4f43654 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +/** + * Use this method to forward messages of any kind. + * Service messages and messages with protected content can't be forwarded. + * On success, the sent {@link Message} is returned. + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("video_start_timestamp") + private long videoStartTimestamp; + + public ForwardMessage(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public ForwardMessage(long chatId, String fromChatId, long messageId) { + this(String.valueOf(chatId), fromChatId, messageId); + } + + public ForwardMessage(long chatId, long fromChatId, long messageId) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); + } + + private ForwardMessage(Builder builder) { + chatId = builder.chatId; + setMessageThreadId(builder.messageThreadId); + fromChatId = builder.fromChatId; + messageId = builder.messageId; + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setVideoStartTimestamp(builder.videoStartTimestamp); + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setVideoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final long messageId; + private Boolean disableNotification; + private Boolean protectContent; + private long videoStartTimestamp; + + public Builder(String chatId, String fromChatId, long messageId) { + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageId = messageId; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(Boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public Builder videoStartTimestamp(long videoStartTimestamp) { + this.videoStartTimestamp = videoStartTimestamp; + return this; + } + + public ForwardMessage build() { + return new ForwardMessage(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java new file mode 100644 index 0000000..664566f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java @@ -0,0 +1,147 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.Message; + +import okhttp3.RequestBody; + +import java.util.ArrayList; +import java.util.List; + +/** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. + * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. + * On success, an array of MessageId as {@link Long} of the sent messages is returned. + * @see Message#hasProtectedContent() + */ +@Jsonable +@NotTested +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class ForwardMessages implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("from_chat_id") + private final String fromChatId; + @JsonProperty("message_id") + private final List messageIds; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + + public ForwardMessages(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public ForwardMessages(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public ForwardMessages(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public ForwardMessages(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + private ForwardMessages(Builder builder) { + chatId = builder.chatId; + messageThreadId = builder.messageThreadId; + fromChatId = builder.fromChatId; + messageIds = builder.messageIds; + disableNotification = builder.disableNotification; + protectContent = builder.protectContent; + } + + public void setMessageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setDisableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(boolean protectContent) { + this.protectContent = protectContent; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "forwardMessages"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Long[].class; + } + + + public static final class Builder { + private final String chatId; + private Long messageThreadId; + private final String fromChatId; + private final List messageIds; + private Boolean disableNotification; + private Boolean protectContent; + + public Builder(String chatId, String fromChatId, List messageIds) { + ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); + sortedMessageIds.sort(null); + this.chatId = chatId; + this.fromChatId = fromChatId; + this.messageIds = sortedMessageIds; + } + + public Builder(long chatId, String fromChatId, List messageIds) { + this(String.valueOf(chatId), fromChatId, messageIds); + } + + public Builder(String chatId, long fromChatId, List messageIds) { + this(chatId, String.valueOf(fromChatId), messageIds); + } + + public Builder(long chatId, long fromChatId, List messageIds) { + this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); + } + + public Builder messageThreadId(long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public Builder disableNotification(boolean disableNotification) { + this.disableNotification = disableNotification; + return this; + } + + public Builder protectContent(boolean protectContent) { + this.protectContent = protectContent; + return this; + } + + public ForwardMessages build() { + return new ForwardMessages(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java new file mode 100644 index 0000000..231c2bc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java @@ -0,0 +1,36 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.annotations.util.NotTested; +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. + * @param chatId + */ +@NotTested +public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { + + public GetChatAdministrators(long chatId) { + this(String.valueOf(chatId)); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).build(); + } + + @Override + public String getMethodName() { + return "getChatAdministrators"; + } + + @Override + public Class getResponseClass() { + return ChatMember[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java new file mode 100644 index 0000000..fee4dd3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.objects.ChatMember; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { + + public GetChatMember(long chatId, long userId) { + this(String.valueOf(chatId), userId); + } + + public GetChatMember(String chatId, String userId) { + this(chatId, Long.parseLong(userId)); + } + + public GetChatMember(long chatId, String userId) { + this(String.valueOf(chatId), userId); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + } + + @Override + public String getMethodName() { + return "getChatMember"; + } + + @Override + public Class getResponseClass() { + return ChatMember.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetFile.java b/core/src/main/java/hdvtdev/telegram/methods/GetFile.java new file mode 100644 index 0000000..c29f5df --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetFile.java @@ -0,0 +1,23 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.objects.TelegramFile; +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record GetFile(String fileId) implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("file_id", fileId).build(); + } + + @Override + public String getMethodName() { + return "getFile"; + } + + @Override + public Class getResponseClass() { + return TelegramFile.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMe.java b/core/src/main/java/hdvtdev/telegram/methods/GetMe.java new file mode 100644 index 0000000..224bbae --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetMe.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.objects.User; +import okhttp3.RequestBody; + +public final class GetMe implements TelegramApiMethod { + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + return "getMe"; + } + + @Override + public Class getResponseClass() { + return User.Bot.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java new file mode 100644 index 0000000..abd0400 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java @@ -0,0 +1,58 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; + +import okhttp3.RequestBody; + +/** + * Use this method to get the current list of the bot's commands for the given scope and user language. + * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. + * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. + * @param languageCode A two-letter ISO 639-1 language code or an empty string + * @see BotCommandScope + * @since 1.0.0 + */ +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public record GetMyCommands( + @JsonProperty("scope") BotCommandScope scope, + @JsonProperty("language_code") String languageCode +) implements TelegramApiMethod { + + public GetMyCommands() { + this(null, null); + } + + public GetMyCommands(String languageCode) { + this(null, languageCode); + } + + public GetMyCommands(BotCommandScope scope) { + this(scope, null); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "getMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return BotCommand[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java new file mode 100644 index 0000000..2c74024 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.methods; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +public record GetMyDescription(String languageCode) implements TelegramApiMethod { + + public GetMyDescription() { + this(null); + } + + @Override + public RequestBody getBody() { + return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyDescription"; + } + + @Override + public Class getResponseClass() { + return BotDescription.class; + } + + public record BotDescription(String description) { + @NotNull + @Override + public String toString() { + return description; + } + + public boolean isEmpty() { + return description.isEmpty(); + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java new file mode 100644 index 0000000..1e76f28 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java @@ -0,0 +1,38 @@ +package hdvtdev.telegram.methods; + +import okhttp3.FormBody; +import okhttp3.RequestBody; +import org.jetbrains.annotations.NotNull; + +public record GetMyName(String languageCode) implements TelegramApiMethod { + + public GetMyName() { + this(null); + } + + @Override + public RequestBody getBody() { + return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build(); + } + + @Override + public String getMethodName() { + return "getMyName"; + } + + @Override + public Class getResponseClass() { + return BotName.class; + } + + public record BotName(String name) { + + @NotNull + @Override + public String toString() { + return this.name; + } + + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java b/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java new file mode 100644 index 0000000..7dfcf74 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java @@ -0,0 +1,42 @@ +package hdvtdev.telegram.methods; + + +import hdvtdev.telegram.objects.Update; +import okhttp3.RequestBody; + +import java.util.ArrayList; + +public record GetUpdates( + Long offset, + Integer limit, + Integer timeout +) implements TelegramApiMethod { + + public GetUpdates() { + this(null, null, null); + } + + @Override + public RequestBody getBody() { + return null; + } + + @Override + public String getMethodName() { + ArrayList params = new ArrayList<>(3); + if (offset != null) params.add("offset=" + offset); + if (limit != null) params.add("limit=" + limit); + if (timeout != null) params.add("timeout=" + timeout); + + if (params.isEmpty()) { + return "getUpdates"; + } else { + return "getUpdates?" + String.join("&", params); + } + } + + @Override + public Class getResponseClass() { + return Update[].class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java new file mode 100644 index 0000000..e201091 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.methods; + +import hdvtdev.telegram.objects.ChatInviteLink; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; + +/** + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * Returns the revoked invite link as {@link ChatInviteLink} object. + * @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername) + * @param link The invite link to revoke + */ +public record RevokeChatInviteLink(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod { + + public RevokeChatInviteLink(long chatId, @NotNull String link) { + this(String.valueOf(chatId), link); + } + + @Override + public RequestBody getBody() { + return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); + } + + @Override + public String getMethodName() { + return "revokeChatInviteLink"; + } + + @Override + public Class getResponseClass() { + return ChatInviteLink.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java new file mode 100644 index 0000000..871c195 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java @@ -0,0 +1,104 @@ +package hdvtdev.telegram.methods; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public final class SendChatAction implements TelegramApiMethod { + + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { + this.businessConnectionId = businessConnectionId; + this.chatId = chatId; + this.messageThreadId = messageThreadId; + this.chatAction = chatAction; + } + + public SendChatAction(String chatId, ChatAction chatAction) { + this(null, chatId, null, chatAction); + } + + public SendChatAction(long chatId, ChatAction chatAction) { + this(String.valueOf(chatId), chatAction); + } + + private SendChatAction(Builder builder) { + this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction); + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + @Override + public RequestBody getBody() { + + FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); + + if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); + if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); + + return builder.build(); + } + + @Override + public String getMethodName() { + return "sendChatAction"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public enum ChatAction { + TYPING, + UPLOAD_PHOTO, + RECORD_VIDEO, + UPLOAD_VIDEO, + RECORD_VOICE, + UPLOAD_VOICE, + UPLOAD_DOCUMENT, + UPLOAD_FILE, + CHOOSE_STICKER, + FIND_LOCATION, + RECORD_VIDEO_NOTE, + UPLOAD_VIDEO_NOTE + } + + public static final class Builder { + private String businessConnectionId; + private final String chatId; + private Long messageThreadId; + private final ChatAction chatAction; + + public Builder(String chatId, ChatAction chatAction) { + this.chatId = chatId; + this.chatAction = chatAction; + } + + public Builder businessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + return this; + } + + public Builder messageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + return this; + } + + public SendChatAction build() { + return new SendChatAction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendDice.java b/core/src/main/java/hdvtdev/telegram/methods/SendDice.java new file mode 100644 index 0000000..e71c879 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SendDice.java @@ -0,0 +1,133 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.ReplyMarkup; +import hdvtdev.telegram.objects.ReplyParameters; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendDice implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("emoji") + private String emoji; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + public SendDice(String chatId) { + this.chatId = chatId; + } + + public SendDice(long chatId) { + this(String.valueOf(chatId)); + } + + public SendDice(String chatId, Emoji emoji) { + this.emoji = emoji.getEmoji(); + this.chatId = chatId; + } + + public SendDice(long chatId, Emoji emoji) { + this(String.valueOf(chatId), emoji); + } + + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setEmoji(Emoji emoji) { + this.emoji = emoji.getEmoji(); + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendDice"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public enum Emoji { + DICE("🎲"), + DART("🎯"), + BASKETBALL("🏀"), + FOOTBALL("⚽"), + BOWLING("🎳"), + SLOT_MACHINE("🎰"); + + private final String emoji; + + Emoji(String emoji) { + this.emoji = emoji; + } + + public String getEmoji() { + return emoji; + } + + } + + + +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java b/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java new file mode 100644 index 0000000..8c67974 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java @@ -0,0 +1,226 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.*; +import hdvtdev.telegram.util.ParseMode; + +import okhttp3.RequestBody; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SendMessage implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("text") + private final String text; + @JsonProperty("business_connection_id") + private String businessConnectionId; + @JsonProperty("message_thread_id") + private Long messageThreadId; + @JsonProperty("parse_mode") + private ParseMode parseMode; + @JsonProperty("entities") + private MessageEntity[] entities; + @JsonProperty("link_preview_options") + private LinkPreviewOptions linkPreviewOptions; + @JsonProperty("disable_notification") + private Boolean disableNotification; + @JsonProperty("protect_content") + private Boolean protectContent; + @JsonProperty("allow_paid_broadcast") + private Boolean allowPaidBroadcast; + @JsonProperty("message_effect_id") + private String messageEffectId; + @JsonProperty("reply_parameters") + private ReplyParameters replyParameters; + @JsonProperty("reply_markup") + private ReplyMarkup replyMarkup; + + private SendMessage(Builder builder) { + chatId = builder.chatId; + text = builder.text; + setBusinessConnectionId(builder.businessConnectionId); + setMessageThreadId(builder.messageThreadId); + setParseMode(builder.parseMode); + setEntities(builder.entities); + setLinkPreviewOptions(builder.linkPreviewOptions); + setDisableNotification(builder.disableNotification); + setProtectContent(builder.protectContent); + setAllowPaidBroadcast(builder.allowPaidBroadcast); + setMessageEffectId(builder.messageEffectId); + setReplyParameters(builder.replyParameters); + setReplyMarkup(builder.replyMarkup); + } + + public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { + this.linkPreviewOptions = linkPreviewOptions; + } + + public void setBusinessConnectionId(String businessConnectionId) { + this.businessConnectionId = businessConnectionId; + } + + public void setMessageThreadId(Long messageThreadId) { + this.messageThreadId = messageThreadId; + } + + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + public void setEntities(MessageEntity[] entities) { + this.entities = entities; + } + + public void setDisableNotification(Boolean disableNotification) { + this.disableNotification = disableNotification; + } + + public void setProtectContent(Boolean protectContent) { + this.protectContent = protectContent; + } + + public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { + this.allowPaidBroadcast = allowPaidBroadcast; + } + + public void setMessageEffectId(String messageEffectId) { + this.messageEffectId = messageEffectId; + } + + public void setReplyParameters(ReplyParameters replyParameters) { + this.replyParameters = replyParameters; + } + + public void setReplyToMessage(long messageId) { + this.replyParameters = new ReplyParameters(messageId, chatId); + } + + public void setReplyMarkup(ReplyMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + public SendMessage(String chatId, String text) { + if (chatId.isEmpty() || text.isEmpty()) + throw new IllegalArgumentException("chatId or/and message (text) cannot be empty."); + this.chatId = chatId; + this.text = text; + } + + public SendMessage(long chatIdAsLong, String text) { + this(String.valueOf(chatIdAsLong), text); + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "sendMessage"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Message.class; + } + + public static final class Builder { + private final String chatId; + private final String text; + private String businessConnectionId; + private Long messageThreadId; + private ParseMode parseMode; + private MessageEntity[] entities; + private LinkPreviewOptions linkPreviewOptions; + private Boolean disableNotification; + private Boolean protectContent; + private Boolean allowPaidBroadcast; + private String messageEffectId; + private ReplyParameters replyParameters; + private ReplyMarkup replyMarkup; + + public Builder(long chatId, String text) { + this(String.valueOf(chatId), text); + } + + public Builder(String chatId, String text) { + this.chatId = chatId; + this.text = text; + } + + public Builder businessConnectionId(String val) { + businessConnectionId = val; + return this; + } + + public Builder messageThreadId(Long val) { + messageThreadId = val; + return this; + } + + public Builder parseMode(ParseMode val) { + parseMode = val; + return this; + } + + public Builder entities(MessageEntity[] val) { + entities = val; + return this; + } + + public Builder linkPreviewOptions(LinkPreviewOptions val) { + linkPreviewOptions = val; + return this; + } + + public Builder disableNotification() { + disableNotification = true; + return this; + } + + public Builder protectContent() { + protectContent = true; + return this; + } + + public Builder allowPaidBroadcast() { + allowPaidBroadcast = true; + return this; + } + + public Builder messageEffectId(String val) { + messageEffectId = val; + return this; + } + + public Builder replyParameters(ReplyParameters val) { + replyParameters = val; + return this; + } + + public Builder replyToMessage(long val) { + replyParameters = new ReplyParameters(val, this.chatId); + return this; + } + + public Builder replyMarkup(ReplyMarkup val) { + replyMarkup = val; + return this; + } + + public SendMessage build() { + return new SendMessage(this); + } + } +} + diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java new file mode 100644 index 0000000..2cf41ea --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.ReactionType; + +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SetMessageReaction implements TelegramApiMethod { + + @JsonProperty("chat_id") + private final String chatId; + @JsonProperty("message_id") + private final long messageId; + @JsonProperty("reaction") + private List reactions; + @JsonProperty("is_big") + private Boolean isBig; + + public SetMessageReaction(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public SetMessageReaction(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + private SetMessageReaction(Builder builder) { + chatId = builder.chatId; + messageId = builder.messageId; + setReactions(builder.reactions); + isBig = builder.isBig; + } + + public void setReactions(List reactions) { + this.reactions = reactions; + } + + public void setBig(Boolean big) { + isBig = big; + } + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMessageReaction"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + public static final class Builder { + private final String chatId; + private final long messageId; + private List reactions; + private Boolean isBig; + + public Builder(String chatId, long messageId) { + this.chatId = chatId; + this.messageId = messageId; + } + + public Builder(long chatId, long messageId) { + this.chatId = String.valueOf(chatId); + this.messageId = messageId; + } + + public Builder reactions(List reactions) { + this.reactions = reactions; + return this; + } + + public Builder isBig(Boolean isBig) { + this.isBig = isBig; + return this; + } + + public SetMessageReaction build() { + return new SetMessageReaction(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java new file mode 100644 index 0000000..6fa9fbf --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java @@ -0,0 +1,100 @@ +package hdvtdev.telegram.methods; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.objects.bot.BotCommand; +import hdvtdev.telegram.objects.bot.BotCommandScope; +import okhttp3.RequestBody; + +import java.util.List; + +@Jsonable +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class SetMyCommands implements TelegramApiMethod { + + @JsonProperty("commands") + private final List commands; + @JsonProperty("scope") + private Object scope; + @JsonProperty("language_code") + private String languageCode; + + public SetMyCommands(List commands, Object scope, String languageCode) { + this.commands = commands; + this.scope = scope; + this.languageCode = languageCode; + } + + public SetMyCommands(BotCommand... commands) { + this.commands = List.of(commands); + } + + public SetMyCommands(List commands) { + this.commands = commands; + } + + private SetMyCommands(Builder builder) { + commands = builder.commands; + setScope(builder.scope); + setLanguageCode(builder.languageCode); + } + + public void setScope(Object scope) { + this.scope = scope; + } + + public void setLanguageCode(String languageCode) { + this.languageCode = languageCode; + } + + + @JsonIgnore + @Override + public RequestBody getBody() { + return null; + } + + @JsonIgnore + @Override + public String getMethodName() { + return "setMyCommands"; + } + + @JsonIgnore + @Override + public Class getResponseClass() { + return Boolean.class; + } + + + public static final class Builder { + private final List commands; + private Object scope; + private String languageCode; + + public Builder(List commands) { + this.commands = commands; + } + + public Builder(BotCommand... commands) { + this.commands = List.of(commands); + } + + public Builder scope(BotCommandScope scope) { + this.scope = scope; + return this; + } + + public Builder languageCode(String languageCode) { + this.languageCode = languageCode; + return this; + } + + public SetMyCommands build() { + return new SetMyCommands(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java new file mode 100644 index 0000000..8757cc7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java @@ -0,0 +1,41 @@ +package hdvtdev.telegram.methods; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +/** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. + * Returns {@code true} on success. + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. + */ +public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { + + public SetMyDescription() { + this(null, null); + } + + public SetMyDescription(String description) { + this(description, null); + } + + @Override + public RequestBody getBody() { + if (description == null) { + return null; + } + FormBody.Builder builder = new FormBody.Builder().add("description", description); + if (languageCode != null) builder.add("language_code", languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyDescription"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java new file mode 100644 index 0000000..536002c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.methods; + +import okhttp3.FormBody; +import okhttp3.RequestBody; + +public record SetMyName(String name, String languageCode) implements TelegramApiMethod { + + public SetMyName(String name) { + this(name, null); + } + + @Override + public RequestBody getBody() { + FormBody.Builder builder = new FormBody.Builder().add("name", this.name); + if (languageCode != null) builder.add("language_code", this.languageCode); + return builder.build(); + } + + @Override + public String getMethodName() { + return "setMyName"; + } + + @Override + public Class getResponseClass() { + return Boolean.class; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java new file mode 100644 index 0000000..268f6db --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.methods; + +import okhttp3.RequestBody; + +public interface TelegramApiMethod { + + RequestBody getBody(); + + String getMethodName(); + + Class getResponseClass(); + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Animation.java b/core/src/main/java/hdvtdev/telegram/objects/Animation.java new file mode 100644 index 0000000..e5c3785 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Animation.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public record Animation( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") Long fileSize +) { + + public boolean hasThumbnail() { + return this.thumbnail != null; + } + + public boolean hasFileName() { + return this.fileName != null; + } + + public boolean hasMimeType() { + return this.mimeType != null; + } + + public boolean hasFileSize() { + return this.fileSize != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Audio.java b/core/src/main/java/hdvtdev/telegram/objects/Audio.java new file mode 100644 index 0000000..591f8be --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Audio.java @@ -0,0 +1,37 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Audio( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("duration") int duration, + @JsonProperty("performer") String performer, + @JsonProperty("title") String title, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") Long fileSize, + @JsonProperty("thumbnail") PhotoSize thumbnail +) { + + public boolean hasThumbnail() { + return this.thumbnail != null; + } + + public boolean hasFileName() { + return this.fileName != null; + } + + public boolean hasMimeType() { + return this.mimeType != null; + } + + public boolean hasFileSize() { + return this.fileSize != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java new file mode 100644 index 0000000..94fe350 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BackgroundFillSolid.class, name = "solid"), + @JsonSubTypes.Type(value = BackgroundFillGradient.class, name = "gradient"), + @JsonSubTypes.Type(value = BackgroundFillFreeformGradient.class, name = "freeform_gradient") +}) +public interface BackgroundFill { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java new file mode 100644 index 0000000..6e9c38d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillFreeformGradient( + @JsonProperty("type") String type, + @JsonProperty("colors") int[] colors +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java new file mode 100644 index 0000000..a1573fe --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillGradient( + @JsonProperty("type") String type, + @JsonProperty("top_color") int topColor, + @JsonProperty("bottom_color") int bottomColor, + @JsonProperty("rotation_angle") int rotationAngle +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java new file mode 100644 index 0000000..c2bfba8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundFillSolid( + @JsonProperty("type") String type, + @JsonProperty("color") int color +) implements BackgroundFill { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java new file mode 100644 index 0000000..9b3c347 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BackgroundTypeFill.class, name = "fill"), + @JsonSubTypes.Type(value = BackgroundTypeWallpaper.class, name = "wallpaper"), + @JsonSubTypes.Type(value = BackgroundTypePattern.class, name = "pattern"), + @JsonSubTypes.Type(value = BackgroundTypeChatTheme.class, name = "chat_theme") +}) +public interface BackgroundType { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java new file mode 100644 index 0000000..1d7323d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeChatTheme( + @JsonProperty("type") String type, + @JsonProperty("theme_name") String themeName +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java new file mode 100644 index 0000000..00efd83 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeFill( + @JsonProperty("type") String type, + @JsonProperty("fill") BackgroundFill fill, + @JsonProperty("dark_theme_dimming") int darkThemeDimming +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java new file mode 100644 index 0000000..201eef1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypePattern( + @JsonProperty("type") String type, + @JsonProperty("document") Document document, + @JsonProperty("fill") BackgroundFill fill, + @JsonProperty("is_inverted") boolean isInverted, + @JsonProperty("is_moving") boolean isMoving +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java new file mode 100644 index 0000000..da3a7ef --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BackgroundTypeWallpaper( + @JsonProperty("type") String type, + @JsonProperty("document") Document document, + @JsonProperty("dark_theme_dimming") int darkThemeDimming, + @JsonProperty("is_blurred") boolean isBlurred, + @JsonProperty("is_moving") boolean isMoving +) implements BackgroundType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java b/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java new file mode 100644 index 0000000..2917f45 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BusinessConnection( + @JsonProperty("id") String id, + @JsonProperty("user") User user, + @JsonProperty("user_chat_id") long userChatId, + @JsonProperty("date") long date, + @JsonProperty("can_reply") boolean canReply, + @JsonProperty("is_enabled") boolean isEnabled +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java b/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java new file mode 100644 index 0000000..06a4536 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BusinessMessagesDeleted( + @JsonProperty("business_connection_id") String businessConnectionId, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_ids") long[] messageIds +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java b/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java new file mode 100644 index 0000000..4213d42 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CallbackGame() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java b/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java new file mode 100644 index 0000000..add7ba0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java @@ -0,0 +1,39 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CallbackQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("message") MaybeInaccessibleMessage message, + @JsonProperty("inline_message_id") String inlineMessageId, + @JsonProperty("chat_instance") String chatInstance, + @JsonProperty("data") String data, + @JsonProperty("game_short_name") String gameShortName +) { + + public boolean hasMessage() { + return this.message != null; + } + + public boolean hasInlineMessageId() { + return this.inlineMessageId != null; + } + + public boolean hasChatInstance() { + return this.chatInstance != null; + } + + public boolean hasData() { + return this.data != null; + } + + public boolean hasGameShortName() { + return this.gameShortName != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Chat.java b/core/src/main/java/hdvtdev/telegram/objects/Chat.java new file mode 100644 index 0000000..4d15355 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Chat.java @@ -0,0 +1,35 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Chat( + @JsonProperty("id") long id, + @JsonProperty("type") String type, + @JsonProperty("title") String title, + @JsonProperty("username") String username, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("is_forum") boolean isForum +) { + + public boolean hasTitle() { + return this.title != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasFirstName() { + return this.firstName != null; + } + + public boolean hasLastName() { + return this.lastName != null; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java b/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java new file mode 100644 index 0000000..0653c1a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java @@ -0,0 +1,26 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatAdministratorRights( + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("can_manage_chat") boolean canManageChat, + @JsonProperty("can_delete_messages") boolean canDeleteMessages, + @JsonProperty("can_manage_video_chats") boolean canManageVideoChats, + @JsonProperty("can_restrict_members") boolean canRestrictMembers, + @JsonProperty("can_promote_members") boolean canPromoteMembers, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_post_stories") boolean canPostStories, + @JsonProperty("can_edit_stories") boolean canEditStories, + @JsonProperty("can_delete_stories") boolean canDeleteStories, + @JsonProperty("can_post_messages") boolean canPostMessages, + @JsonProperty("can_edit_messages") boolean canEditMessages, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java new file mode 100644 index 0000000..af2af91 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBackground(@JsonProperty("type") BackgroundType type) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java new file mode 100644 index 0000000..2f16be1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoost( + @JsonProperty("boost_id") String boostId, + @JsonProperty("add_date") long addDate, + @JsonProperty("expiration_date") long expirationDate, + @JsonProperty("source") ChatBoostSource source +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java new file mode 100644 index 0000000..de0db01 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostAdded( + @JsonProperty("boost_count") int boostCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java new file mode 100644 index 0000000..2c04426 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostRemoved( + @JsonProperty("chat") Chat chat, + @JsonProperty("boost_id") String boostId, + @JsonProperty("remove_date") long removeDate, + @JsonProperty("source") ChatBoostSource source +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java new file mode 100644 index 0000000..0b46d25 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "source" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatBoostSourcePremium.class, name = "premium"), + @JsonSubTypes.Type(value = ChatBoostSourceGiveaway.class, name = "giveaway"), + @JsonSubTypes.Type(value = ChatBoostSourceGiftCode.class, name = "gift_code") +}) +public interface ChatBoostSource { + String source(); +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java new file mode 100644 index 0000000..c3e8cd8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourceGiftCode( + @JsonProperty("source") String source, + @JsonProperty("user") User user +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java new file mode 100644 index 0000000..d48c42c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourceGiveaway( + @JsonProperty("source") String source, + @JsonProperty("giveaway_message_id") long giveawayMessageId, + @JsonProperty("user") User user, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("is_unclaimed") boolean isUnclaimed +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java new file mode 100644 index 0000000..a096875 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostSourcePremium( + @JsonProperty("source") String source, + @JsonProperty("user") User user +) implements ChatBoostSource { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java new file mode 100644 index 0000000..05dd19d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatBoostUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("boost") ChatBoost boost +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java new file mode 100644 index 0000000..c8a57ee --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java @@ -0,0 +1,29 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatInviteLink( + @JsonProperty("invite_link") String inviteLink, + @JsonProperty("creator") User creator, + @JsonProperty("creates_join_request") boolean createsJoinRequest, + @JsonProperty("is_primary") boolean isPrimary, + @JsonProperty("is_revoked") boolean isRevoked, + @JsonProperty("name") String name, + @JsonProperty("expire_date") long expireDate, + @JsonProperty("member_limit") int memberLimit, + @JsonProperty("pending_join_request_count") int pendingJoinRequestCount, + @JsonProperty("subscription_period") int subscriptionPeriod, + @JsonProperty("subscription_price") int subscriptionPrice +) { + @NotNull + @Override + public String toString() { + return this.inviteLink; + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java new file mode 100644 index 0000000..d5e8a86 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatJoinRequest( + @JsonProperty("chat") Chat chat, + @JsonProperty("from") User from, + @JsonProperty("user_chat_id") long userChatId, + @JsonProperty("date") long date, + @JsonProperty("bio") String bio, + @JsonProperty("invite_link") ChatInviteLink chatInviteLink +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java new file mode 100644 index 0000000..fdce955 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "status" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatMemberAdministrator.class, name = "administrator"), + @JsonSubTypes.Type(value = ChatMemberBanned.class, name = "kicked"), + @JsonSubTypes.Type(value = ChatMemberLeft.class, name = "left"), + @JsonSubTypes.Type(value = ChatMemberMember.class, name = "member"), + @JsonSubTypes.Type(value = ChatMemberOwner.class, name = "creator"), + @JsonSubTypes.Type(value = ChatMemberRestricted.class, name = "restricted"), +}) +public interface ChatMember { + User user(); + String status(); + + default ChatMemberAdministrator getAsChatMemberAdministrator() { + return (ChatMemberAdministrator) this; + } + +} + diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java new file mode 100644 index 0000000..c2ee0ed --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java @@ -0,0 +1,30 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberAdministrator( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("can_be_edited") boolean canBeEdited, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("can_manage_chat") boolean canManageChat, + @JsonProperty("can_delete_messages") boolean canDeleteMessages, + @JsonProperty("can_manage_video_chats") boolean canManageVideoChat, + @JsonProperty("can_restrict_members") boolean canRestrictMembers, + @JsonProperty("can_promote_members") boolean canPromoteMembers, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_post_stories") boolean canPostStories, + @JsonProperty("can_edit_stories") boolean canEditStories, + @JsonProperty("can_delete_stories") boolean canDeleteStories, + @JsonProperty("can_post_messages") boolean canPostMessages, + @JsonProperty("can_edit_messages") boolean canEditMessages, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics, + @JsonProperty("custom_title") boolean hasCustomTitle +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java new file mode 100644 index 0000000..e31b1f2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberBanned( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java new file mode 100644 index 0000000..a8511e7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberLeft( + @JsonProperty("status") String status, + @JsonProperty("user") User user +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java new file mode 100644 index 0000000..6462ead --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberMember( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java new file mode 100644 index 0000000..b41346b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberOwner( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("custom_title") String customTitle +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java new file mode 100644 index 0000000..d801758 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java @@ -0,0 +1,29 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberRestricted( + @JsonProperty("status") String status, + @JsonProperty("user") User user, + @JsonProperty("is_member") boolean isMember, + @JsonProperty("can_send_messages") boolean canSendMessage, + @JsonProperty("can_send_audios") boolean canSendAudios, + @JsonProperty("can_send_documents") boolean canSendDocuments, + @JsonProperty("can_send_photos") boolean canSendPhotos, + @JsonProperty("can_send_videos") boolean canSendVideos, + @JsonProperty("can_send_video_notes") boolean canSendVideoNotes, + @JsonProperty("can_send_voice_notes") boolean canSendVoiceNotes, + @JsonProperty("can_send_polls") boolean canSendPolls, + @JsonProperty("can_send_other_messages") boolean canSendOtherMessages, + @JsonProperty("can_add_web_page_previews") boolean canAddWebPagePreviews, + @JsonProperty("can_change_info") boolean canChangeInfo, + @JsonProperty("can_invite_users") boolean canInviteUsers, + @JsonProperty("can_pin_messages") boolean canPinMessages, + @JsonProperty("can_manage_topics") boolean canManageTopics, + @JsonProperty("until_date") long untilDate +) implements ChatMember { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java new file mode 100644 index 0000000..0634715 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatMemberUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("from") User from, + @JsonProperty("date") long date, + @JsonProperty("old_chat_member") ChatMember oldChatMember, + @JsonProperty("new_chat_member") ChatMember newChatMember, + @JsonProperty("invite_link") ChatInviteLink chatInviteLink, + @JsonProperty("via_join_request") boolean viaJoinRequest, + @JsonProperty("via_chat_folder_invite_link") boolean viaChatFolderInviteLink +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java b/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java new file mode 100644 index 0000000..114346a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChatShared( + @JsonProperty("request_id") int requestId, + @JsonProperty("chat_id") long chatId, + @JsonProperty("title") String title, + @JsonProperty("username") String username, + @JsonProperty("photo") PhotoSize[] photo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java b/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java new file mode 100644 index 0000000..d57196f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ChosenInlineResult( + @JsonProperty("result_id") String resultId, + @JsonProperty("from") User from, + @JsonProperty("location") Location location, + @JsonProperty("inline_message_id") String inlineMessageId, + @JsonProperty("query") String query +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Contact.java b/core/src/main/java/hdvtdev/telegram/objects/Contact.java new file mode 100644 index 0000000..5e28ed9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Contact.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Contact( + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("user_id") long userId, + @JsonProperty("vcard") String vcard +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java b/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java new file mode 100644 index 0000000..895f845 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record CopyTextButton(@JsonProperty("text") String text) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Dice.java b/core/src/main/java/hdvtdev/telegram/objects/Dice.java new file mode 100644 index 0000000..5c3061b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Dice.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Dice( + @JsonProperty("emoji") String emoji, + @JsonProperty("value") int value +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Document.java b/core/src/main/java/hdvtdev/telegram/objects/Document.java new file mode 100644 index 0000000..8e3fd8c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Document.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.methods.GetFile; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Document( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { + public GetFile getFile() { + return new GetFile(this.fileId); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java b/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java new file mode 100644 index 0000000..90a57ae --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record EncryptedCredentials( + @JsonProperty("data") String data, + @JsonProperty("hash") String hash, + @JsonProperty("secret") String secret +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java b/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java new file mode 100644 index 0000000..a1dfa54 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record EncryptedPassportElement( + @JsonProperty("type") String type, + @JsonProperty("data") String data, + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("email") String email, + @JsonProperty("files") PassportFile[] files, + @JsonProperty("front_side") PassportFile frontSide, + @JsonProperty("reverse_side") PassportFile reverseSide, + @JsonProperty("selfie") PassportFile selfie, + @JsonProperty("translation") PassportFile[] translation, + @JsonProperty("hash") String hash +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java b/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java new file mode 100644 index 0000000..84f2ce8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java @@ -0,0 +1,35 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ExternalReplyInfo( + @JsonProperty("origin") MessageOrigin origin, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, + @JsonProperty("animation") Animation animation, + @JsonProperty("audio") Audio audio, + @JsonProperty("document") Document document, + @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("sticker") Sticker sticker, + @JsonProperty("story") Story story, + @JsonProperty("video") Video video, + @JsonProperty("video_note") VideoNote videoNote, + @JsonProperty("voice") Voice voice, + @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, + @JsonProperty("contact") Contact contact, + @JsonProperty("dice") Dice dice, + @JsonProperty("game") Game game, + @JsonProperty("giveaway") Giveaway giveaway, + @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, + @JsonProperty("invoice") Invoice invoice, + @JsonProperty("location") Location location, + @JsonProperty("poll") Poll poll, + @JsonProperty("venue") Venue venue +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java b/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java new file mode 100644 index 0000000..61df0cb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForceReply( + @JsonProperty("force_reply") boolean forceReply, + @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java new file mode 100644 index 0000000..619afff --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicClosed() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java new file mode 100644 index 0000000..166e12f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicCreated( + @JsonProperty("name") String name, + @JsonProperty("icon_color") int iconColor, + @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java new file mode 100644 index 0000000..85e3c3f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicEdited( + @JsonProperty("name") String name, + @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java new file mode 100644 index 0000000..1beab80 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ForumTopicReopened() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Game.java b/core/src/main/java/hdvtdev/telegram/objects/Game.java new file mode 100644 index 0000000..ec4a513 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Game.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Game( + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("text") String text, + @JsonProperty("text_entities") MessageEntity[] textEntities, + @JsonProperty("animation") Animation animation +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java new file mode 100644 index 0000000..cc154a1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GeneralForumTopicHidden() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java new file mode 100644 index 0000000..81616f9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GeneralForumTopicUnhidden() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java b/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java new file mode 100644 index 0000000..9f7a292 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java @@ -0,0 +1,20 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Giveaway( + @JsonProperty("chats") Chat[] chats, + @JsonProperty("winners_selection_date") long winnersSelectionDate, + @JsonProperty("winner_count") int winnerCount, + @JsonProperty("only_new_members") boolean onlyNewMembers, + @JsonProperty("has_public_winners") boolean hasPublicWinners, + @JsonProperty("prize_description") String prizeDescription, + @JsonProperty("country_codes") String[] countryCodes, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java new file mode 100644 index 0000000..b293899 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayCompleted( + @JsonProperty("winner_count") int winnerCount, + @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, + @JsonProperty("giveaway_message") Message giveawayMessage, + @JsonProperty("is_star_giveaway") boolean isStarGiveaway +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java new file mode 100644 index 0000000..e69d7c4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayCreated(@JsonProperty("prize_star_count") int prizeStarCount) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java new file mode 100644 index 0000000..028819e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java @@ -0,0 +1,23 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record GiveawayWinners( + @JsonProperty("chat") Chat chat, + @JsonProperty("giveaway_message_id") long giveawayMessageId, + @JsonProperty("winners_selection_date") long winnersSelectionDate, + @JsonProperty("winners_count") int winnersCount, + @JsonProperty("winners") User[] winners, + @JsonProperty("additional_chat_count") int additionalChatCount, + @JsonProperty("prize_star_count") int prizeStarCount, + @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount, + @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, + @JsonProperty("only_new_members") boolean onlyNewMembers, + @JsonProperty("was_refunded") boolean wasRefunded, + @JsonProperty("prize_description") String prizeDescription +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java new file mode 100644 index 0000000..ec66ce7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record InaccessibleMessage(Chat chat, @JsonProperty("message_id") int messageId, + long date) implements MaybeInaccessibleMessage { + @Override + public long chatId() { + return chat.id(); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java new file mode 100644 index 0000000..0b71217 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java @@ -0,0 +1,250 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class InlineKeyboardButton { + + @JsonProperty("text") + private final String text; + @JsonProperty("url") + private String url; + @JsonProperty("callback_data") + private String callbackData; + @JsonProperty("web_app") + private WebAppInfo webApp; + @JsonProperty("login_url") + private LoginUrl loginUrl; + @JsonProperty("switch_inline_query") + private String switchInlineQuery; + @JsonProperty("switch_inline_query_current_chat") + private String switchInlineQueryCurrentChat; + @JsonProperty("switch_inline_query_chosen_chat") + private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; + @JsonProperty("copy_text") + private CopyTextButton copyTextButton; + @JsonProperty("callback_game") + private CallbackGame callbackGame; + @JsonProperty("pay") + private Boolean pay; + + @JsonCreator + public InlineKeyboardButton( + @JsonProperty("text") String text, + @JsonProperty("url") String url, + @JsonProperty("callback_data") String callbackData, + @JsonProperty("web_app") WebAppInfo webApp, + @JsonProperty("login_url") LoginUrl loginUrl, + @JsonProperty("switch_inline_query") String switchInlineQuery, + @JsonProperty("switch_inline_query_current_chat") String switchInlineQueryCurrentChat, + @JsonProperty("switch_inline_query_chosen_chat") SwitchInlineQueryChosenChat switchInlineQueryChosenChat, + @JsonProperty("copy_text") CopyTextButton copyTextButton, + @JsonProperty("callback_game") CallbackGame callbackGame, + @JsonProperty("pay") Boolean pay + ) { + this.text = text; + this.url = url; + this.callbackData = callbackData; + this.webApp = webApp; + this.loginUrl = loginUrl; + this.switchInlineQuery = switchInlineQuery; + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + this.copyTextButton = copyTextButton; + this.callbackGame = callbackGame; + this.pay = pay; + } + + private InlineKeyboardButton(Builder builder) { + this.text = builder.text; + setUrl(builder.url); + setCallbackData(builder.callbackData); + setWebApp(builder.webApp); + setLoginUrl(builder.loginUrl); + setSwitchInlineQuery(builder.switchInlineQuery); + setSwitchInlineQueryCurrentChat(builder.switchInlineQueryCurrentChat); + setSwitchInlineQueryChosenChat(builder.switchInlineQueryChosenChat); + setCopyTextButton(builder.copyTextButton); + setCallbackGame(builder.callbackGame); + setPay(builder.pay); + } + + public InlineKeyboardButton(String text) { + this.text = text; + } + + public InlineKeyboardButton(String text, String data) { + this.text = text; + this.callbackData = data; + } + + @JsonIgnore + public String getText() { + return text; + } + + @JsonIgnore + public String getUrl() { + return url; + } + + @JsonIgnore + public String getCallbackData() { + return callbackData; + } + + @JsonIgnore + public WebAppInfo getWebApp() { + return webApp; + } + + @JsonIgnore + public LoginUrl getLoginUrl() { + return loginUrl; + } + + @JsonIgnore + public String getSwitchInlineQuery() { + return switchInlineQuery; + } + + @JsonIgnore + public String getSwitchInlineQueryCurrentChat() { + return switchInlineQueryCurrentChat; + } + + @JsonIgnore + public SwitchInlineQueryChosenChat getSwitchInlineQueryChosenChat() { + return switchInlineQueryChosenChat; + } + + @JsonIgnore + public CopyTextButton getCopyTextButton() { + return copyTextButton; + } + + @JsonIgnore + public CallbackGame getCallbackGame() { + return callbackGame; + } + + @JsonIgnore + public Boolean getPay() { + return pay; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + public void setWebApp(WebAppInfo webApp) { + this.webApp = webApp; + } + + public void setLoginUrl(LoginUrl loginUrl) { + this.loginUrl = loginUrl; + } + + public void setSwitchInlineQuery(String switchInlineQuery) { + this.switchInlineQuery = switchInlineQuery; + } + + public void setSwitchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + } + + public void setSwitchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + } + + public void setCopyTextButton(CopyTextButton copyTextButton) { + this.copyTextButton = copyTextButton; + } + + public void setCallbackGame(CallbackGame callbackGame) { + this.callbackGame = callbackGame; + } + + public void setPay(Boolean pay) { + this.pay = pay; + } + + public static final class Builder { + private final String text; + private String url; + private String callbackData; + private WebAppInfo webApp; + private LoginUrl loginUrl; + private String switchInlineQuery; + private String switchInlineQueryCurrentChat; + private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; + private CopyTextButton copyTextButton; + private CallbackGame callbackGame; + private Boolean pay; + + public Builder(String text) { + this.text = text; + } + + public Builder pay(boolean pay) { + this.pay = pay; + return this; + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder callbackData(String callbackData) { + this.callbackData = callbackData; + return this; + } + + public Builder webApp(WebAppInfo webApp) { + this.webApp = webApp; + return this; + } + + public Builder loginUrl(LoginUrl loginUrl) { + this.loginUrl = loginUrl; + return this; + } + + public Builder switchInlineQuery(String switchInlineQuery) { + this.switchInlineQuery = switchInlineQuery; + return this; + } + + public Builder switchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + return this; + } + + public Builder switchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { + this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; + return this; + } + + public Builder copyTextButton(CopyTextButton copyTextButton) { + this.copyTextButton = copyTextButton; + return this; + } + + public Builder callbackGame(CallbackGame callbackGame) { + this.callbackGame = callbackGame; + return this; + } + + public InlineKeyboardButton build() { + return new InlineKeyboardButton(this); + } + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java new file mode 100644 index 0000000..34ff270 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java @@ -0,0 +1,35 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.*; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public record InlineKeyboardMarkup( + @JsonProperty("inline_keyboard") InlineKeyboardRow... keyboard) implements ReplyMarkup { + + @JsonCreator + public InlineKeyboardMarkup(@JsonProperty("inline_keyboard") InlineKeyboardButton[][] keyboardButtons) { + this(convertToInlineKeyboardRow(keyboardButtons)); + } + + public InlineKeyboardMarkup(List inlineKeyboardRows) { + this(inlineKeyboardRows.toArray(new InlineKeyboardRow[0])); + } + + @JsonIgnore + private static InlineKeyboardRow[] convertToInlineKeyboardRow(InlineKeyboardButton[][] keyboardButtons) { + InlineKeyboardRow[] rows = new InlineKeyboardRow[keyboardButtons.length]; + for (int i = 0; i < keyboardButtons.length; i++) { + rows[i] = new InlineKeyboardRow(keyboardButtons[i]); + } + return rows; + } + + @JsonIgnore + public static InlineKeyboardMarkup ofSingleButton(InlineKeyboardButton button) { + return new InlineKeyboardMarkup(new InlineKeyboardRow(button)); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java new file mode 100644 index 0000000..cb1665e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java @@ -0,0 +1,69 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jetbrains.annotations.NotNull; + +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + + +public final class InlineKeyboardRow extends AbstractList { + + @JsonIgnore + private final ArrayList buttonsList = new ArrayList<>(); + + public InlineKeyboardRow() { + + } + + public InlineKeyboardButton remove(int i) { + return this.buttonsList.remove(i); + } + + @JsonIgnore + @Override + public void clear() { + this.buttonsList.clear(); + } + + @JsonIgnore + @Override + public int size() { + return this.buttonsList.size(); + } + + @JsonIgnore + @Override + public boolean addAll(@NotNull Collection buttons) { + return this.buttonsList.addAll(buttons); + } + + public void addAll(InlineKeyboardButton... buttons) { + this.buttonsList.addAll(List.of(buttons)); + } + + public InlineKeyboardRow(InlineKeyboardButton... buttons) { + this.buttonsList.addAll(List.of(buttons)); + } + + @JsonIgnore + @Override + public boolean add(InlineKeyboardButton button) { + return this.buttonsList.add(button); + } + + @JsonIgnore + @Override + public InlineKeyboardButton get(int i) { + return this.buttonsList.get(i); + } + + @JsonValue + public List buttons() { + return buttonsList; + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java b/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java new file mode 100644 index 0000000..2738525 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record InlineQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("query") String query, + @JsonProperty("offset") String offset, + @JsonProperty("chat_type") String chatType, + @JsonProperty("location") Location location +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Invoice.java b/core/src/main/java/hdvtdev/telegram/objects/Invoice.java new file mode 100644 index 0000000..04b2ca1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Invoice.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Invoice( + @JsonProperty("title") String title, + @JsonProperty("description") String description, + @JsonProperty("start_parameter") String startParameter, + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java new file mode 100644 index 0000000..6e82940 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButton( + @JsonProperty("text") String text, + @JsonProperty("request_users") KeyboardButtonRequestUsers requestUsers, + @JsonProperty("request_chat") KeyboardButtonRequestChat requestChat, + @JsonProperty("request_contact") boolean requestContact, + @JsonProperty("request_location") boolean requestLocation, + @JsonProperty("request_poll") KeyboardButtonPollType requestPoll, + @JsonProperty("web_app") WebAppInfo webApp +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java new file mode 100644 index 0000000..3f6c38b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonPollType( + @JsonProperty("type") String type +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java new file mode 100644 index 0000000..d5181f1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonRequestChat( + @JsonProperty("request_id") Integer requestId, + @JsonProperty("chat_is_channel") boolean chatIsChannel, + @JsonProperty("chat_is_forum") boolean chatIsForum, + @JsonProperty("chat_has_username") boolean chatHasUsername, + @JsonProperty("chat_is_created") boolean chatIsCreated, + @JsonProperty("user_administrator_rights") ChatAdministratorRights userAdministratorRights, + @JsonProperty("bot_administrator_rights") ChatAdministratorRights botAdministratorRights, + @JsonProperty("bot_is_member") boolean botIsMember, + @JsonProperty("request_title") boolean requestTitle, + @JsonProperty("request_username") boolean requestUsername, + @JsonProperty("request_photo") boolean requestPhoto +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java new file mode 100644 index 0000000..9f417c4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record KeyboardButtonRequestUsers( + @JsonProperty("request_id") Integer requestId, + @JsonProperty("user_is_bot") boolean userIsBot, + @JsonProperty("user_is_premium") boolean userIsPremium, + @JsonProperty("max_quantity") Integer maxQuantity, + @JsonProperty("request_name") Boolean requestName, + @JsonProperty("request_username") Boolean requestUsername, + @JsonProperty("request_photo") Boolean requestPhoto +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java b/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java new file mode 100644 index 0000000..9aefc6e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record LinkPreviewOptions( + @JsonProperty("is_disabled") boolean isDisabled, + @JsonProperty("url") String url, + @JsonProperty("prefer_small_media") boolean preferSmallMedia, + @JsonProperty("prefer_large_media") boolean preferLargeMedia, + @JsonProperty("show_above_text") boolean showAboveText + +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Location.java b/core/src/main/java/hdvtdev/telegram/objects/Location.java new file mode 100644 index 0000000..23f669b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Location.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Location( + @JsonProperty("latitude") float latitude, + @JsonProperty("longitude") float longitude, + @JsonProperty("horizontal_accuracy") float horizontalAccuracy, + @JsonProperty("live_period") int livePeriod, + @JsonProperty("heading") int heading, + @JsonProperty("proximity_alert_radius") int proximityAlertRadius +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java b/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java new file mode 100644 index 0000000..6fce8da --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record LoginUrl( + @JsonProperty("url") String url, + @JsonProperty("forward_text") String forwardText, + @JsonProperty("bot_username") String botUsername, + @JsonProperty("request_write_access") boolean requestWriteAccess +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java b/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java new file mode 100644 index 0000000..deb02df --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MaskPosition( + @JsonProperty("point") String point, + @JsonProperty("x_shift") float xShift, + @JsonProperty("y_shift") float yShift, + @JsonProperty("scale") float scale +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java new file mode 100644 index 0000000..bb27697 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = MaybeInaccessibleMessageDeserializer.class) +public interface MaybeInaccessibleMessage { + long chatId(); + + Chat chat(); + + int messageId(); + + long date(); + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java new file mode 100644 index 0000000..44ecc07 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +import java.io.IOException; + +public class MaybeInaccessibleMessageDeserializer extends JsonDeserializer { + + @Override + public MaybeInaccessibleMessage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + Message msg = p.getCodec().readValue(p, Message.class); + return msg.date() == 0 ? new InaccessibleMessage(msg.chat(), msg.messageId(), 0) : msg; + } +} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/objects/Message.java b/core/src/main/java/hdvtdev/telegram/objects/Message.java new file mode 100644 index 0000000..64ba755 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Message.java @@ -0,0 +1,274 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Message( + @JsonProperty("message_id") int messageId, + @JsonProperty("message_thread_id") Long messageThreadId, + @JsonProperty("from") User user, + @JsonProperty("sender_chat") Chat senderChat, + @JsonProperty("sender_boost_count") Integer senderBoostCount, + @JsonProperty("sender_business_bot") User senderBusinessBot, + @JsonProperty("date") long date, + @JsonProperty("business_connection_id") String businessConnectionId, + @JsonProperty("chat") Chat chat, + @JsonProperty("forward_origin") MessageOrigin forwardOrigin, + @JsonProperty("is_topic_message") boolean isTopicMessage, + @JsonProperty("is_automatic_forward") boolean isAutomaticForward, + @JsonProperty("reply_to_message") Message replyToMessage, + @JsonProperty("external_reply") ExternalReplyInfo externalReply, + @JsonProperty("quote") TextQuote quote, + @JsonProperty("reply_to_story") Story replyToStory, + @JsonProperty("via_bot") User viaBot, + @JsonProperty("edit_date") long editDate, + @JsonProperty("has_protected_content") boolean hasProtectedContent, + @JsonProperty("is_from_offline") boolean isFromOnline, + @JsonProperty("media_group_id") String mediaGroupId, + @JsonProperty("author_signature") String authorSignature, + @JsonProperty("text") String text, + @JsonProperty("entities") MessageEntity[] entities, + @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, + @JsonProperty("effect_id") String effectId, + @JsonProperty("animation") Animation animation, + @JsonProperty("audio") Audio audio, + @JsonProperty("document") Document document, + @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, + @JsonProperty("photo") PhotoSize[] photo, + @JsonProperty("sticker") Sticker sticker, + @JsonProperty("story") Story story, + @JsonProperty("video") Video video, + @JsonProperty("video_note") VideoNote videoNote, + @JsonProperty("voice") Voice voice, + @JsonProperty("caption") String caption, + @JsonProperty("caption_entities") MessageEntity[] captionEntities, + @JsonProperty("show_caption_above_media") boolean showCaptionAboveMedia, + @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, + @JsonProperty("contact") Contact contact, + @JsonProperty("dice") Dice dice, + @JsonProperty("game") Game game, + @JsonProperty("poll") Poll poll, + @JsonProperty("venue") Venue venue, + @JsonProperty("location") Location location, + @JsonProperty("new_chat_members") User[] newChatMembers, + @JsonProperty("left_chat_member") User leftChatMember, + @JsonProperty("new_chat_title") String newChatTitle, + @JsonProperty("new_chat_photo") PhotoSize[] newChatPhoto, + @JsonProperty("delete_chat_photo") boolean deleteChatPhoto, + @JsonProperty("group_chat_created") boolean groupChatCreated, + @JsonProperty("supergroup_chat_created") boolean supergroupChatCreated, + @JsonProperty("channel_chat_created") boolean channelChatCreated, + @JsonProperty("message_auto_delete_timer_changed") MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged, + @JsonProperty("migrate_to_chat_id") Long migrateToChatId, + @JsonProperty("migrate_from_chat_id") Long migrateFromChatId, + @JsonProperty("pinned_message") MaybeInaccessibleMessage pinnedMessage, + @JsonProperty("invoice") Invoice invoice, + @JsonProperty("successful_payment") SuccessfulPayment successfulPayment, + @JsonProperty("refunded_payment") RefundedPayment refundedPayment, + @JsonProperty("users_shared") UsersShared usersShared, + @JsonProperty("chat_shared") ChatShared chatShared, + @JsonProperty("connected_website") String connectedWebsite, + @JsonProperty("write_access_allowed") WriteAccessAllowed writeAccessAllowed, + @JsonProperty("passport_data") PassportData passportData, + @JsonProperty("proximity_alert_triggered") ProximityAlertTriggered proximityAlertTriggered, + @JsonProperty("boost_added") ChatBoostAdded chatBoostAdded, + @JsonProperty("chat_background_set") ChatBackground chatBackground, + @JsonProperty("forum_topic_created") ForumTopicCreated forumTopicCreated, + @JsonProperty("forum_topic_edited") ForumTopicEdited forumTopicEdited, + @JsonProperty("forum_topic_closed") ForumTopicClosed forumTopicClosed, + @JsonProperty("forum_topic_reopened") ForumTopicReopened forumTopicReopened, + @JsonProperty("general_forum_topic_hidden") GeneralForumTopicHidden generalForumTopicHidden, + @JsonProperty("general_forum_topic_unhidden") GeneralForumTopicUnhidden generalForumTopicUnhidden, + @JsonProperty("giveaway_created") GiveawayCreated giveawayCreated, + @JsonProperty("giveaway") Giveaway giveaway, + @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, + @JsonProperty("giveaway_completed") GiveawayCompleted giveawayCompleted, + @JsonProperty("video_chat_scheduled") VideoChatScheduled videoChatScheduled, + @JsonProperty("video_chat_started") VideoChatStarted videoChatStarted, + @JsonProperty("video_chat_ended") VideoChatEnded videoChatEnded, + @JsonProperty("video_chat_participants_invited") VideoChatParticipantsInvited videoChatParticipantsInvited, + @JsonProperty("web_app_data") WebAppData webAppData, + @JsonProperty("reply_markup") InlineKeyboardMarkup inlineKeyboardMarkup + +) implements MaybeInaccessibleMessage { + + public boolean hasMessageThreadId() { + return messageThreadId != null; + } + + public boolean hasSenderChat() { + return senderChat != null; + } + + public boolean hasSenderBoostCount() { + return senderBoostCount != null; + } + + public boolean hasSenderBusinessBot() { + return senderBusinessBot != null; + } + + public boolean hasBusinessConnectionId() { + return businessConnectionId != null; + } + + public boolean hasForwardOrigin() { + return forwardOrigin != null; + } + + public boolean hasReplyToMessage() { + return replyToMessage != null; + } + + public boolean hasExternalReply() { + return externalReply != null; + } + + public boolean hasQuote() { + return quote != null; + } + + public boolean hasReplyToStory() { + return replyToStory != null; + } + + public boolean hasViaBot() { + return viaBot != null; + } + + public boolean hasEditDate() { + return editDate != 0; + } + + public boolean hasMediaGroupId() { + return mediaGroupId != null; + } + + public boolean hasAuthorSignature() { + return authorSignature != null; + } + + public boolean hasText() { + return text != null; + } + + public boolean hasEntities() { + return entities != null; + } + + public boolean hasLinkPreviewOptions() { + return linkPreviewOptions != null; + } + + public boolean hasEffectId() { + return effectId != null; + } + + public boolean hasAnimation() { + return animation != null; + } + + public boolean hasAudio() { + return audio != null; + } + + public boolean hasDocument() { + return document != null; + } + + public boolean hasPaidMediaInfo() { + return paidMediaInfo != null; + } + + public boolean hasPhoto() { + return photo != null; + } + + public boolean hasSticker() { + return sticker != null; + } + + public boolean hasStory() { + return story != null; + } + + public boolean hasVideo() { + return video != null; + } + + public boolean hasVideoNote() { + return videoNote != null; + } + + public boolean hasVoice() { + return voice != null; + } + + public boolean hasCaption() { + return caption != null; + } + + public boolean hasCaptionEntities() { + return captionEntities != null; + } + + public boolean hasContact() { + return contact != null; + } + + public boolean hasDice() { + return dice != null; + } + + public boolean hasGame() { + return game != null; + } + + public boolean hasPoll() { + return poll != null; + } + + public boolean hasVenue() { + return venue != null; + } + + public boolean hasLocation() { + return location != null; + } + + public boolean hasNewChatMembers() { + return newChatMembers != null; + } + + public boolean hasLeftChatMember() { + return leftChatMember != null; + } + + public boolean hasNewChatTitle() { + return newChatTitle != null; + } + + public boolean hasNewChatPhoto() { + return newChatPhoto != null; + } + + public boolean hasMessageAutoDeleteTimerChanged() { + return messageAutoDeleteTimerChanged != null; + } + + public boolean hasMigrateToChatId() { + return migrateToChatId != null; + } + + public boolean hasMigrateFromChatId() { + return migrateFromChatId != null; + } + + @Override + public long chatId() { + return this.chat.id(); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java b/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java new file mode 100644 index 0000000..d2b30a0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageAutoDeleteTimerChanged(@JsonProperty("message_auto_delete_time") long messageAutoDeleteTime) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java b/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java new file mode 100644 index 0000000..68f6bb5 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageEntity( + @JsonProperty("type") String type, + @JsonProperty("offset") int offset, + @JsonProperty("length") int length, + @JsonProperty("url") String url, + @JsonProperty("user") User user, + @JsonProperty("language") String language, + @JsonProperty("custom_emoji_id") String customEmojiId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java new file mode 100644 index 0000000..4716239 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java @@ -0,0 +1,19 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = MessageOriginUser.class, name = "user"), + @JsonSubTypes.Type(value = MessageOriginHiddenUser.class, name = "hidden_user"), + @JsonSubTypes.Type(value = MessageOriginChat.class, name = "chat"), + @JsonSubTypes.Type(value = MessageOriginChannel.class, name = "channel") +}) +public interface MessageOrigin { + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java new file mode 100644 index 0000000..73903e3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginChannel( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("author_signature") String authorSignature +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java new file mode 100644 index 0000000..558e3a7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginChat( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_chat") Chat senderChat, + @JsonProperty("author_signature") String authorSignature +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java new file mode 100644 index 0000000..ea5b8ca --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginHiddenUser( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_user_name") String senderUserName +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java new file mode 100644 index 0000000..1b3614e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageOriginUser( + @JsonProperty("type") String type, + @JsonProperty("date") long date, + @JsonProperty("sender_user") User senderUser +) implements MessageOrigin { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java new file mode 100644 index 0000000..ef74f64 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageReactionCountUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("date") long date, + @JsonProperty("reactions") ReactionCount[] reactions +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java new file mode 100644 index 0000000..fea1ccc --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record MessageReactionUpdated( + @JsonProperty("chat") Chat chat, + @JsonProperty("message_id") long messageId, + @JsonProperty("user") User user, + @JsonProperty("actor_chat") Chat actorChat, + @JsonProperty("date") long date, + @JsonProperty("old_reaction") ReactionType[] oldReaction, + @JsonProperty("new_reaction") ReactionType[] newReaction +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java b/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java new file mode 100644 index 0000000..f214e41 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record OrderInfo( + @JsonProperty("name") String name, + @JsonProperty("phone_number") String phoneNumber, + @JsonProperty("email") String email, + @JsonProperty("shipping_address") ShippingAddress shippingAddress +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java new file mode 100644 index 0000000..73703a3 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = PaidMediaPreview.class, name = "preview"), + @JsonSubTypes.Type(value = PaidMediaPhoto.class, name = "photo"), + @JsonSubTypes.Type(value = PaidMediaVideo.class, name = "video") +}) +public interface PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java new file mode 100644 index 0000000..ff95de6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaInfo( + @JsonProperty("star_count") int startCount, + @JsonProperty("paid_media") PaidMedia[] paidMedia +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java new file mode 100644 index 0000000..a78e5b9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPhoto( + @JsonProperty("type") String type, + @JsonProperty("photo") PhotoSize[] photo +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java new file mode 100644 index 0000000..f763a38 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPreview( + @JsonProperty("type") String type, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java new file mode 100644 index 0000000..32475dd --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaPurchased( + @JsonProperty("from") User from, + @JsonProperty("paid_media_payload") String paidMediaPayload +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java new file mode 100644 index 0000000..dc65b58 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PaidMediaVideo( + @JsonProperty("type") String type, + @JsonProperty("video") Video video +) implements PaidMedia { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PassportData.java b/core/src/main/java/hdvtdev/telegram/objects/PassportData.java new file mode 100644 index 0000000..6633ae8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PassportData.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PassportData( + @JsonProperty("data") EncryptedPassportElement[] data, + @JsonProperty("credentials") EncryptedCredentials credentials +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java b/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java new file mode 100644 index 0000000..6247580 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PassportFile( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("file_size") long fileSize, + @JsonProperty("file_date") long fileDate +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java b/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java new file mode 100644 index 0000000..6fcf9ad --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PhotoSize( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("file_size") long file_size +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Poll.java b/core/src/main/java/hdvtdev/telegram/objects/Poll.java new file mode 100644 index 0000000..43637d8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Poll.java @@ -0,0 +1,25 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Poll( + @JsonProperty("id") String id, + @JsonProperty("question") String question, + @JsonProperty("question_entities") MessageEntity[] questionEntities, + @JsonProperty("options") PollOption[] options, + @JsonProperty("total_voter_count") int totalVoterCount, + @JsonProperty("is_closed") boolean isClosed, + @JsonProperty("is_anonymous") boolean isAnonymous, + @JsonProperty("type") String type, + @JsonProperty("allows_multiple_answers") boolean allowMultipleAnswers, + @JsonProperty("correct_option_id") int correctOptionId, + @JsonProperty("explanation") String explanation, + @JsonProperty("explanation_entities") MessageEntity[] explanationEntities, + @JsonProperty("open_period") long openPeriod, + @JsonProperty("close_date") long closeDate +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java b/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java new file mode 100644 index 0000000..beea375 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PollAnswer( + @JsonProperty("poll_id") String pollId, + @JsonProperty("voter_chat") Chat voterChat, + @JsonProperty("user") User user, + @JsonProperty("option_ids") int[] optionsIds +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PollOption.java b/core/src/main/java/hdvtdev/telegram/objects/PollOption.java new file mode 100644 index 0000000..2616815 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PollOption.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PollOption( + @JsonProperty("text") String text, + @JsonProperty("text_entities") MessageEntity[] textEntities, + @JsonProperty("voter_count") int voterCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java b/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java new file mode 100644 index 0000000..d42e5c4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record PreCheckoutQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("shipping_option_id") String shippingOptionId, + @JsonProperty("order_info") OrderInfo orderInfo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java b/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java new file mode 100644 index 0000000..303c3b8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ProximityAlertTriggered( + @JsonProperty("traveler") User traveler, + @JsonProperty("watcher") User watcher, + @JsonProperty("distance") int distance +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java new file mode 100644 index 0000000..9ace7e4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionCount( + @JsonProperty("type") ReactionType type, + @JsonProperty("total_count") int totalCount +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java new file mode 100644 index 0000000..76aaff4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ReactionTypeEmoji.class, name = "emoji"), + @JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = "custom_emoji"), + @JsonSubTypes.Type(value = ReactionTypePaid.class, name = "paid") +}) +public interface ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java new file mode 100644 index 0000000..2b5ee8f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypeCustomEmoji( + @JsonProperty("type") String type, + @JsonProperty("custom_emoji_id") String customEmojiId +) implements ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java new file mode 100644 index 0000000..a6b31f2 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypeEmoji( + @JsonProperty("type") String type, + @JsonProperty("emoji") String emoji +) implements ReactionType { + public ReactionTypeEmoji(String emoji) { + this("emoji", emoji); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java new file mode 100644 index 0000000..cc639b8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java @@ -0,0 +1,12 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReactionTypePaid( + @JsonProperty("type") String type +) implements ReactionType { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java b/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java new file mode 100644 index 0000000..3c98a87 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record RefundedPayment( + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, + @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java new file mode 100644 index 0000000..e34dec0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyKeyboardMarkup( + @JsonProperty("keyboard") KeyboardButton[][] keyboard, + @JsonProperty("is_persistent") boolean isPersistent, + @JsonProperty("resize_keyboard") boolean resizeKeyboard, + @JsonProperty("one_time_keyboard") boolean oneTimeKeyboard, + @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java new file mode 100644 index 0000000..cf1c8f9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyKeyboardRemove( + @JsonProperty("remove_keyboard") boolean removeKeyboard, + @JsonProperty("selective") boolean selective +) implements ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java new file mode 100644 index 0000000..42abbbb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.DEDUCTION, + defaultImpl = Void.class +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ReplyKeyboardMarkup.class), + @JsonSubTypes.Type(value = InlineKeyboardMarkup.class), + @JsonSubTypes.Type(value = ReplyKeyboardRemove.class) +}) +public interface ReplyMarkup { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java new file mode 100644 index 0000000..cf10443 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java @@ -0,0 +1,28 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ReplyParameters( + @JsonProperty("message_id") long messageId, + @JsonProperty("chat_id") String chatId, + @JsonProperty("allow_sending_without_reply") boolean allowSendingWithoutReply, + @JsonProperty("quote") String quote, + @JsonProperty("quote_parse_mode") String quoteParseMode, + @JsonProperty("quote_entities") MessageEntity[] quoteEntities, + @JsonProperty("quote_position") Integer quotePosition +) { + + public ReplyParameters(long messageId, String chatId) { + this(messageId, chatId, false, null, null, null, null); + } + + public ReplyParameters(long messageId, long chatId) { + this(messageId, String.valueOf(chatId)); + } + + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java b/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java new file mode 100644 index 0000000..540c0cb --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SharedUser( + @JsonProperty("user_id") long userId, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("photo") PhotoSize[] photo +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java b/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java new file mode 100644 index 0000000..a894bc9 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ShippingAddress( + @JsonProperty("country_code") String countryCode, + @JsonProperty("state") String state, + @JsonProperty("city") String city, + @JsonProperty("street_line1") String firstStreetLine, + @JsonProperty("street_line2") String secondStreetLine, + @JsonProperty("post_code") String postCode +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java b/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java new file mode 100644 index 0000000..6916978 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java @@ -0,0 +1,15 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record ShippingQuery( + @JsonProperty("id") String id, + @JsonProperty("from") User from, + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("shipping_address") ShippingAddress shippingAddress +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Sticker.java b/core/src/main/java/hdvtdev/telegram/objects/Sticker.java new file mode 100644 index 0000000..859a71a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Sticker.java @@ -0,0 +1,26 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Sticker( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("type") String type, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("is_animated") boolean isAnimated, + @JsonProperty("is_video") boolean isVideo, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("emoji") String emoji, + @JsonProperty("set_name") String setName, + @JsonProperty("premium_animation") TelegramFile premiumAnimation, + @JsonProperty("mask_position") MaskPosition maskPosition, + @JsonProperty("custom_emoji_id") String customEmojiId, + @JsonProperty("needs_repairing") boolean needsRepairing, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Story.java b/core/src/main/java/hdvtdev/telegram/objects/Story.java new file mode 100644 index 0000000..518583e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Story.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Story( + @JsonProperty("chat") Chat chat, + @JsonProperty("id") long id +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java b/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java new file mode 100644 index 0000000..a4e2029 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java @@ -0,0 +1,21 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SuccessfulPayment( + @JsonProperty("currency") String currency, + @JsonProperty("total_amount") int totalAmount, //price + @JsonProperty("invoice_payload") String invoicePayload, + @JsonProperty("subscription_expiration_date") long subscriptionExpirationDate, + @JsonProperty("is_recurring") boolean isRecurring, + @JsonProperty("is_first_recurring") boolean isFirstRecurring, + @JsonProperty("shipping_option_id") String shippingOptionId, + @JsonProperty("order_info") OrderInfo orderInfo, + @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, + @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java b/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java new file mode 100644 index 0000000..42282c6 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record SwitchInlineQueryChosenChat( + @JsonProperty("query") String query, + @JsonProperty("allow_user_chats") boolean allowUserChats, + @JsonProperty("allow_bot_chats") boolean allowBotChats, + @JsonProperty("allow_group_chats") boolean allowGroupChats, + @JsonProperty("allow_channel_chats") boolean allowChannelChats +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java b/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java new file mode 100644 index 0000000..2f4f403 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("file") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record TelegramFile( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("file_size") long fileSize, + @JsonProperty("file_path") String filePath //link to file +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java b/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java new file mode 100644 index 0000000..11ccc52 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java @@ -0,0 +1,11 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record TextQuote(String text, MessageEntity[] entities, int position, + @JsonProperty("is_manual") boolean isManual) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Update.java b/core/src/main/java/hdvtdev/telegram/objects/Update.java new file mode 100644 index 0000000..f1f460b --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Update.java @@ -0,0 +1,139 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Update( + @JsonProperty("update_id") long updateId, + @JsonProperty("message") Message message, + @JsonProperty("edited_message") Message editedMessage, + @JsonProperty("channel_post") Message channelPost, + @JsonProperty("edited_channel_post") Message editedChannelPost, + @JsonProperty("business_connection") BusinessConnection businessConnection, + @JsonProperty("business_message") Message businessMessage, + @JsonProperty("edited_business_message") Message editedBusinessMessage, + @JsonProperty("deleted_business_messages") BusinessMessagesDeleted businessMessagesDeleted, + @JsonProperty("message_reaction") MessageReactionUpdated messageReaction, + @JsonProperty("message_reaction_count") MessageReactionCountUpdated messageReactionCount, + @JsonProperty("inline_query") InlineQuery inlineQuery, + @JsonProperty("chosen_inline_result") ChosenInlineResult chosenInlineResult, + @JsonProperty("callback_query") CallbackQuery callbackQuery, + @JsonProperty("shipping_query") ShippingQuery shippingQuery, + @JsonProperty("pre_checkout_query") PreCheckoutQuery preCheckoutQuery, + @JsonProperty("purchased_paid_media") PaidMediaPurchased paidMediaPurchased, + @JsonProperty("poll") Poll poll, + @JsonProperty("poll_answer") PollAnswer pollAnswer, + @JsonProperty("my_chat_member") ChatMemberUpdated myChatMember, + @JsonProperty("chat_member") ChatMemberUpdated chatMember, + @JsonProperty("chat_join_request") ChatJoinRequest chatJoinRequest, + @JsonProperty("chat_boost") ChatBoostUpdated chatBoost, + @JsonProperty("removed_chat_boost") ChatBoostRemoved chatBoostRemoved +) { + + public boolean hasMessage() { + return this.message != null; + } + + public boolean hasEditedMessage() { + return this.editedMessage != null; + } + + public boolean hasChannelPost() { + return this.channelPost != null; + } + + public boolean hasEditedChannelPost() { + return this.editedChannelPost != null; + } + + public boolean hasBusinessConnection() { + return this.businessConnection != null; + } + + public boolean hasBusinessMessage() { + return this.businessMessage != null; + } + + public boolean hasEditedBusinessMessage() { + return this.editedBusinessMessage != null; + } + + public boolean hasDeletedBusinessMessages() { + return this.businessMessagesDeleted != null; + } + + public boolean hasMessageReaction() { + return this.messageReaction != null; + } + + public boolean hasMessageReactionCount() { + return this.messageReactionCount != null; + } + + public boolean hasInlineQuery() { + return this.inlineQuery != null; + } + + public boolean hasChosenInlineResult() { + return this.chosenInlineResult != null; + } + + public boolean hasCallbackQuery() { + return this.callbackQuery != null; + } + + public boolean hasShippingQuery() { + return this.shippingQuery != null; + } + + public boolean hasPreCheckoutQuery() { + return this.preCheckoutQuery != null; + } + + public boolean hasPurchasedPaidMedia() { + return this.paidMediaPurchased != null; + } + + public boolean hasPoll() { + return this.poll != null; + } + + public boolean hasPollAnswer() { + return this.pollAnswer != null; + } + + public boolean hasMyChatMember() { + return this.myChatMember != null; + } + + public boolean hasChatMember() { + return this.chatMember != null; + } + + public boolean hasChatJoinRequest() { + return this.chatJoinRequest != null; + } + + public boolean hasChatBoost() { + return this.chatBoost != null; + } + + public boolean hasRemovedChatBoost() { + return this.chatBoostRemoved != null; + } + + public Optional getAnyText() { + if (hasMessage()) { + if (message.hasText()) return Optional.of(message.text()); + if (message.hasCaption()) return Optional.of(message.caption()); + } + return Optional.empty(); + } + +} + diff --git a/core/src/main/java/hdvtdev/telegram/objects/User.java b/core/src/main/java/hdvtdev/telegram/objects/User.java new file mode 100644 index 0000000..c202248 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/User.java @@ -0,0 +1,62 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record User( + @JsonProperty("id") long id, + @JsonProperty("is_bot") boolean isBot, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("language_code") String languageCode, + @JsonProperty("is_premium") boolean isPremium, + @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu +) { + + public boolean hasLastName() { + return this.lastName != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasLanguageCode() { + return this.languageCode != null; + } + + public record Bot( + @JsonProperty("id") long id, + @JsonProperty("is_bot") Boolean isBot, + @JsonProperty("first_name") String firstName, + @JsonProperty("last_name") String lastName, + @JsonProperty("username") String username, + @JsonProperty("language_code") String languageCode, + @JsonProperty("is_premium") boolean isPremium, + @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu, + @JsonProperty("can_join_groups") boolean canJoinGroups, + @JsonProperty("can_read_all_group_messages") boolean canReadAllGroupMessages, + @JsonProperty("supports_inline_queries") boolean supportsInlineQueries, + @JsonProperty("can_connect_to_business") boolean canConnectToBusiness, + @JsonProperty("has_main_web_app") boolean hasMainWebApp + ) { + + public boolean hasLastName() { + return this.lastName != null; + } + + public boolean hasUsername() { + return this.username != null; + } + + public boolean hasLanguageCode() { + return this.languageCode != null; + } + + + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java b/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java new file mode 100644 index 0000000..4fe05e1 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record UsersShared( + @JsonProperty("request_id") int requestId, + @JsonProperty("users") SharedUser[] users +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Venue.java b/core/src/main/java/hdvtdev/telegram/objects/Venue.java new file mode 100644 index 0000000..df26408 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Venue.java @@ -0,0 +1,18 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Venue( + @JsonProperty("location") Location location, + @JsonProperty("title") String title, + @JsonProperty("address") String address, + @JsonProperty("foursquare_id") String foursquareId, + @JsonProperty("foursquare_type") String foursquareType, + @JsonProperty("google_place_id") String googlePlaceId, + @JsonProperty("google_place_type") String googlePlaceType +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Video.java b/core/src/main/java/hdvtdev/telegram/objects/Video.java new file mode 100644 index 0000000..8ff8749 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Video.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Video( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("width") int width, + @JsonProperty("height") int height, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("cover") PhotoSize[] cover, + @JsonProperty("start_timestamp") int startTimestamp, + @JsonProperty("file_name") String fileName, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java new file mode 100644 index 0000000..4b44303 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatEnded(@JsonProperty("duration") long duration) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java new file mode 100644 index 0000000..915409f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatParticipantsInvited(@JsonProperty("users") User[] users) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java new file mode 100644 index 0000000..681892f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatScheduled(@JsonProperty("start_date") long startDate) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java new file mode 100644 index 0000000..db138ef --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java @@ -0,0 +1,9 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoChatStarted() { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java b/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java new file mode 100644 index 0000000..f328034 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java @@ -0,0 +1,17 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record VideoNote( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("length") long length, + @JsonProperty("duration") int duration, + @JsonProperty("thumbnail") PhotoSize thumbnail, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Voice.java b/core/src/main/java/hdvtdev/telegram/objects/Voice.java new file mode 100644 index 0000000..1ad4777 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/Voice.java @@ -0,0 +1,16 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record Voice( + @JsonProperty("file_id") String fileId, + @JsonProperty("file_unique_id") String fileUniqueId, + @JsonProperty("duration") int duration, + @JsonProperty("mime_type") String mimeType, + @JsonProperty("file_size") long fileSize +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java b/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java new file mode 100644 index 0000000..1b7e9e4 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WebAppData(String data, @JsonProperty("button_text") String buttonText) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java b/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java new file mode 100644 index 0000000..ada9c9d --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WebAppInfo(@JsonProperty("url") String url) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java b/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java new file mode 100644 index 0000000..47b2777 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record WriteAccessAllowed( + @JsonProperty("from_request") boolean fromRequest, + @JsonProperty("web_app_name") String webAppName, + @JsonProperty("from_attachment_menu") boolean fromAttachmentMenu +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java new file mode 100644 index 0000000..5d030d8 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java @@ -0,0 +1,13 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommand( + @JsonProperty("command") String name, + @JsonProperty("description") String description +) { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java new file mode 100644 index 0000000..c1fad84 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java @@ -0,0 +1,22 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type" +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = BotCommandScopeDefault.class, name = "default"), + @JsonSubTypes.Type(value = BotCommandScopeAllPrivateChats.class, name = "all_private_chats"), + @JsonSubTypes.Type(value = BotCommandScopeAllGroupChats.class, name = "all_group_chats"), + @JsonSubTypes.Type(value = BotCommandScopeAllChatAdministrators.class, name = "all_chat_administrators"), + @JsonSubTypes.Type(value = BotCommandScopeChat.class, name = "chat"), + @JsonSubTypes.Type(value = BotCommandScopeChatAdministrators.class, name = "chat_administrators"), + @JsonSubTypes.Type(value = BotCommandScopeChatMember.class, name = "chat_member") +}) +public interface BotCommandScope { + String type(); +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java new file mode 100644 index 0000000..dda2c07 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllChatAdministrators(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java new file mode 100644 index 0000000..593fe3c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllGroupChats(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java new file mode 100644 index 0000000..4b1b44f --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeAllPrivateChats(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java new file mode 100644 index 0000000..54cb0c7 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChat(@JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId) implements BotCommandScope { + public BotCommandScopeChat(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { + this(type, String.valueOf(chatId)); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java new file mode 100644 index 0000000..74a96d0 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java @@ -0,0 +1,14 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChatAdministrators(@JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId) implements BotCommandScope { + public BotCommandScopeChatAdministrators(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { + this(type, String.valueOf(chatId)); + } +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java new file mode 100644 index 0000000..c89d343 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java @@ -0,0 +1,27 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeChatMember( + @JsonProperty("type") String type, + @JsonProperty("chat_id") String chatId, + @JsonProperty("user_id") long userId +) implements BotCommandScope { + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") long userId) { + this(type, String.valueOf(chatId), userId); + } + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") String userId) { + this(type, String.valueOf(chatId), Long.parseLong(userId)); + } + + public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") String chatId, @JsonProperty("user_id") String userId) { + this(type, chatId, Long.parseLong(userId)); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java new file mode 100644 index 0000000..817b3fe --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java @@ -0,0 +1,10 @@ +package hdvtdev.telegram.objects.bot; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public record BotCommandScopeDefault(@JsonProperty("type") String type) implements BotCommandScope { +} diff --git a/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java b/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java new file mode 100644 index 0000000..3bafd11 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java @@ -0,0 +1,136 @@ +package hdvtdev.telegram.util; + +import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler; +import hdvtdev.telegram.annotations.handlers.TextMessageHandler; +import hdvtdev.telegram.objects.CallbackQuery; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.Update; + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.security.CodeSource; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +public abstract class ClassFinder { + + private static final Set> annotationsToSearch = Set.of(TextMessageHandler.class, CallbackQueryHandler.class); + private static final Set> methodsArgumentType = Set.of(Message.class, Update.class, CallbackQuery.class); + + private static ErrorHandler errorHandler; + + public static Map, Map> getClasses() { + + Map, Map> allMethods = new HashMap<>(); + annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); + + CodeSource codeSource = ClassFinder.class.getProtectionDomain().getCodeSource(); + if (codeSource != null) { + try { + String path = codeSource.getLocation().toURI().getPath(); + File file = new File(URLDecoder.decode(path, StandardCharsets.UTF_8)); + + if (file.isFile() && file.getName().endsWith(".jar")) { + processJar(file, allMethods); + } else if (file.isDirectory()) { + processDirectory(file, "", allMethods); + } + } catch (Exception e) { + return Map.of(); + } + } + + return Collections.unmodifiableMap(allMethods); + } + + private static void processDirectory(File directory, String packageName, Map, Map> methods) { + File[] files = directory.listFiles(); + if (files == null) return; + + for (File file : files) { + if (file.isDirectory()) { + processDirectory(file, packageName + file.getName() + ".", methods); + } else if (file.getName().endsWith(".class")) { + + String className = packageName + file.getName().replace(".class", ""); + loadClass(className, methods); + } + } + } + + private static void processJar(File jarFile, Map, Map> methods) { + try (JarFile jar = new JarFile(jarFile)) { + Enumeration entries = jar.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + if (entry.getName().endsWith(".class")) { + String className = entry.getName() + .replace("/", ".") + .replace(".class", ""); + + loadClass(className, methods); + } + } + } catch (IOException ignored) { + } + } + + public static Map, Map> localScan(Class cls) { + Map, Map> allMethods = new HashMap<>(); + annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); + loadClass(cls.getName(), allMethods); + return allMethods; + } + + + private static void loadClass(String className, Map, Map> methods) { + try { + Class c = Class.forName(className); + + for (Method method : c.getDeclaredMethods()) { + + Class[] parameters = method.getParameterTypes(); + + if (parameters.length != 0 && !methodsArgumentType.contains(parameters[0])) { + continue; + } + + if (method.isAnnotationPresent(CallbackQueryHandler.class)) { + if (Modifier.isStatic(method.getModifiers())) { + for (String value : method.getAnnotation(CallbackQueryHandler.class).value()) { + methods.get(CallbackQueryHandler.class).put(value, new InvokeMethod(method, parameters[0])); + } + } else + System.err.println(method + " is annotated with @CallbackQueryHandler, but it is not static. For the annotation to work, the method must be static."); + } + + if (method.isAnnotationPresent(TextMessageHandler.class)) { + if (Modifier.isStatic(method.getModifiers())) { + for (String value : method.getAnnotation(TextMessageHandler.class).value()) { + methods.get(TextMessageHandler.class).put(value, new InvokeMethod(method, parameters[0])); + } + } else + System.err.println(method + " is annotated with @TextMessageHandler, but it is not static. For the annotation to work, the method must be static."); + } + + } + } catch (NoClassDefFoundError | UnsupportedClassVersionError | ClassNotFoundException e) { + if (errorHandler != null) errorHandler.onError(e); + } + } + + public void setErrorHandler(ErrorHandler errorHandler) { + ClassFinder.errorHandler = errorHandler; + } + + public interface ErrorHandler { + void onError(Throwable throwable); + } + +} diff --git a/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java b/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java new file mode 100644 index 0000000..e30980a --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java @@ -0,0 +1,7 @@ +package hdvtdev.telegram.util; + +import java.lang.reflect.Method; + +public record InvokeMethod(Method method, Class parameterType) { + +} diff --git a/core/src/main/java/hdvtdev/telegram/util/ParseMode.java b/core/src/main/java/hdvtdev/telegram/util/ParseMode.java new file mode 100644 index 0000000..3837775 --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/util/ParseMode.java @@ -0,0 +1,7 @@ +package hdvtdev.telegram.util; + +public enum ParseMode { + MARKDOWN, + MARKDOWNV2, + HTML +} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/util/Util.java b/core/src/main/java/hdvtdev/telegram/util/Util.java new file mode 100644 index 0000000..457268e --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/util/Util.java @@ -0,0 +1,98 @@ +package hdvtdev.telegram.util; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public class Util { + + public static void pretty(Path filePath) { + try { + if (filePath.toString().contains("InlineKeyboard")) return; + List lines = Files.readAllLines(filePath); + HashSet linesSet = new HashSet<>(lines); + ArrayList res = new ArrayList<>(lines.size()); + + if (!linesSet.contains("import com.fasterxml.jackson.annotation.JsonProperty;")) + lines.add(2, "import com.fasterxml.jackson.annotation.JsonProperty;"); + boolean inRecord = false; + for (String line : lines) { + if (line.contains("@JsonProperty\\(.*?\\)")) { + res.add(line); + continue; + } + if (!line.contains("@") && !line.contains("class") && !line.contains("=")) { + if (line.contains("record")) { + String bufferLine = line; + if (bufferLine.replaceAll("[{}]", "").trim().endsWith(")")) { + if (bufferLine.contains("()")) { + res.add(line); + continue; + } + bufferLine = bufferLine.split("\\(", 2)[1]; + bufferLine = bufferLine.split("\\)", 2)[0]; + + if (bufferLine.contains(",")) { + for (String element : bufferLine.split(",")) { + element = element.strip(); + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); + line = line.replace(element, ann); + } + } else { + String element = bufferLine.strip(); + if (element.isEmpty()) continue; + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); + line = line.replace(element, ann); + } + } else { + inRecord = true; + res.add(line); + continue; + } + } + if (inRecord) { + if (line.contains("{") && line.contains(")")) { + inRecord = false; + } else { + if (line.isEmpty() || line.contains("}")) { + res.add(line); + continue; + } + String element = line.strip(); + if (element.isEmpty()) continue; + String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1].replace(",", ""), element); + line = line.replace(element, ann); + } + } + + } + res.add(line); + } + BufferedWriter writer = new BufferedWriter(new FileWriter(filePath.toFile())); + for (String s : res) { + writer.write(s); + writer.newLine(); + } + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void date() { + LocalDate today = LocalDate.now(); + DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; // формат ГГГГ-ММ-ДД + + String formattedDate = today.format(formatter); + System.out.println(formattedDate); + } + +} diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java new file mode 100644 index 0000000..5b2ffe2 --- /dev/null +++ b/core/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module hdvtdev.telegram.core { + exports hdvtdev.telegram.core; +} \ No newline at end of file diff --git a/longpolling-okhttp/build.gradle b/longpolling-okhttp/build.gradle new file mode 100644 index 0000000..77cd762 --- /dev/null +++ b/longpolling-okhttp/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'java' +} + +group = 'com.github.hdvtdev' +version = '1.0.0' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation(project(":core")) +} + +tasks.register('fat') { + jar { + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } +} + diff --git a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java new file mode 100644 index 0000000..f186644 --- /dev/null +++ b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java @@ -0,0 +1,335 @@ +package hdvtdev.telegram.longpolling; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler; +import hdvtdev.telegram.annotations.handlers.TextMessageHandler; +import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.core.TelegramBot; +import hdvtdev.telegram.exceptions.TelegramApiException; +import hdvtdev.telegram.exceptions.TelegramApiNetworkException; +import hdvtdev.telegram.exceptions.TelegramMethodParsingException; +import hdvtdev.telegram.methods.GetUpdates; +import hdvtdev.telegram.methods.TelegramApiMethod; +import hdvtdev.telegram.objects.CallbackQuery; +import hdvtdev.telegram.objects.Message; +import hdvtdev.telegram.objects.TelegramFile; +import hdvtdev.telegram.objects.Update; +import hdvtdev.telegram.util.ClassFinder; +import hdvtdev.telegram.util.InvokeMethod; + +import okhttp3.*; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.HttpURLConnection; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicLong; + + +public class OkHttpTelegramBot implements TelegramBot { + + private final String TELEGRAM_API_URL; + private final String TELEGRAM_FILE_API_URL; + private final ObjectMapper json = new ObjectMapper(); + + static { + try { + HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.telegram.org").toURL().openConnection(); + connection.setRequestMethod("HEAD"); + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + int responseCode = connection.getResponseCode(); + + if (responseCode != 200) { + throw new TelegramApiNetworkException("Telegram API is unreachable. Response code: " + responseCode); + } + } catch (IOException e) { + throw new TelegramApiNetworkException("Error checking Telegram API connectivity.", e); + } + } + + private ExecutorService thread; + private AtomicLong lastUpdateId; + private int updateLimit = 10; + private int updateTimeout = 25; + private final OkHttpClient client = buildOkHttpClient(); + + private OkHttpClient buildOkHttpClient() { + Dispatcher dispatcher = new Dispatcher(); + dispatcher.setMaxRequests(100); + dispatcher.setMaxRequestsPerHost(100); + + return new OkHttpClient.Builder() + .dispatcher(dispatcher) + .connectionPool(new ConnectionPool( + 100, + 75, + TimeUnit.SECONDS + )) + .readTimeout(updateTimeout + 10, TimeUnit.SECONDS) + .writeTimeout(updateTimeout, TimeUnit.SECONDS) + .connectTimeout(updateTimeout, TimeUnit.SECONDS) + .retryOnConnectionFailure(true) + .build(); + } + + private UpdateConsumer updateConsumer; + + private boolean enableHandlers = false; + private Map messageHandlers; + private Map callbackQueryHandlers; + + private UserState userState; + private Map userStateStorage; + + public UserState getUserState(String id) { + return userStateStorage.getOrDefault(id, userState); + } + + public void setUserState(String id, UserState userState) { + userStateStorage.put(id, userState); + } + + public boolean compareUserState(String id, UserState userState) { + return getUserState(id).equals(userState); + } + + public OkHttpTelegramBot(String token) { + this.TELEGRAM_API_URL = "https://api.telegram.org/bot" + token + "/"; + this.TELEGRAM_FILE_API_URL = "https://api.telegram.org/file/bot" + token + "/"; + } + + private OkHttpTelegramBot(Builder builder) { + updateLimit = builder.updateLimit; + updateTimeout = builder.updateTimeout; + enableHandlers = builder.enableHandlers; + userStateStorage = builder.userStateStorage; + userState = builder.userState; + if (builder.updateConsumer != null) setUpdateConsumer(builder.updateConsumer); + if (enableHandlers) { + Class updateConsumerClass = builder.updateConsumer == null ? UpdateConsumer.class : builder.updateConsumer.getClass(); + Map, Map> handlers = builder.enableScan ? ClassFinder.getClasses() : ClassFinder.localScan(updateConsumerClass); + this.messageHandlers = Collections.unmodifiableMap(handlers.get(TextMessageHandler.class)); + this.callbackQueryHandlers = Collections.unmodifiableMap(handlers.get(CallbackQueryHandler.class)); + } + this.TELEGRAM_API_URL = "https://api.telegram.org/bot" + builder.token + "/"; + this.TELEGRAM_FILE_API_URL = "https://api.telegram.org/file/bot" + builder.token + "/"; + } + + /** + * Enables the default long polling update consumer for handlers. + *

+ * This method is effective only if {@link #enableHandlers} is{@code true}, + * otherwise, it just marks updates as read/processed without invoking any handlers. + *

+ *


+     * Equivalent to: setUpdateConsumer(null);
+     * 
+ * @throws IllegalStateException if an {@code UpdateConsumer} is already defined + * @see #setUpdateConsumer(UpdateConsumer) + * @see #enableHandlers + * @since 0.0.1 + */ + public void enableDefaultUpdateConsumer() throws IllegalStateException { + setUpdateConsumer(null); + } + + /** + * Enables a long polling update consumer. If {@link #enableHandlers} is {@code true}, + * the specified handlers will be invoked for each received update. + * + * @param updateConsumer class that implements {@code UpdateConsumer} + * @throws IllegalStateException if an {@code UpdateConsumer} is already defined + * @see #enableDefaultUpdateConsumer() + * @see #enableHandlers + * @since 0.0.1 + */ + public void setUpdateConsumer(UpdateConsumer updateConsumer) throws IllegalStateException { + if (thread != null) + throw new IllegalStateException("Update Consumer is already defined. You must first stop the previous"); + this.updateConsumer = updateConsumer; + this.lastUpdateId = new AtomicLong(0); + thread = Executors.newSingleThreadExecutor(); + thread.execute(this::getUpdates); + } + + private void getUpdates() { + List updates = List.of(awaitExecute(new GetUpdates(lastUpdateId.get() + 1, updateLimit, updateTimeout))); + System.out.println("UPDATE"); + if (!updates.isEmpty()) { + try { + if (enableHandlers) { + for (Update update : updates) { + CompletableFuture.runAsync(() -> { + if (update.hasMessage()) { + Message message = update.message(); + if (message.hasText() && !messageHandlers.isEmpty()) { + String key = message.text(); + invokeAnnotatedMethod(messageHandlers.containsKey("*") ? messageHandlers.get("*") : messageHandlers.get(key), update); + } + } + if (update.hasCallbackQuery()) { + CallbackQuery callbackQuery = update.callbackQuery(); + if (callbackQuery.hasMessage()) { + Message message = (Message) callbackQuery.message(); + if (message.hasText() && !callbackQueryHandlers.isEmpty()) { + invokeAnnotatedMethod(callbackQueryHandlers.containsKey("*") ? callbackQueryHandlers.get("*") : callbackQueryHandlers.get(message.text()), update); + } + } + } + }); + } + } + if (updateConsumer != null) CompletableFuture.runAsync(() -> updateConsumer.getUpdates(updates)); + } finally { + lastUpdateId.set(updates.getLast().updateId()); + if (!thread.isShutdown()) getUpdates(); + } + } + + } + + private static void invokeAnnotatedMethod(InvokeMethod invokeMethod, Update update) { + + if (invokeMethod != null) { + Method method = invokeMethod.method(); + method.setAccessible(true); + try { + switch (invokeMethod.parameterType().getSimpleName()) { + case "Message" -> method.invoke(null, update.message()); + case "Update" -> method.invoke(null, update); + case "CallbackQuery" -> method.invoke(null, update.callbackQuery()); + default -> method.invoke(null); + } + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + } + + public void shutdownUpdateConsumer() { + this.thread.close(); + } + + public T awaitExecute(TelegramApiMethod telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException { + + RequestBody body = telegramApiMethod.getBody(); + + Request.Builder request = new Request.Builder() + .url(TELEGRAM_API_URL + telegramApiMethod.getMethodName()); + if (body == null) { + if (telegramApiMethod.getClass().isAnnotationPresent(Jsonable.class)) { + try { + request.post(RequestBody.create(json.writeValueAsString(telegramApiMethod), MediaType.get("application/json; charset=utf-8"))); + } catch (JsonProcessingException e) { + throw new TelegramMethodParsingException(e); + } + } + } else request.post(body); + + try (Response response = client.newCall(request.build()).execute()) { + String responseBody = Objects.requireNonNull(response.body()).string(); + if (response.isSuccessful()) { + JsonNode rootNode = json.readTree(responseBody); + JsonNode resultNode = rootNode.path("result"); + return json.treeToValue(resultNode, telegramApiMethod.getResponseClass()); + } else { + throw new TelegramApiException(json.readValue(responseBody, TelegramApiException.ErrorResponse.class)); + } + } catch (IOException e) { + throw new TelegramApiNetworkException(e); + } + + + } + + @NotNull + private File getFile(TelegramFile telegramFile, Path targetDirectory) { + try (Response response = client.newCall(new Request.Builder().url(TELEGRAM_FILE_API_URL + telegramFile.filePath()).build()).execute()) { + ResponseBody responseBody = Objects.requireNonNull(response.body()); + if (!response.isSuccessful()) + throw new TelegramApiException(json.readValue(responseBody.string(), TelegramApiException.ErrorResponse.class)); + Path filePath = Files.isDirectory(targetDirectory) ? targetDirectory.resolve(Path.of(telegramFile.filePath()).getFileName()) : targetDirectory; + Files.copy(responseBody.byteStream(), filePath, StandardCopyOption.REPLACE_EXISTING); + return new File(filePath.toUri()); + } catch (IOException e) { + throw new TelegramApiNetworkException(e); + } + } + + public File awaitDownloadFile(TelegramFile telegramFile, Path targetDirectory) { + return getFile(telegramFile, targetDirectory); + } + + + public static final class Builder { + private int updateLimit = 10; + private int updateTimeout = 25; + private boolean enableHandlers = false; + private boolean enableScan = false; + private final String token; + private Map userStateStorage; + private UserState userState; + private UpdateConsumer updateConsumer; + + public Builder(String token) { + this.token = token; + } + + public Builder updateConsumer(Main.Upd updateConsumer) { + this.updateConsumer = updateConsumer; + return this; + } + + public Builder enableUserStateStorage(UserState defaultValue, Map userStateStorage) { + this.userState = defaultValue; + this.userStateStorage = userStateStorage; + return this; + } + + public Builder enableUserStateStorage(UserState defaultValue) { + return enableUserStateStorage(defaultValue, new ConcurrentHashMap<>()); + } + + public Builder updateLimit(int updateLimit) { + this.updateLimit = updateLimit; + return this; + } + + public Builder updateTimeout(int updateTimeout) { + this.updateTimeout = updateTimeout; + return this; + } + + public Builder enableHandlers() { + this.enableHandlers = true; + return this; + } + + public Builder enableHandlers(boolean enableScan) { + this.enableHandlers = true; + this.enableScan = enableScan; + return this; + } + + public OkHttpTelegramBot build() { + return new OkHttpTelegramBot(this); + } + } +} diff --git a/longpolling-okhttp/src/main/java/module-info.java b/longpolling-okhttp/src/main/java/module-info.java new file mode 100644 index 0000000..46bf3f8 --- /dev/null +++ b/longpolling-okhttp/src/main/java/module-info.java @@ -0,0 +1,6 @@ +module longpolling.okhttp { + exports hdvtdev.telegram.longpolling; + requires com.fasterxml.jackson.databind; + requires core; + requires okhttp3; +} diff --git a/test/build.gradle b/test/build.gradle new file mode 100644 index 0000000..d4eb6b4 --- /dev/null +++ b/test/build.gradle @@ -0,0 +1,17 @@ +plugins { + id 'java' +} + +group = 'com.github.hdvtdev' +version = '1.0.0' + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":core")) + implementation(project(":longpolling-okhttp")) +} + + diff --git a/test/src/main/java/Main.java b/test/src/main/java/Main.java new file mode 100644 index 0000000..1e936b3 --- /dev/null +++ b/test/src/main/java/Main.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class Main { +} From 7b66404e3e1b97edc796105be88be91a05446138 Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Tue, 22 Apr 2025 12:36:22 +0300 Subject: [PATCH 2/6] some refactoring --- .gitignore | 2 +- .idea/gradle.xml | 5 +++++ build.gradle | 20 ++++++++++---------- settings.gradle | 6 ++++++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index dae3f48..560059e 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,4 @@ bin/ ### Mac OS ### .DS_Store -/src/main/java/hdvtdev/telegram/Count.java +/core/src/main/java/hdvtdev/telegram/Count.java diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ce1c62c..7244181 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -8,6 +8,11 @@ diff --git a/build.gradle b/build.gradle index 8035c26..a662c31 100644 --- a/build.gradle +++ b/build.gradle @@ -10,18 +10,18 @@ repositories { } dependencies { - implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' - implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation(project(":core")) + implementation(project(":longpolling-okhttp")) + implementation(project(":test")) } -jar { - - manifest { - attributes( - 'Main-Class': 'hdvtdev.telegram.Main' - ) - } - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } +tasks.register('fat', Jar) { + archiveClassifier.set('all') duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from sourceSets.main.output + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } } + diff --git a/settings.gradle b/settings.gradle index ef3e3e5..8c3e3e0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,8 @@ rootProject.name = 'TeleJ' +include 'longpolling' +include 'core' +include 'longpolling:longpolling-okhttp' +findProject(':longpolling:longpolling-okhttp')?.name = 'longpolling-okhttp' +include 'test' +include 'longpolling-okhttp' From 111eafdc0a8c16e05509e33bbaeaeed38cfc7227 Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Tue, 22 Apr 2025 12:37:13 +0300 Subject: [PATCH 3/6] some refactoring --- core/src/main/java/hdvtdev/telegram/Main.java | 55 ---- .../handlers/CallbackQueryHandler.java | 58 ---- .../handlers/TextMessageHandler.java | 61 ---- .../telegram/annotations/util/Jsonable.java | 19 -- .../telegram/annotations/util/NotTested.java | 18 -- .../hdvtdev/telegram/core/InvokeMethod.java | 2 +- .../main/java/hdvtdev/telegram/core/Main.java | 52 ---- .../hdvtdev/telegram/core/TelegramBot.java | 12 +- .../hdvtdev/telegram/core/UpdateConsumer.java | 2 +- .../java/hdvtdev/telegram/core/UserState.java | 2 +- .../core/exceptions/TelegramApiException.java | 3 +- .../TelegramApiNetworkException.java | 2 +- .../TelegramMethodParsingException.java | 2 +- .../core/methods/AnswerCallbackQuery.java | 30 +- .../core/methods/ApproveChatJoinRequest.java | 26 +- .../telegram/core/methods/BanChatMember.java | 29 +- .../core/methods/BanChatSenderChat.java | 24 +- .../core/methods/CloseForumTopic.java | 18 +- .../core/methods/CloseGeneralForumTopic.java | 18 +- .../telegram/core/methods/CopyMessage.java | 26 +- .../telegram/core/methods/CopyMessages.java | 40 ++- .../core/methods/CreateChatInviteLink.java | 25 +- .../telegram/core/methods/ForwardMessage.java | 13 +- .../core/methods/ForwardMessages.java | 19 +- .../core/methods/GetChatAdministrators.java | 20 +- .../telegram/core/methods/GetChatMember.java | 18 +- .../telegram/core/methods/GetFile.java | 12 +- .../hdvtdev/telegram/core/methods/GetMe.java | 7 +- .../telegram/core/methods/GetMyCommands.java | 16 +- .../core/methods/GetMyDescription.java | 19 +- .../telegram/core/methods/GetMyName.java | 17 +- .../telegram/core/methods/GetUpdates.java | 8 +- .../core/methods/RevokeChatInviteLink.java | 24 +- .../telegram/core/methods/SendChatAction.java | 25 +- .../telegram/core/methods/SendDice.java | 14 +- .../telegram/core/methods/SendMessage.java | 15 +- .../core/methods/SetMessageReaction.java | 10 +- .../telegram/core/methods/SetMyCommands.java | 11 +- .../core/methods/SetMyDescription.java | 19 +- .../telegram/core/methods/SetMyName.java | 14 +- .../core/methods/TelegramApiMethod.java | 6 +- .../core/methods/TelegramApiMethodBody.java | 2 +- .../telegram/core/methods/util/ParseMode.java | 2 +- .../telegram/core/methods/util/Util.java | 2 +- .../core/objects/AnswerCallbackQuery.java | 113 -------- .../core/objects/ApproveChatJoinRequest.java | 51 ---- .../telegram/core/objects/BanChatMember.java | 110 ------- .../core/objects/BanChatSenderChat.java | 38 --- .../core/objects/CloseForumTopic.java | 37 --- .../core/objects/CloseGeneralForumTopic.java | 37 --- .../telegram/core/objects/CopyMessage.java | 244 ---------------- .../telegram/core/objects/CopyMessages.java | 181 ------------ .../core/objects/CreateChatInviteLink.java | 114 -------- .../telegram/core/objects/ForwardMessage.java | 133 --------- .../core/objects/ForwardMessages.java | 147 ---------- .../hdvtdev/telegram/core/objects/Game.java | 3 + .../core/objects/GetChatAdministrators.java | 36 --- .../telegram/core/objects/GetChatMember.java | 38 --- .../telegram/core/objects/GetFile.java | 23 -- .../hdvtdev/telegram/core/objects/GetMe.java | 22 -- .../telegram/core/objects/GetMyCommands.java | 58 ---- .../core/objects/GetMyDescription.java | 42 --- .../telegram/core/objects/GetMyName.java | 38 --- .../telegram/core/objects/GetUpdates.java | 42 --- .../core/objects/ReplyParameters.java | 1 + .../core/objects/RevokeChatInviteLink.java | 37 --- .../telegram/core/objects/SendChatAction.java | 104 ------- .../telegram/core/objects/SendDice.java | 133 --------- .../telegram/core/objects/SendMessage.java | 226 --------------- .../core/objects/SetMessageReaction.java | 100 ------- .../telegram/core/objects/SetMyCommands.java | 100 ------- .../core/objects/SetMyDescription.java | 41 --- .../telegram/core/objects/SetMyName.java | 28 -- .../telegram/core/objects/SharedUser.java | 1 + .../core/objects/TelegramApiMethod.java | 13 - .../hdvtdev/telegram/core/objects/Update.java | 15 + .../objects/background/BackgroundFill.java | 2 +- .../BackgroundFillDeserializer.java | 25 +- .../BackgroundFillFreeformGradient.java | 2 +- .../background/BackgroundFillGradient.java | 2 +- .../background/BackgroundFillSolid.java | 2 +- .../objects/background/BackgroundType.java | 17 +- .../background/BackgroundTypeChatTheme.java | 2 +- .../BackgroundTypeDeserializer.java | 26 +- .../background/BackgroundTypeFill.java | 2 +- .../background/BackgroundTypePattern.java | 3 +- .../background/BackgroundTypeWallpaper.java | 3 +- .../objects/business/BusinessConnection.java | 3 +- .../business/BusinessMessagesDeleted.java | 2 +- .../core/objects/callback/CallbackGame.java | 2 +- .../core/objects/callback/CallbackQuery.java | 3 +- .../telegram/core/objects/chat/Chat.java | 2 +- .../objects/chat/ChatAdministratorRights.java | 2 +- .../core/objects/chat/ChatBackground.java | 3 +- .../core/objects/chat/ChatInviteLink.java | 5 +- .../core/objects/chat/ChatJoinRequest.java | 3 +- .../core/objects/chat/ChatMember.java | 3 +- .../objects/chat/ChatMemberAdministrator.java | 3 +- .../core/objects/chat/ChatMemberBanned.java | 3 +- .../core/objects/chat/ChatMemberLeft.java | 3 +- .../core/objects/chat/ChatMemberMember.java | 3 +- .../core/objects/chat/ChatMemberOwner.java | 3 +- .../objects/chat/ChatMemberRestricted.java | 3 +- .../core/objects/chat/ChatMemberUpdated.java | 3 +- .../core/objects/chat/ChatShared.java | 3 +- .../core/objects/chatboost/ChatBoost.java | 2 +- .../objects/chatboost/ChatBoostAdded.java | 2 +- .../objects/chatboost/ChatBoostRemoved.java | 3 +- .../objects/chatboost/ChatBoostSource.java | 2 +- .../chatboost/ChatBoostSourceGiftCode.java | 3 +- .../chatboost/ChatBoostSourceGiveaway.java | 3 +- .../chatboost/ChatBoostSourcePremium.java | 3 +- .../objects/chatboost/ChatBoostUpdated.java | 3 +- .../core/objects/command/BotCommand.java | 2 +- .../core/objects/command/BotCommandScope.java | 2 +- .../BotCommandScopeAllChatAdministrators.java | 2 +- .../command/BotCommandScopeAllGroupChats.java | 2 +- .../BotCommandScopeAllPrivateChats.java | 2 +- .../objects/command/BotCommandScopeChat.java | 2 +- .../BotCommandScopeChatAdministrators.java | 2 +- .../command/BotCommandScopeChatMember.java | 2 +- .../command/BotCommandScopeDefault.java | 2 +- .../core/objects/forum/ForumTopicClosed.java | 2 +- .../core/objects/forum/ForumTopicCreated.java | 2 +- .../core/objects/forum/ForumTopicEdited.java | 2 +- .../objects/forum/ForumTopicReopened.java | 2 +- .../forum/GeneralForumTopicHidden.java | 2 +- .../forum/GeneralForumTopicUnhidden.java | 2 +- .../core/objects/giveaway/Giveaway.java | 2 +- .../objects/giveaway/GiveawayCompleted.java | 2 +- .../objects/giveaway/GiveawayCreated.java | 2 +- .../objects/giveaway/GiveawayWinners.java | 3 +- .../core/objects/markup/CopyTextButton.java | 2 +- .../core/objects/markup/ForceReply.java | 3 +- .../objects/markup/InlineKeyboardButton.java | 4 +- .../objects/markup/InlineKeyboardMarkup.java | 2 +- .../objects/markup/InlineKeyboardRow.java | 5 +- .../core/objects/markup/KeyboardButton.java | 3 +- .../markup/KeyboardButtonPollType.java | 2 +- .../markup/KeyboardButtonRequestChat.java | 2 +- .../markup/KeyboardButtonRequestUsers.java | 2 +- .../objects/markup/ReplyKeyboardMarkup.java | 2 +- .../objects/markup/ReplyKeyboardRemove.java | 2 +- .../core/objects/markup/ReplyMarkup.java | 2 +- .../markup/SwitchInlineQueryChosenChat.java | 2 +- .../core/objects/media/Animation.java | 2 +- .../telegram/core/objects/media/Audio.java | 2 +- .../telegram/core/objects/media/Document.java | 8 +- .../core/objects/media/PhotoSize.java | 2 +- .../telegram/core/objects/media/Sticker.java | 3 +- .../telegram/core/objects/media/Story.java | 2 +- .../core/objects/media/TelegramFile.java | 2 +- .../telegram/core/objects/media/Voice.java | 2 +- .../objects/media/paidmedia/PaidMedia.java | 2 +- .../media/paidmedia/PaidMediaInfo.java | 2 +- .../media/paidmedia/PaidMediaPhoto.java | 3 +- .../media/paidmedia/PaidMediaPreview.java | 2 +- .../media/paidmedia/PaidMediaPurchased.java | 3 +- .../media/paidmedia/PaidMediaVideo.java | 3 +- .../core/objects/media/video/Video.java | 3 +- .../objects/media/video/VideoChatEnded.java | 2 +- .../video/VideoChatParticipantsInvited.java | 3 +- .../media/video/VideoChatScheduled.java | 2 +- .../objects/media/video/VideoChatStarted.java | 2 +- .../core/objects/media/video/VideoNote.java | 3 +- .../objects/message/ExternalReplyInfo.java | 5 +- .../objects/message/InaccessibleMessage.java | 3 +- .../objects/message/LinkPreviewOptions.java | 2 +- .../message/MaybeInaccessibleMessage.java | 3 +- .../MaybeInaccessibleMessageDeserializer.java | 2 +- .../core/objects/message/Message.java | 20 +- .../MessageAutoDeleteTimerChanged.java | 2 +- .../core/objects/message/MessageEntity.java | 3 +- .../core/objects/message/MessageOrigin.java | 2 +- .../objects/message/MessageOriginChannel.java | 3 +- .../objects/message/MessageOriginChat.java | 3 +- .../message/MessageOriginHiddenUser.java | 2 +- .../objects/message/MessageOriginUser.java | 3 +- .../message/MessageReactionCountUpdated.java | 4 +- .../message/MessageReactionUpdated.java | 5 +- .../core/objects/message/TextQuote.java | 3 +- .../passport/EncryptedCredentials.java | 2 +- .../passport/EncryptedPassportElement.java | 2 +- .../core/objects/passport/PassportData.java | 2 +- .../core/objects/passport/PassportFile.java | 2 +- .../core/objects/payment/Invoice.java | 2 +- .../core/objects/payment/OrderInfo.java | 2 +- .../objects/payment/PreCheckoutQuery.java | 3 +- .../core/objects/payment/RefundedPayment.java | 2 +- .../core/objects/payment/ShippingAddress.java | 2 +- .../core/objects/payment/ShippingQuery.java | 3 +- .../objects/payment/SuccessfulPayment.java | 2 +- .../telegram/core/objects/poll/Poll.java | 2 +- .../core/objects/poll/PollAnswer.java | 3 +- .../core/objects/poll/PollOption.java | 2 +- .../core/objects/reaction/ReactionCount.java | 2 +- .../core/objects/reaction/ReactionType.java | 2 +- .../reaction/ReactionTypeCustomEmoji.java | 2 +- .../objects/reaction/ReactionTypeEmoji.java | 2 +- .../objects/reaction/ReactionTypePaid.java | 2 +- .../exceptions/TelegramApiException.java | 30 -- .../TelegramApiNetworkException.java | 17 -- .../TelegramMethodParsingException.java | 11 - .../telegram/methods/AnswerCallbackQuery.java | 113 -------- .../methods/ApproveChatJoinRequest.java | 51 ---- .../telegram/methods/BanChatMember.java | 110 ------- .../telegram/methods/BanChatSenderChat.java | 38 --- .../telegram/methods/CloseForumTopic.java | 37 --- .../methods/CloseGeneralForumTopic.java | 37 --- .../hdvtdev/telegram/methods/CopyMessage.java | 244 ---------------- .../telegram/methods/CopyMessages.java | 181 ------------ .../methods/CreateChatInviteLink.java | 114 -------- .../telegram/methods/ForwardMessage.java | 133 --------- .../telegram/methods/ForwardMessages.java | 147 ---------- .../methods/GetChatAdministrators.java | 36 --- .../telegram/methods/GetChatMember.java | 38 --- .../hdvtdev/telegram/methods/GetFile.java | 23 -- .../java/hdvtdev/telegram/methods/GetMe.java | 22 -- .../telegram/methods/GetMyCommands.java | 58 ---- .../telegram/methods/GetMyDescription.java | 42 --- .../hdvtdev/telegram/methods/GetMyName.java | 38 --- .../hdvtdev/telegram/methods/GetUpdates.java | 42 --- .../methods/RevokeChatInviteLink.java | 37 --- .../telegram/methods/SendChatAction.java | 104 ------- .../hdvtdev/telegram/methods/SendDice.java | 133 --------- .../hdvtdev/telegram/methods/SendMessage.java | 226 --------------- .../telegram/methods/SetMessageReaction.java | 100 ------- .../telegram/methods/SetMyCommands.java | 100 ------- .../telegram/methods/SetMyDescription.java | 41 --- .../hdvtdev/telegram/methods/SetMyName.java | 28 -- .../telegram/methods/TelegramApiMethod.java | 13 - .../hdvtdev/telegram/objects/Animation.java | 37 --- .../java/hdvtdev/telegram/objects/Audio.java | 37 --- .../telegram/objects/BackgroundFill.java | 18 -- .../BackgroundFillFreeformGradient.java | 13 - .../objects/BackgroundFillGradient.java | 15 - .../telegram/objects/BackgroundFillSolid.java | 13 - .../telegram/objects/BackgroundType.java | 19 -- .../objects/BackgroundTypeChatTheme.java | 13 - .../telegram/objects/BackgroundTypeFill.java | 14 - .../objects/BackgroundTypePattern.java | 16 - .../objects/BackgroundTypeWallpaper.java | 16 - .../telegram/objects/BusinessConnection.java | 17 -- .../objects/BusinessMessagesDeleted.java | 14 - .../telegram/objects/CallbackGame.java | 9 - .../telegram/objects/CallbackQuery.java | 39 --- .../java/hdvtdev/telegram/objects/Chat.java | 35 --- .../objects/ChatAdministratorRights.java | 26 -- .../telegram/objects/ChatBackground.java | 10 - .../hdvtdev/telegram/objects/ChatBoost.java | 15 - .../telegram/objects/ChatBoostAdded.java | 12 - .../telegram/objects/ChatBoostRemoved.java | 15 - .../telegram/objects/ChatBoostSource.java | 18 -- .../objects/ChatBoostSourceGiftCode.java | 13 - .../objects/ChatBoostSourceGiveaway.java | 16 - .../objects/ChatBoostSourcePremium.java | 13 - .../telegram/objects/ChatBoostUpdated.java | 13 - .../telegram/objects/ChatInviteLink.java | 29 -- .../telegram/objects/ChatJoinRequest.java | 17 -- .../hdvtdev/telegram/objects/ChatMember.java | 28 -- .../objects/ChatMemberAdministrator.java | 30 -- .../telegram/objects/ChatMemberBanned.java | 14 - .../telegram/objects/ChatMemberLeft.java | 13 - .../telegram/objects/ChatMemberMember.java | 14 - .../telegram/objects/ChatMemberOwner.java | 15 - .../objects/ChatMemberRestricted.java | 29 -- .../telegram/objects/ChatMemberUpdated.java | 19 -- .../hdvtdev/telegram/objects/ChatShared.java | 16 - .../telegram/objects/ChosenInlineResult.java | 16 - .../hdvtdev/telegram/objects/Contact.java | 16 - .../telegram/objects/CopyTextButton.java | 10 - .../java/hdvtdev/telegram/objects/Dice.java | 13 - .../hdvtdev/telegram/objects/Document.java | 21 -- .../objects/EncryptedCredentials.java | 14 - .../objects/EncryptedPassportElement.java | 21 -- .../telegram/objects/ExternalReplyInfo.java | 35 --- .../hdvtdev/telegram/objects/ForceReply.java | 14 - .../telegram/objects/ForumTopicClosed.java | 9 - .../telegram/objects/ForumTopicCreated.java | 14 - .../telegram/objects/ForumTopicEdited.java | 13 - .../telegram/objects/ForumTopicReopened.java | 9 - .../java/hdvtdev/telegram/objects/Game.java | 17 -- .../objects/GeneralForumTopicHidden.java | 9 - .../objects/GeneralForumTopicUnhidden.java | 9 - .../hdvtdev/telegram/objects/Giveaway.java | 20 -- .../telegram/objects/GiveawayCompleted.java | 15 - .../telegram/objects/GiveawayCreated.java | 10 - .../telegram/objects/GiveawayWinners.java | 23 -- .../telegram/objects/InaccessibleMessage.java | 15 - .../objects/InlineKeyboardButton.java | 250 ---------------- .../objects/InlineKeyboardMarkup.java | 35 --- .../telegram/objects/InlineKeyboardRow.java | 69 ----- .../hdvtdev/telegram/objects/InlineQuery.java | 17 -- .../hdvtdev/telegram/objects/Invoice.java | 16 - .../telegram/objects/KeyboardButton.java | 18 -- .../objects/KeyboardButtonPollType.java | 12 - .../objects/KeyboardButtonRequestChat.java | 22 -- .../objects/KeyboardButtonRequestUsers.java | 18 -- .../telegram/objects/LinkPreviewOptions.java | 17 -- .../hdvtdev/telegram/objects/Location.java | 17 -- .../hdvtdev/telegram/objects/LoginUrl.java | 15 - .../telegram/objects/MaskPosition.java | 15 - .../objects/MaybeInaccessibleMessage.java | 15 - .../MaybeInaccessibleMessageDeserializer.java | 16 - .../hdvtdev/telegram/objects/Message.java | 274 ------------------ .../MessageAutoDeleteTimerChanged.java | 10 - .../telegram/objects/MessageEntity.java | 18 -- .../telegram/objects/MessageOrigin.java | 19 -- .../objects/MessageOriginChannel.java | 16 - .../telegram/objects/MessageOriginChat.java | 15 - .../objects/MessageOriginHiddenUser.java | 14 - .../telegram/objects/MessageOriginUser.java | 14 - .../objects/MessageReactionCountUpdated.java | 15 - .../objects/MessageReactionUpdated.java | 18 -- .../hdvtdev/telegram/objects/OrderInfo.java | 15 - .../hdvtdev/telegram/objects/PaidMedia.java | 17 -- .../telegram/objects/PaidMediaInfo.java | 13 - .../telegram/objects/PaidMediaPhoto.java | 13 - .../telegram/objects/PaidMediaPreview.java | 15 - .../telegram/objects/PaidMediaPurchased.java | 13 - .../telegram/objects/PaidMediaVideo.java | 13 - .../telegram/objects/PassportData.java | 13 - .../telegram/objects/PassportFile.java | 15 - .../hdvtdev/telegram/objects/PhotoSize.java | 16 - .../java/hdvtdev/telegram/objects/Poll.java | 25 -- .../hdvtdev/telegram/objects/PollAnswer.java | 15 - .../hdvtdev/telegram/objects/PollOption.java | 14 - .../telegram/objects/PreCheckoutQuery.java | 18 -- .../objects/ProximityAlertTriggered.java | 14 - .../telegram/objects/ReactionCount.java | 13 - .../telegram/objects/ReactionType.java | 17 -- .../objects/ReactionTypeCustomEmoji.java | 13 - .../telegram/objects/ReactionTypeEmoji.java | 16 - .../telegram/objects/ReactionTypePaid.java | 12 - .../telegram/objects/RefundedPayment.java | 16 - .../telegram/objects/ReplyKeyboardMarkup.java | 17 -- .../telegram/objects/ReplyKeyboardRemove.java | 13 - .../hdvtdev/telegram/objects/ReplyMarkup.java | 16 - .../telegram/objects/ReplyParameters.java | 28 -- .../hdvtdev/telegram/objects/SharedUser.java | 16 - .../telegram/objects/ShippingAddress.java | 17 -- .../telegram/objects/ShippingQuery.java | 15 - .../hdvtdev/telegram/objects/Sticker.java | 26 -- .../java/hdvtdev/telegram/objects/Story.java | 13 - .../telegram/objects/SuccessfulPayment.java | 21 -- .../objects/SwitchInlineQueryChosenChat.java | 16 - .../telegram/objects/TelegramFile.java | 17 -- .../hdvtdev/telegram/objects/TextQuote.java | 11 - .../java/hdvtdev/telegram/objects/Update.java | 139 --------- .../java/hdvtdev/telegram/objects/User.java | 62 ---- .../hdvtdev/telegram/objects/UsersShared.java | 13 - .../java/hdvtdev/telegram/objects/Venue.java | 18 -- .../java/hdvtdev/telegram/objects/Video.java | 22 -- .../telegram/objects/VideoChatEnded.java | 10 - .../objects/VideoChatParticipantsInvited.java | 10 - .../telegram/objects/VideoChatScheduled.java | 10 - .../telegram/objects/VideoChatStarted.java | 9 - .../hdvtdev/telegram/objects/VideoNote.java | 17 -- .../java/hdvtdev/telegram/objects/Voice.java | 16 - .../hdvtdev/telegram/objects/WebAppData.java | 10 - .../hdvtdev/telegram/objects/WebAppInfo.java | 10 - .../telegram/objects/WriteAccessAllowed.java | 14 - .../telegram/objects/bot/BotCommand.java | 13 - .../telegram/objects/bot/BotCommandScope.java | 22 -- .../BotCommandScopeAllChatAdministrators.java | 10 - .../bot/BotCommandScopeAllGroupChats.java | 10 - .../bot/BotCommandScopeAllPrivateChats.java | 10 - .../objects/bot/BotCommandScopeChat.java | 14 - .../BotCommandScopeChatAdministrators.java | 14 - .../bot/BotCommandScopeChatMember.java | 27 -- .../objects/bot/BotCommandScopeDefault.java | 10 - .../hdvtdev/telegram/util/ClassFinder.java | 136 --------- .../hdvtdev/telegram/util/InvokeMethod.java | 7 - .../java/hdvtdev/telegram/util/ParseMode.java | 7 - .../main/java/hdvtdev/telegram/util/Util.java | 98 ------- core/src/main/java/module-info.java | 22 +- .../longpolling/okhttp/OkHttpTelegramBot.java | 50 ++-- .../src/main/java/module-info.java | 3 +- test/src/main/java/Main.java | 25 +- 379 files changed, 592 insertions(+), 8633 deletions(-) delete mode 100644 core/src/main/java/hdvtdev/telegram/Main.java delete mode 100644 core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java delete mode 100644 core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java delete mode 100644 core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java delete mode 100644 core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java delete mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java delete mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java delete mode 100644 core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetFile.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMe.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetMyName.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendDice.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SendMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/SetMyName.java delete mode 100644 core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Animation.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Audio.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Chat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChatShared.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Contact.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Dice.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Document.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForceReply.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Game.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Giveaway.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Invoice.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Location.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Message.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PassportData.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PassportFile.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Poll.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PollOption.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionType.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/SharedUser.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Sticker.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Story.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/TextQuote.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Update.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/User.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/UsersShared.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Venue.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Video.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/VideoNote.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/Voice.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/WebAppData.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java delete mode 100644 core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java delete mode 100644 core/src/main/java/hdvtdev/telegram/util/ClassFinder.java delete mode 100644 core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java delete mode 100644 core/src/main/java/hdvtdev/telegram/util/ParseMode.java delete mode 100644 core/src/main/java/hdvtdev/telegram/util/Util.java diff --git a/core/src/main/java/hdvtdev/telegram/Main.java b/core/src/main/java/hdvtdev/telegram/Main.java deleted file mode 100644 index a7be11d..0000000 --- a/core/src/main/java/hdvtdev/telegram/Main.java +++ /dev/null @@ -1,55 +0,0 @@ -package hdvtdev.telegram; - -import com.fasterxml.jackson.databind.ObjectMapper; -import hdvtdev.telegram.annotations.handlers.TextMessageHandler; -import hdvtdev.telegram.core.OkHttpTelegramBot; -import hdvtdev.telegram.core.TelegramBot; -import hdvtdev.telegram.core.UpdateConsumer; -import hdvtdev.telegram.exceptions.TelegramApiException; -import hdvtdev.telegram.methods.*; -import hdvtdev.telegram.objects.*; -import hdvtdev.telegram.util.ClassFinder; - -import java.util.Arrays; -import java.util.List; - - -public class Main { - - private static String apiKey; - - private static long idd = 2027845508; - - public static TelegramBot bot; - - @TextMessageHandler("пинг") - private static void ping(Message message) { - bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing()))); - } - - public static void main(String[] args) throws Exception { - - bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build(); - bot.enableDefaultUpdateConsumer(); - - apiKey = args[2]; - } - - - - private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler { - - @Override - public void onError(Throwable throwable) { - throwable.printStackTrace(); - } - - - @Override - public void getUpdates(List updates) { - updates.forEach(System.out::println); - } - } - - -} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java b/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java deleted file mode 100644 index 68e13e4..0000000 --- a/core/src/main/java/hdvtdev/telegram/annotations/handlers/CallbackQueryHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -package hdvtdev.telegram.annotations.handlers; - -import hdvtdev.telegram.objects.CallbackQuery; -import hdvtdev.telegram.objects.Update; - -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a static method as a handler for {@link CallbackQuery} updates with specific data values. - *

- * If {@code value} is set to "*", the method will handle all {@link CallbackQuery} data, - * and other {@code @CallbackQueryHandler} methods will be ignored. - *

- * The annotated method must be {@code static} and may accept: - *

    - *
  • {@link Void} {@code (no params)}
  • - *
  • {@link Update}
  • - *
  • {@link CallbackQuery}
  • - *
- * Only one parameter is allowed. - *

- * You do not need to call {@link CallbackQuery#hasData()} or {@link Update#hasCallbackQuery()}, - * as these checks are performed automatically before invocation. - * - *

Usage example:

- *

- * {@code @CallbackQueryHandler({"stop",}  "shutdown"})
- * private static void stop(CallbackQuery callbackQuery) {
- *     long id = callbackQuery.message.chatId;
- *     if (DatabaseManager.isAdmin(id)) {
- *         bot.awaitExecute(new SendMessage(id, "Shutting down..."));
- *         System.exit(0);
- *     }
- * }
- * 
- *
Last documentation update: 2025-04-05
- * @see Update - * @see CallbackQuery - * @since 1.0.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface CallbackQueryHandler { - /** - * Values to match against {@link CallbackQuery#data()}. - * If set to "*", this method will handle all {@link CallbackQuery} updates, - * overriding any other {@code @CallbackQueryHandler} annotations. - * - * @return array of matching strings - */ - @NotNull String[] value() default "*"; -} - diff --git a/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java b/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java deleted file mode 100644 index 89837b8..0000000 --- a/core/src/main/java/hdvtdev/telegram/annotations/handlers/TextMessageHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package hdvtdev.telegram.annotations.handlers; - -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.Update; - -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a static method as a handler for {@link Message} updates with specific data values. - *

- * If {@code value} is set to "*", the method will handle all {@link Message} text, - * and other {@code @TextMessageHandler} methods will be ignored. - *

- * The annotated method must be {@code static} and may accept: - *

    - *
  • {@link Void} {@code (no params)}
  • - *
  • {@link Update}
  • - *
  • {@link Message}
  • - *
- * Only one parameter is allowed. - *

- * You do not need to call {@link Message#hasText()} or {@link Update#hasMessage()}, - * as these checks are performed automatically before invocation. - * - *

Usage example:

- *

- * {@code @TextMessageHandler}({"rock", "paper", "scissors"})
- * private static void cheaterRockPaperScissors(Message message) {
- *     bot.execute(new SendMessage(message.chatId(), switch(message.text()) {
- *         case "rock" -> "paper";
- *         case "paper" -> "scissors";
- *         default -> "rock";
- *     }));
- *
- * {@code @TextMessageHandler}("/ping")
- * private static void ping(Message message) {
- *     bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing())));
- * }
- * 
- *
Last documentation update: 2025-04-05
- * @see Update - * @see Message - * @since 1.0.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TextMessageHandler { - /** - * Values to match against {@link Message#text()}. - * If set to "*", this method will handle all {@link Message} updates, - * overriding any other {@code @TextMessageHandler} annotations. - * - * @return array of matching strings - */ - @NotNull String[] value() default "*"; -} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java b/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java deleted file mode 100644 index d4bf8fa..0000000 --- a/core/src/main/java/hdvtdev/telegram/annotations/util/Jsonable.java +++ /dev/null @@ -1,19 +0,0 @@ -package hdvtdev.telegram.annotations.util; - -import hdvtdev.telegram.methods.TelegramApiMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation is used to indicate {@link TelegramApiMethod} that should be serialized into JSON. - *
Last documentation update: 2025-04-05
- * @see com.fasterxml.jackson.databind.ObjectMapper - * @since 1.0.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface Jsonable { -} diff --git a/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java b/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java deleted file mode 100644 index 4f75c06..0000000 --- a/core/src/main/java/hdvtdev/telegram/annotations/util/NotTested.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.annotations.util; - -import hdvtdev.telegram.methods.TelegramApiMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation is used to indicate {@link TelegramApiMethod} that is not tested, usually used if the method was created recently. - * @since 1.0.0 - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.SOURCE) -public @interface NotTested { - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java b/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java index 0f70fa3..0046255 100644 --- a/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java +++ b/core/src/main/java/hdvtdev/telegram/core/InvokeMethod.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core; import java.lang.reflect.Method; diff --git a/core/src/main/java/hdvtdev/telegram/core/Main.java b/core/src/main/java/hdvtdev/telegram/core/Main.java index d3da0f0..e69de29 100644 --- a/core/src/main/java/hdvtdev/telegram/core/Main.java +++ b/core/src/main/java/hdvtdev/telegram/core/Main.java @@ -1,52 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.handlers.TextMessageHandler; -import hdvtdev.telegram.longpolling -import hdvtdev.telegram.core.TelegramBot; -import hdvtdev.telegram.core.UpdateConsumer; -import hdvtdev.telegram.methods.*; -import hdvtdev.telegram.objects.*; -import hdvtdev.telegram.util.ClassFinder; - -import java.util.List; - - -public class Main { - - private static String apiKey; - - private static long idd = 2027845508; - - public static TelegramBot bot; - - @TextMessageHandler("пинг") - private static void ping(Message message) { - bot.execute(new SendMessage(message.chatId(), String.valueOf(bot.getPing()))); - } - - public static void main(String[] args) throws Exception { - - bot = new OkHttpTelegramBot.Builder(args[0]).enableHandlers(true).build(); - bot.enableDefaultUpdateConsumer(); - - apiKey = args[2]; - } - - - - private static class Upd implements UpdateConsumer, ClassFinder.ErrorHandler { - - @Override - public void onError(Throwable throwable) { - throwable.printStackTrace(); - } - - - @Override - public void getUpdates(List updates) { - updates.forEach(System.out::println); - } - } - - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java index a32029e..a78e4e5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java +++ b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java @@ -1,10 +1,10 @@ -package hdvtdev.telegram.core.bot; +package hdvtdev.telegram.core; -import hdvtdev.telegram.exceptions.TelegramApiException; -import hdvtdev.telegram.exceptions.TelegramApiNetworkException; -import hdvtdev.telegram.exceptions.TelegramMethodParsingException; -import hdvtdev.telegram.methods.TelegramApiMethod; -import hdvtdev.telegram.objects.TelegramFile; +import hdvtdev.telegram.core.exceptions.TelegramApiException; +import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException; +import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException; +import hdvtdev.telegram.core.methods.TelegramApiMethod; +import hdvtdev.telegram.core.objects.media.TelegramFile; import java.io.File; import java.io.IOException; diff --git a/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java index 2348807..4bba6a6 100644 --- a/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java +++ b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.bot; +package hdvtdev.telegram.core; import hdvtdev.telegram.core.objects.Update; diff --git a/core/src/main/java/hdvtdev/telegram/core/UserState.java b/core/src/main/java/hdvtdev/telegram/core/UserState.java index 3008cd7..194d086 100644 --- a/core/src/main/java/hdvtdev/telegram/core/UserState.java +++ b/core/src/main/java/hdvtdev/telegram/core/UserState.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.bot; +package hdvtdev.telegram.core; public interface UserState { } diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java index 4808610..dc2e074 100644 --- a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiException.java @@ -1,6 +1,5 @@ -package hdvtdev.telegram.exceptions; +package hdvtdev.telegram.core.exceptions; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java index 8ee9c6a..d294e6d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramApiNetworkException.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.exceptions; +package hdvtdev.telegram.core.exceptions; import java.io.IOException; diff --git a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java index cad5c01..a49568c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java +++ b/core/src/main/java/hdvtdev/telegram/core/exceptions/TelegramMethodParsingException.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.exceptions; +package hdvtdev.telegram.core.exceptions; public class TelegramMethodParsingException extends RuntimeException { public TelegramMethodParsingException(String message) { diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java index 13b9a17..0d61199 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/AnswerCallbackQuery.java @@ -1,22 +1,19 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Game; +import hdvtdev.telegram.core.objects.Game; -import okhttp3.FormBody; -import okhttp3.RequestBody; /** * Use this method to send answers to callback queries sent from inline keyboards. * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. * Alternatively, the user can be redirected to the specified {@link Game} URL. - * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * For this option to work, you must first create a game for your command via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your command with a parameter. * @apiNote On success, {@code Boolean == true} is returned. * @since 1.0.0 */ -@NotTested -public class AnswerCallbackQuery implements TelegramApiMethod { +//@NotTested +public final class AnswerCallbackQuery implements TelegramApiMethod { /** * Unique identifier for the query to be answered @@ -33,7 +30,7 @@ public class AnswerCallbackQuery implements TelegramApiMethod { /** * URL that will be opened by the user's client. * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. - * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your command with a parameter. * @apiNote this will only work if the query comes from a callback_game button. */ private String url; @@ -56,13 +53,14 @@ public class AnswerCallbackQuery implements TelegramApiMethod { } @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); - if (text != null) builder.add("text", this.text); - if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); - if (url != null) builder.add("url", this.url); - if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); - return builder.build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("callback_query_id", this.callbackQueryId); + body.add("text", this.text); + body.add("show_alert", String.valueOf(this.showAlert)); + body.add("url", this.url); + body.add("cache_time", String.valueOf(this.cacheTime)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java index 7338266..8e1298a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/ApproveChatJoinRequest.java @@ -1,18 +1,13 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.Chat; -import hdvtdev.telegram.objects.User; +import hdvtdev.telegram.core.objects.chat.Chat; +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; +import hdvtdev.telegram.core.objects.User; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; /** * Use this method to approve a chat join request. - * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. + * The command must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. * Returns True on success. * @param chatId Unique username of the target channel in the format @channelusername * @param userId Unique identifier of the target user @@ -21,8 +16,8 @@ import org.jetbrains.annotations.NotNull; * @see Chat#id() * @since 0.1.0 */ -@NotTested -public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { +//TODO NotTested +public record ApproveChatJoinRequest(String chatId, long userId) implements TelegramApiMethod { /** * @param chatId Unique identifier for the target chat @@ -35,8 +30,11 @@ public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implem } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + body.add("user_id", String.valueOf(userId)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java index 17622c3..5977514 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatMember.java @@ -1,20 +1,19 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; + + +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; /** * Use this method to ban a user in a group, a supergroup or a channel. * In the case of supergroups and channels, the user will not be able to return * to the chat on their own using invite links, etc., unless unbanned first. - * The bot must be an administrator in the chat for this to work and must have + * The command must be an administrator in the chat for this to work and must have * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. * @see ChatAdministratorRights * @since 0.1.1 */ -@NotTested +//TODO NotTested public final class BanChatMember implements TelegramApiMethod { /** @@ -33,8 +32,8 @@ public final class BanChatMember implements TelegramApiMethod { */ private Long untilDate; /** - * Pass true to delete all messages from the chat for the user that is being removed. - * If false, the user will be able to see messages in the group that were sent before the user was removed. + * Pass true to delete all message from the chat for the user that is being removed. + * If false, the user will be able to see message in the group that were sent before the user was removed. * Always True for supergroups and channels. */ private Boolean revokeMessages; @@ -65,11 +64,13 @@ public final class BanChatMember implements TelegramApiMethod { } @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); - if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); - if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); - return builder.build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", this.chatId); + body.add("user_id", String.valueOf(userId)); + body.add("until_date", String.valueOf(untilDate)); + body.add("revoke_messages", String.valueOf(revokeMessages)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java index 323e677..9dff2fb 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/BanChatSenderChat.java @@ -1,29 +1,25 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; +package hdvtdev.telegram.core.methods; /** * Use this method to ban a channel chat in a supergroup or a channel. - * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of - * their channels. The bot must be an administrator in the supergroup or channel for this to + * Until the chat is unbanned, the owner of the banned chat won't be able to send message on behalf of + * their channels. The command must be an administrator in the supergroup or channel for this to * work and must have the appropriate administrator rights. Returns True on success. * @since 1.0.0 */ -@NotTested -public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { +//TODO NotTested +public record BanChatSenderChat(String chatId, long userId) implements TelegramApiMethod { public BanChatSenderChat(long chatId, long userId) { this(String.valueOf(chatId), userId); } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + body.add("user_id", String.valueOf(userId)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java index debe5e5..a401ec7 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CloseForumTopic.java @@ -1,19 +1,16 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; /** * Use this method to close an open topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, + * The command must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, * unless it is the creator of the topic. Returns {@code true} on success. * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param messageThreadId Unique identifier for the target message thread of the forum topic * @see ChatAdministratorRights#canManageTopics() */ -@NotTested +//TODO NotTested public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { public CloseForumTopic(long chatId, long messageThreadId) { @@ -21,8 +18,11 @@ public record CloseForumTopic(String chatId, long messageThreadId) implements Te } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + body.add("message_thread_id", String.valueOf(messageThreadId)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java index 2d2ed8e..1b8394e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CloseGeneralForumTopic.java @@ -1,19 +1,15 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; - -import okhttp3.FormBody; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; /** * Use this method to close an open 'General' topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. + * The command must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. * Returns {@code true} on success. * @see ChatAdministratorRights#canManageTopics() * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ -@NotTested +// TODO NotTested public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { public CloseGeneralForumTopic(long chatId) { @@ -21,8 +17,10 @@ public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java index a910879..172fd38 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessage.java @@ -1,31 +1,29 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.MessageEntity; -import hdvtdev.telegram.objects.Poll; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; -import hdvtdev.telegram.util.ParseMode; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.methods.util.ParseMode; +import hdvtdev.telegram.core.objects.message.MessageEntity; +import hdvtdev.telegram.core.objects.poll.Poll; +import hdvtdev.telegram.core.objects.markup.ReplyMarkup; +import hdvtdev.telegram.core.objects.ReplyParameters; -import okhttp3.RequestBody; import java.util.List; /** - * Use this method to copy messages of any kind. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. + * Use this method to copy message of any kind. + * Service message, paid media message, giveaway message, giveaway winners message, and invoice message can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the command. * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. * Returns the messageId as {@link Long} of the sent message on success. * @see Poll#correctOptionId() * @since 1.0.0 */ -@NotTested +//TODO NotTested @Jsonable @JsonInclude(JsonInclude.Include.NON_NULL) public final class CopyMessage implements TelegramApiMethod { @@ -140,7 +138,7 @@ public final class CopyMessage implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java index b5bc081..36d3e1a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CopyMessages.java @@ -1,25 +1,23 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Poll; - -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.poll.Poll; import java.util.ArrayList; import java.util.List; /** - * Use this method to copy messages of any kind. - * If some of the specified messages can't be found or copied, they are skipped. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. - * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. - * Album grouping is kept for copied messages. - * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. + * Use this method to copy message of any kind. + * If some of the specified message can't be found or copied, they are skipped. + * Service message, paid media message, giveaway message, giveaway winners message, and invoice message can't be copied. + * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the command. + * The method is analogous to the method {@link ForwardMessages}, but the copied message don't have a link to the original message. + * Album grouping is kept for copied message. + * On success, an array of MessageId as {@link Long}{@code []} of the sent message is returned. * @see Poll#correctOptionId() * @since 1.0.0 */ @@ -44,8 +42,8 @@ public final class CopyMessages implements TelegramApiMethod { /** * @param chatId Username of the target channel (in the format @channelusername) - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + * @param fromChatId Channel username in the format @channelusername for the chat where the original message were sent + * @param messageIds List of 1-100 identifiers of message in the chat to copy. */ public CopyMessages(String chatId, String fromChatId, List messageIds) { this.chatId = chatId; @@ -57,8 +55,8 @@ public final class CopyMessages implements TelegramApiMethod { /** * @param chatId Unique identifier for the target chat - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + * @param fromChatId Channel username in the format @channelusername for the chat where the original message were sent + * @param messageIds List of 1-100 identifiers of message in the chat to copy. */ public CopyMessages(long chatId, String fromChatId, List messageIds) { this(String.valueOf(chatId), fromChatId, messageIds); @@ -66,17 +64,17 @@ public final class CopyMessages implements TelegramApiMethod { /** * @param chatId Unique identifier for the target chat - * @param fromChatId Unique identifier for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + * @param fromChatId Unique identifier for the chat where the original message were sent + * @param messageIds List of 1-100 identifiers of message in the chat to copy. */ public CopyMessages(long chatId, long fromChatId, List messageIds) { this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); } /** - * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent + * @param chatId Channel username in the format @channelusername for the chat where the original message were sent * @param fromChatId Unique identifier for the target chat - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. + * @param messageIds List of 1-100 identifiers of message in the chat to copy. */ public CopyMessages(String chatId, long fromChatId, List messageIds) { this(chatId, String.valueOf(fromChatId), messageIds); @@ -110,7 +108,7 @@ public final class CopyMessages implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java index 45bcd68..83b2cc6 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/CreateChatInviteLink.java @@ -1,14 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.ChatInviteLink; - -import okhttp3.FormBody; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.objects.chat.ChatAdministratorRights; +import hdvtdev.telegram.core.objects.chat.ChatInviteLink; /** * Use this method to create an additional invite link for a chat. - * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. + * The command must be an administrator in the chat for this to work and must have the appropriate administrator rights. * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. * @see ChatAdministratorRights#canInviteUsers() */ @@ -54,12 +51,14 @@ public final class CreateChatInviteLink implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java index 7ff9110..d369ca1 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/ForwardMessages.java @@ -1,26 +1,23 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; - import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Message; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.message.Message; import java.util.ArrayList; import java.util.List; /** - * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. - * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. - * On success, an array of MessageId as {@link Long} of the sent messages is returned. + * Use this method to forward multiple message of any kind. If some of the specified message can't be found or forwarded, they are skipped. + * Service message and message with protected content can't be forwarded. Album grouping is kept for forwarded message. + * On success, an array of MessageId as {@link Long} of the sent message is returned. * @see Message#hasProtectedContent() */ +// TODO NotTested @Jsonable -@NotTested @JsonInclude(JsonInclude.Include.NON_NULL) public final class ForwardMessages implements TelegramApiMethod { @@ -80,7 +77,7 @@ public final class ForwardMessages implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java index 8a0ad7a..02d8d9f 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatAdministrators.java @@ -1,27 +1,23 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatMember; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; +import hdvtdev.telegram.core.objects.chat.ChatMember; /** * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. * @param chatId */ -@NotTested -public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { +//TODO NotTested +public record GetChatAdministrators(String chatId) implements TelegramApiMethod { public GetChatAdministrators(long chatId) { this(String.valueOf(chatId)); } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java index 1c0065c..9aa7a68 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetChatMember.java @@ -1,13 +1,8 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.objects.ChatMember; +import hdvtdev.telegram.core.objects.chat.ChatMember; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { +public record GetChatMember(String chatId, long userId) implements TelegramApiMethod { public GetChatMember(long chatId, long userId) { this(String.valueOf(chatId), userId); @@ -22,8 +17,11 @@ public record GetChatMember(@NotNull String chatId, long userId) implements Tele } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + body.add("user_id", String.valueOf(userId)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java index 96bfbd5..5f41461 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetFile.java @@ -1,14 +1,14 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.objects.TelegramFile; -import okhttp3.FormBody; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.objects.media.TelegramFile; public record GetFile(String fileId) implements TelegramApiMethod { @Override - public RequestBody getBody() { - return new FormBody.Builder().add("file_id", fileId).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("file_id", fileId); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java index cfe2819..5e1b160 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMe.java @@ -1,12 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; -import hdvtdev.telegram.objects.User; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.objects.User; public final class GetMe implements TelegramApiMethod { @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java index aebee4d..1c04bd2 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyCommands.java @@ -1,18 +1,16 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; - -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.command.BotCommand; +import hdvtdev.telegram.core.objects.command.BotCommandScope; +import hdvtdev.telegram.core.objects.command.BotCommandScopeDefault; /** - * Use this method to get the current list of the bot's commands for the given scope and user language. + * Use this method to get the current list of the command's commands for the given scope and user language. * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. * @param languageCode A two-letter ISO 639-1 language code or an empty string @@ -40,7 +38,7 @@ public record GetMyCommands( @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java index a351910..706ecc1 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyDescription.java @@ -1,9 +1,4 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; +package hdvtdev.telegram.core.methods; public record GetMyDescription(String languageCode) implements TelegramApiMethod { @@ -12,8 +7,14 @@ public record GetMyDescription(String languageCode) implements TelegramApiMethod } @Override - public RequestBody getBody() { - return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); + public TelegramApiMethodBody getBody() { + if (languageCode == null) { + return null; + } else { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("language_code", languageCode); + return body; + } } @Override @@ -27,7 +28,7 @@ public record GetMyDescription(String languageCode) implements TelegramApiMethod } public record BotDescription(String description) { - @NotNull + @Override public String toString() { return description; diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java index af83b33..cf16657 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/GetMyName.java @@ -1,8 +1,4 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; -import org.jetbrains.annotations.NotNull; +package hdvtdev.telegram.core.methods; public record GetMyName(String languageCode) implements TelegramApiMethod { @@ -11,8 +7,14 @@ public record GetMyName(String languageCode) implements TelegramApiMethod { +public record RevokeChatInviteLink(String chatId, String link) implements TelegramApiMethod { - public RevokeChatInviteLink(long chatId, @NotNull String link) { + public RevokeChatInviteLink(long chatId, String link) { this(String.valueOf(chatId), link); } @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(2); + body.add("chat_id", chatId); + body.add("link", link); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java index 9f59abd..09201d0 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendChatAction.java @@ -1,10 +1,4 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +package hdvtdev.telegram.core.methods; public final class SendChatAction implements TelegramApiMethod { @@ -13,7 +7,7 @@ public final class SendChatAction implements TelegramApiMethod { private Long messageThreadId; private final ChatAction chatAction; - public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { + public SendChatAction(String businessConnectionId, String chatId, Long messageThreadId, ChatAction chatAction) { this.businessConnectionId = businessConnectionId; this.chatId = chatId; this.messageThreadId = messageThreadId; @@ -41,14 +35,13 @@ public final class SendChatAction implements TelegramApiMethod { } @Override - public RequestBody getBody() { - - FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); - - if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); - if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); - - return builder.build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(); + body.add("chat_id", chatId); + body.add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); + body.add("business_connection_id", businessConnectionId); + body.add("message_thread_id", String.valueOf(messageThreadId)); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java index 3bb16dc..a275518 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendDice.java @@ -1,15 +1,13 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; - -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.message.Message; +import hdvtdev.telegram.core.objects.markup.ReplyMarkup; +import hdvtdev.telegram.core.objects.ReplyParameters; @Jsonable @JsonInclude(JsonInclude.Include.NON_NULL) @@ -92,7 +90,7 @@ public final class SendDice implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java b/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java index 6187da7..ac8ddf0 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SendMessage.java @@ -1,14 +1,17 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.*; -import hdvtdev.telegram.util.ParseMode; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.methods.util.ParseMode; +import hdvtdev.telegram.core.objects.*; +import hdvtdev.telegram.core.objects.markup.ReplyMarkup; +import hdvtdev.telegram.core.objects.message.LinkPreviewOptions; +import hdvtdev.telegram.core.objects.message.Message; +import hdvtdev.telegram.core.objects.message.MessageEntity; -import okhttp3.RequestBody; @Jsonable @JsonInclude(JsonInclude.Include.NON_NULL) @@ -118,7 +121,7 @@ public final class SendMessage implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java index 3aecda3..1d15539 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMessageReaction.java @@ -1,13 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.ReactionType; - -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.reaction.ReactionType; import java.util.List; @@ -51,7 +49,7 @@ public class SetMessageReaction implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java index 8dac79a..c073a7c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyCommands.java @@ -1,13 +1,12 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.methods; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import okhttp3.RequestBody; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.objects.command.BotCommand; +import hdvtdev.telegram.core.objects.command.BotCommandScope; import java.util.List; @@ -53,7 +52,7 @@ public final class SetMyCommands implements TelegramApiMethod { @JsonIgnore @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { return null; } diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java index 2dc5c26..6ccfca8 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyDescription.java @@ -1,12 +1,9 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; +package hdvtdev.telegram.core.methods; /** - * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. + * Use this method to change the command's description, which is shown in the chat with the command if the chat is empty. * Returns {@code true} on success. - * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param description New command description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. */ public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { @@ -20,13 +17,15 @@ public record SetMyDescription(String description, String languageCode) implemen } @Override - public RequestBody getBody() { + public TelegramApiMethodBody getBody() { if (description == null) { return null; + } else { + TelegramApiMethodBody body = new TelegramApiMethodBody(2); + body.add("language_code", languageCode); + body.add("description", description); + return body; } - FormBody.Builder builder = new FormBody.Builder().add("description", description); - if (languageCode != null) builder.add("language_code", languageCode); - return builder.build(); } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java index fb7eff3..774e52e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/SetMyName.java @@ -1,7 +1,4 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; +package hdvtdev.telegram.core.methods; public record SetMyName(String name, String languageCode) implements TelegramApiMethod { @@ -10,10 +7,11 @@ public record SetMyName(String name, String languageCode) implements TelegramApi } @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("name", this.name); - if (languageCode != null) builder.add("language_code", this.languageCode); - return builder.build(); + public TelegramApiMethodBody getBody() { + TelegramApiMethodBody body = new TelegramApiMethodBody(2); + body.add("name", this.name); + body.add("language_code", this.languageCode); + return body; } @Override diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java index 1035ba3..8f4e8f4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethod.java @@ -1,10 +1,8 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.RequestBody; +package hdvtdev.telegram.core.methods; public interface TelegramApiMethod { - RequestBody getBody(); + TelegramApiMethodBody getBody(); String getMethodName(); diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java index 3f65f96..4b8da57 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.bot; +package hdvtdev.telegram.core.methods; import java.util.ArrayList; import java.util.function.Consumer; diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java b/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java index 5ceaa73..4191da3 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/util/ParseMode.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core; +package hdvtdev.telegram.core.methods.util; public enum ParseMode { MARKDOWN, diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java b/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java index d955f77..7d9a7cd 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/util/Util.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core; +package hdvtdev.telegram.core.methods.util; import java.io.BufferedWriter; import java.io.FileWriter; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java deleted file mode 100644 index 13b9a17..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/AnswerCallbackQuery.java +++ /dev/null @@ -1,113 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Game; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to send answers to callback queries sent from inline keyboards. - * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. - * Alternatively, the user can be redirected to the specified {@link Game} URL. - * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. - * @apiNote On success, {@code Boolean == true} is returned. - * @since 1.0.0 - */ - -@NotTested -public class AnswerCallbackQuery implements TelegramApiMethod { - - /** - * Unique identifier for the query to be answered - */ - private final String callbackQueryId; - /** - * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters - */ - private String text; - /** - * If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. - */ - private Boolean showAlert; - /** - * URL that will be opened by the user's client. - * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. - * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. - * @apiNote this will only work if the query comes from a callback_game button. - */ - private String url; - /** - * The maximum amount of time in seconds that the result of the callback query may be cached client-side. - * Telegram apps will support caching starting in version 3.14. Defaults to 0. - */ - private Integer cacheTime; - - public AnswerCallbackQuery(String callbackQueryId) { - this.callbackQueryId = callbackQueryId; - } - - private AnswerCallbackQuery(Builder builder) { - callbackQueryId = builder.callbackQueryId; - text = builder.text; - showAlert = builder.showAlert; - url = builder.url; - cacheTime = builder.cacheTime; - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); - if (text != null) builder.add("text", this.text); - if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); - if (url != null) builder.add("url", this.url); - if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "answerCallbackQuery"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String callbackQueryId; - private String text; - private Boolean showAlert; - private String url; - private Integer cacheTime; - - public Builder(String callbackQueryId) { - this.callbackQueryId = callbackQueryId; - } - - public Builder text(String text) { - this.text = text; - return this; - } - - public Builder showAlert(Boolean showAlert) { - this.showAlert = showAlert; - return this; - } - - public Builder url(String url) { - this.url = url; - return this; - } - - public Builder cacheTime(Integer cacheTime) { - this.cacheTime = cacheTime; - return this; - } - - public AnswerCallbackQuery build() { - return new AnswerCallbackQuery(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java deleted file mode 100644 index 7338266..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/ApproveChatJoinRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.Chat; -import hdvtdev.telegram.objects.User; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to approve a chat join request. - * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. - * Returns True on success. - * @param chatId Unique username of the target channel in the format @channelusername - * @param userId Unique identifier of the target user - * @see ChatAdministratorRights - * @see Chat - * @see Chat#id() - * @since 0.1.0 - */ -@NotTested -public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { - - /** - * @param chatId Unique identifier for the target chat - * @param userId Unique identifier of the target user - * @see User#id() - * @see Chat#id() - */ - public ApproveChatJoinRequest(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "approveChatJoinRequest"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java deleted file mode 100644 index 17622c3..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatMember.java +++ /dev/null @@ -1,110 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to ban a user in a group, a supergroup or a channel. - * In the case of supergroups and channels, the user will not be able to return - * to the chat on their own using invite links, etc., unless unbanned first. - * The bot must be an administrator in the chat for this to work and must have - * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. - * @see ChatAdministratorRights - * @since 0.1.1 - */ -@NotTested -public final class BanChatMember implements TelegramApiMethod { - - /** - * Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) - */ - private final String chatId; - /** - * Unique identifier of the target user - */ - private final long userId; - /** - * Date when the user will be unbanned; Unix time. - * If user is banned for more than 366 days or less than 30 seconds from - * the current time they are considered to be banned forever. - * Applied for supergroups and channels only. - */ - private Long untilDate; - /** - * Pass true to delete all messages from the chat for the user that is being removed. - * If false, the user will be able to see messages in the group that were sent before the user was removed. - * Always True for supergroups and channels. - */ - private Boolean revokeMessages; - - public BanChatMember(String chatId, long userId) { - this.chatId = chatId; - this.userId = userId; - } - - public BanChatMember(long chatId, long userId) { - this.chatId = String.valueOf(chatId); - this.userId = userId; - } - - private BanChatMember(Builder builder) { - chatId = builder.chatId; - userId = builder.userId; - setUntilDate(builder.untilDate); - setRevokeMessages(builder.revokeMessages); - } - - public void setUntilDate(Long untilDate) { - this.untilDate = untilDate; - } - - public void setRevokeMessages(Boolean revokeMessages) { - this.revokeMessages = revokeMessages; - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); - if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); - if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "banChatMember"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String chatId; - private final long userId; - private Long untilDate; - private Boolean revokeMessages; - - public Builder(String chatId, long userId) { - this.chatId = chatId; - this.userId = userId; - } - - public Builder untilDate(Long untilDate) { - this.untilDate = untilDate; - return this; - } - - public Builder revokeMessages(Boolean revokeMessages) { - this.revokeMessages = revokeMessages; - return this; - } - - public BanChatMember build() { - return new BanChatMember(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java deleted file mode 100644 index 323e677..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/BanChatSenderChat.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to ban a channel chat in a supergroup or a channel. - * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of - * their channels. The bot must be an administrator in the supergroup or channel for this to - * work and must have the appropriate administrator rights. Returns True on success. - * @since 1.0.0 - */ -@NotTested -public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { - - public BanChatSenderChat(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "banChatSenderChat"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java deleted file mode 100644 index debe5e5..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/CloseForumTopic.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to close an open topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, - * unless it is the creator of the topic. Returns {@code true} on success. - * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) - * @param messageThreadId Unique identifier for the target message thread of the forum topic - * @see ChatAdministratorRights#canManageTopics() - */ -@NotTested -public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { - - public CloseForumTopic(long chatId, long messageThreadId) { - this(String.valueOf(chatId), messageThreadId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); - } - - @Override - public String getMethodName() { - return "closeForumTopic"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java deleted file mode 100644 index 2d2ed8e..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/CloseGeneralForumTopic.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to close an open 'General' topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. - * Returns {@code true} on success. - * @see ChatAdministratorRights#canManageTopics() - * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) - */ -@NotTested -public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { - - public CloseGeneralForumTopic(long chatId) { - this(String.valueOf(chatId)); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); - } - - @Override - public String getMethodName() { - return "closeGeneralForumTopic"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java deleted file mode 100644 index a910879..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessage.java +++ /dev/null @@ -1,244 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.MessageEntity; -import hdvtdev.telegram.objects.Poll; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; -import hdvtdev.telegram.util.ParseMode; - -import okhttp3.RequestBody; - -import java.util.List; - -/** - * Use this method to copy messages of any kind. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. - * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. - * Returns the messageId as {@link Long} of the sent message on success. - * @see Poll#correctOptionId() - * @since 1.0.0 - */ -@NotTested -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class CopyMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("video_start_timestamp") - private long videoStartTimestamp; - @JsonProperty("caption") - private String caption; - @JsonProperty("parse_mode") - private ParseMode parseMode; - @JsonProperty("caption_entities") - private List captionEntities; - @JsonProperty("show_caption_above_media") - private Boolean showCaptionAboveMedia; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - public CopyMessage(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public CopyMessage(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public CopyMessage(long chatId, long fromChatId, long messageId) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); - } - - public CopyMessage(String chatId, long fromChatId, long messageId) { - this(chatId, String.valueOf(fromChatId), messageId); - } - - private CopyMessage(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageId = builder.messageId; - setVideoStartTimestamp(builder.videoStartTimestamp); - setCaption(builder.caption); - setParseMode(builder.parseMode); - setCaptionEntities(builder.captionEntities); - setShowCaptionAboveMedia(builder.showCaptionAboveMedia); - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setAllowPaidBroadcast(builder.allowPaidBroadcast); - setReplyParameters(builder.replyParameters); - setReplyMarkup(builder.replyMarkup); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setVideoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - } - - public void setCaption(String caption) { - this.caption = caption; - } - - public void setParseMode(ParseMode parseMode) { - this.parseMode = parseMode; - } - - public void setCaptionEntities(List captionEntities) { - this.captionEntities = captionEntities; - } - - public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) { - this.showCaptionAboveMedia = showCaptionAboveMedia; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "copyMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long.class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final long messageId; - private long videoStartTimestamp; - private String caption; - private ParseMode parseMode; - private List captionEntities; - private Boolean showCaptionAboveMedia; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean allowPaidBroadcast; - private ReplyParameters replyParameters; - private ReplyMarkup replyMarkup; - - public Builder(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public Builder(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder videoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - return this; - } - - public Builder caption(String caption) { - this.caption = caption; - return this; - } - - public Builder parseMode(ParseMode parseMode) { - this.parseMode = parseMode; - return this; - } - - public Builder captionEntities(List captionEntities) { - this.captionEntities = captionEntities; - return this; - } - - public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) { - this.showCaptionAboveMedia = showCaptionAboveMedia; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - return this; - } - - public Builder replyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - return this; - } - - public Builder replyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - return this; - } - - public CopyMessage build() { - return new CopyMessage(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java deleted file mode 100644 index b5bc081..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/CopyMessages.java +++ /dev/null @@ -1,181 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Poll; - -import okhttp3.RequestBody; - -import java.util.ArrayList; -import java.util.List; - -/** - * Use this method to copy messages of any kind. - * If some of the specified messages can't be found or copied, they are skipped. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. - * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. - * Album grouping is kept for copied messages. - * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. - * @see Poll#correctOptionId() - * @since 1.0.0 - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class CopyMessages implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final List messageIds; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("remove_caption") - private Boolean removeCaption; - - /** - * @param chatId Username of the target channel (in the format @channelusername) - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(String chatId, String fromChatId, List messageIds) { - this.chatId = chatId; - this.fromChatId = fromChatId; - ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); - sortedMessageIds.sort(null); - this.messageIds = sortedMessageIds; - } - - /** - * @param chatId Unique identifier for the target chat - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - /** - * @param chatId Unique identifier for the target chat - * @param fromChatId Unique identifier for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - /** - * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param fromChatId Unique identifier for the target chat - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - private CopyMessages(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageIds = builder.messageIds; - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setRemoveCaption(builder.removeCaption); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setRemoveCaption(Boolean removeCaption) { - this.removeCaption = removeCaption; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "copyMessages"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long[].class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final List messageIds; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean removeCaption; - - public Builder(String chatId, String fromChatId, List messageIds) { - this.chatId = chatId; - this.fromChatId = fromChatId; - ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); - sortedMessageIds.sort(null); - this.messageIds = sortedMessageIds; - } - public Builder(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public Builder(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - public Builder(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder removeCaption(Boolean removeCaption) { - this.removeCaption = removeCaption; - return this; - } - - public CopyMessages build() { - return new CopyMessages(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java deleted file mode 100644 index 45bcd68..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/CreateChatInviteLink.java +++ /dev/null @@ -1,114 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.ChatInviteLink; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to create an additional invite link for a chat. - * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. - * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. - * @see ChatAdministratorRights#canInviteUsers() - */ -public final class CreateChatInviteLink implements TelegramApiMethod { - - private final String chatId; - private String name; - private Long expireDate; - private Integer memberLimit; - private Boolean createsJoinRequest; - - public CreateChatInviteLink(String chatId) { - this.chatId = chatId; - } - - public CreateChatInviteLink(long chatId) { - this(String.valueOf(chatId)); - } - - private CreateChatInviteLink(Builder builder) { - chatId = builder.chatId; - setName(builder.name); - setExpireDate(builder.expireDate); - setMemberLimit(builder.memberLimit); - setCreatesJoinRequest(builder.createsJoinRequest); - } - - public void setName(String name) { - this.name = name; - } - - public void setExpireDate(Long expireDate) { - this.expireDate = expireDate; - } - - public void setMemberLimit(Integer memberLimit) { - this.memberLimit = memberLimit; - } - - public void setCreatesJoinRequest(Boolean createsJoinRequest) { - this.createsJoinRequest = createsJoinRequest; - } - - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId); - if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate)); - if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit)); - if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "createChatInviteLink"; - } - - @Override - public Class getResponseClass() { - return ChatInviteLink.class; - } - - public static final class Builder { - private final String chatId; - private String name; - private Long expireDate; - private Integer memberLimit; - private Boolean createsJoinRequest; - - public Builder(String chatId) { - this.chatId = chatId; - } - - public Builder(long chatId) { - this(String.valueOf(chatId)); - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder expireDate(Long expireDate) { - this.expireDate = expireDate; - return this; - } - - public Builder memberLimit(Integer memberLimit) { - this.memberLimit = memberLimit; - return this; - } - - public Builder createsJoinRequest(Boolean createsJoinRequest) { - this.createsJoinRequest = createsJoinRequest; - return this; - } - - public CreateChatInviteLink build() { - return new CreateChatInviteLink(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java deleted file mode 100644 index f6bb9d1..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessage.java +++ /dev/null @@ -1,133 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Message; - -import okhttp3.RequestBody; - -/** - * Use this method to forward messages of any kind. - * Service messages and messages with protected content can't be forwarded. - * On success, the sent {@link Message} is returned. - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class ForwardMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("video_start_timestamp") - private long videoStartTimestamp; - - public ForwardMessage(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public ForwardMessage(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public ForwardMessage(long chatId, long fromChatId, long messageId) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); - } - - private ForwardMessage(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageId = builder.messageId; - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setVideoStartTimestamp(builder.videoStartTimestamp); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setVideoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "forwardMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final long messageId; - private Boolean disableNotification; - private Boolean protectContent; - private long videoStartTimestamp; - - public Builder(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder videoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - return this; - } - - public ForwardMessage build() { - return new ForwardMessage(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java deleted file mode 100644 index 7ff9110..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/ForwardMessages.java +++ /dev/null @@ -1,147 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; - -import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Message; - -import okhttp3.RequestBody; - -import java.util.ArrayList; -import java.util.List; - -/** - * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. - * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. - * On success, an array of MessageId as {@link Long} of the sent messages is returned. - * @see Message#hasProtectedContent() - */ -@Jsonable -@NotTested -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class ForwardMessages implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final List messageIds; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - - public ForwardMessages(String chatId, String fromChatId, List messageIds) { - ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); - sortedMessageIds.sort(null); - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageIds = sortedMessageIds; - } - - public ForwardMessages(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public ForwardMessages(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public ForwardMessages(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - private ForwardMessages(Builder builder) { - chatId = builder.chatId; - messageThreadId = builder.messageThreadId; - fromChatId = builder.fromChatId; - messageIds = builder.messageIds; - disableNotification = builder.disableNotification; - protectContent = builder.protectContent; - } - - public void setMessageThreadId(long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(boolean protectContent) { - this.protectContent = protectContent; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "forwardMessages"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long[].class; - } - - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final List messageIds; - private Boolean disableNotification; - private Boolean protectContent; - - public Builder(String chatId, String fromChatId, List messageIds) { - ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); - sortedMessageIds.sort(null); - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageIds = sortedMessageIds; - } - - public Builder(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public Builder(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public Builder(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - public Builder messageThreadId(long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public ForwardMessages build() { - return new ForwardMessages(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Game.java b/core/src/main/java/hdvtdev/telegram/core/objects/Game.java index 6019a26..1580981 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/Game.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Game.java @@ -3,6 +3,9 @@ package hdvtdev.telegram.core.objects; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.Animation; +import hdvtdev.telegram.core.objects.media.PhotoSize; +import hdvtdev.telegram.core.objects.message.MessageEntity; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java deleted file mode 100644 index 8a0ad7a..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatAdministrators.java +++ /dev/null @@ -1,36 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatMember; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. - * @param chatId - */ -@NotTested -public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { - - public GetChatAdministrators(long chatId) { - this(String.valueOf(chatId)); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); - } - - @Override - public String getMethodName() { - return "getChatAdministrators"; - } - - @Override - public Class getResponseClass() { - return ChatMember[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java deleted file mode 100644 index 1c0065c..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetChatMember.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.objects.ChatMember; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { - - public GetChatMember(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - public GetChatMember(String chatId, String userId) { - this(chatId, Long.parseLong(userId)); - } - - public GetChatMember(long chatId, String userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "getChatMember"; - } - - @Override - public Class getResponseClass() { - return ChatMember.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java deleted file mode 100644 index 96bfbd5..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetFile.java +++ /dev/null @@ -1,23 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.objects.TelegramFile; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -public record GetFile(String fileId) implements TelegramApiMethod { - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("file_id", fileId).build(); - } - - @Override - public String getMethodName() { - return "getFile"; - } - - @Override - public Class getResponseClass() { - return TelegramFile.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java deleted file mode 100644 index cfe2819..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetMe.java +++ /dev/null @@ -1,22 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.objects.User; -import okhttp3.RequestBody; - -public final class GetMe implements TelegramApiMethod { - - @Override - public RequestBody getBody() { - return null; - } - - @Override - public String getMethodName() { - return "getMe"; - } - - @Override - public Class getResponseClass() { - return User.Bot.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java deleted file mode 100644 index aebee4d..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyCommands.java +++ /dev/null @@ -1,58 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; - -import okhttp3.RequestBody; - -/** - * Use this method to get the current list of the bot's commands for the given scope and user language. - * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. - * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. - * @param languageCode A two-letter ISO 639-1 language code or an empty string - * @see BotCommandScope - * @since 1.0.0 - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public record GetMyCommands( - @JsonProperty("scope") BotCommandScope scope, - @JsonProperty("language_code") String languageCode -) implements TelegramApiMethod { - - public GetMyCommands() { - this(null, null); - } - - public GetMyCommands(String languageCode) { - this(null, languageCode); - } - - public GetMyCommands(BotCommandScope scope) { - this(scope, null); - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "getMyCommands"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return BotCommand[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java deleted file mode 100644 index a351910..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyDescription.java +++ /dev/null @@ -1,42 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -public record GetMyDescription(String languageCode) implements TelegramApiMethod { - - public GetMyDescription() { - this(null); - } - - @Override - public RequestBody getBody() { - return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); - } - - @Override - public String getMethodName() { - return "getMyDescription"; - } - - @Override - public Class getResponseClass() { - return BotDescription.class; - } - - public record BotDescription(String description) { - @NotNull - @Override - public String toString() { - return description; - } - - public boolean isEmpty() { - return description.isEmpty(); - } - - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java deleted file mode 100644 index af83b33..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetMyName.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; -import org.jetbrains.annotations.NotNull; - -public record GetMyName(String languageCode) implements TelegramApiMethod { - - public GetMyName() { - this(null); - } - - @Override - public RequestBody getBody() { - return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build(); - } - - @Override - public String getMethodName() { - return "getMyName"; - } - - @Override - public Class getResponseClass() { - return BotName.class; - } - - public record BotName(String name) { - - @NotNull - @Override - public String toString() { - return this.name; - } - - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java b/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java deleted file mode 100644 index 2f12900..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/GetUpdates.java +++ /dev/null @@ -1,42 +0,0 @@ -package hdvtdev.telegram.core.objects; - - -import hdvtdev.telegram.objects.Update; -import okhttp3.RequestBody; - -import java.util.ArrayList; - -public record GetUpdates( - Long offset, - Integer limit, - Integer timeout -) implements TelegramApiMethod { - - public GetUpdates() { - this(null, null, null); - } - - @Override - public RequestBody getBody() { - return null; - } - - @Override - public String getMethodName() { - ArrayList params = new ArrayList<>(3); - if (offset != null) params.add("offset=" + offset); - if (limit != null) params.add("limit=" + limit); - if (timeout != null) params.add("timeout=" + timeout); - - if (params.isEmpty()) { - return "getUpdates"; - } else { - return "getUpdates?" + String.join("&", params); - } - } - - @Override - public Class getResponseClass() { - return Update[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java b/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java index c14a787..5ba86e1 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/ReplyParameters.java @@ -3,6 +3,7 @@ package hdvtdev.telegram.core.objects; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.message.MessageEntity; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java deleted file mode 100644 index f3324f2..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/RevokeChatInviteLink.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import hdvtdev.telegram.objects.ChatInviteLink; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. - * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. - * Returns the revoked invite link as {@link ChatInviteLink} object. - * @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername) - * @param link The invite link to revoke - */ -public record RevokeChatInviteLink(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod { - - public RevokeChatInviteLink(long chatId, @NotNull String link) { - this(String.valueOf(chatId), link); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); - } - - @Override - public String getMethodName() { - return "revokeChatInviteLink"; - } - - @Override - public Class getResponseClass() { - return ChatInviteLink.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java deleted file mode 100644 index 9f59abd..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SendChatAction.java +++ /dev/null @@ -1,104 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class SendChatAction implements TelegramApiMethod { - - private String businessConnectionId; - private final String chatId; - private Long messageThreadId; - private final ChatAction chatAction; - - public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { - this.businessConnectionId = businessConnectionId; - this.chatId = chatId; - this.messageThreadId = messageThreadId; - this.chatAction = chatAction; - } - - public SendChatAction(String chatId, ChatAction chatAction) { - this(null, chatId, null, chatAction); - } - - public SendChatAction(long chatId, ChatAction chatAction) { - this(String.valueOf(chatId), chatAction); - } - - private SendChatAction(Builder builder) { - this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction); - } - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - @Override - public RequestBody getBody() { - - FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); - - if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); - if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); - - return builder.build(); - } - - @Override - public String getMethodName() { - return "sendChatAction"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public enum ChatAction { - TYPING, - UPLOAD_PHOTO, - RECORD_VIDEO, - UPLOAD_VIDEO, - RECORD_VOICE, - UPLOAD_VOICE, - UPLOAD_DOCUMENT, - UPLOAD_FILE, - CHOOSE_STICKER, - FIND_LOCATION, - RECORD_VIDEO_NOTE, - UPLOAD_VIDEO_NOTE - } - - public static final class Builder { - private String businessConnectionId; - private final String chatId; - private Long messageThreadId; - private final ChatAction chatAction; - - public Builder(String chatId, ChatAction chatAction) { - this.chatId = chatId; - this.chatAction = chatAction; - } - - public Builder businessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - return this; - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public SendChatAction build() { - return new SendChatAction(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java deleted file mode 100644 index 3bb16dc..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SendDice.java +++ /dev/null @@ -1,133 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; - -import okhttp3.RequestBody; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SendDice implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("business_connection_id") - private String businessConnectionId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("emoji") - private String emoji; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("message_effect_id") - private String messageEffectId; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - public SendDice(String chatId) { - this.chatId = chatId; - } - - public SendDice(long chatId) { - this(String.valueOf(chatId)); - } - - public SendDice(String chatId, Emoji emoji) { - this.emoji = emoji.getEmoji(); - this.chatId = chatId; - } - - public SendDice(long chatId, Emoji emoji) { - this(String.valueOf(chatId), emoji); - } - - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setEmoji(Emoji emoji) { - this.emoji = emoji.getEmoji(); - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setMessageEffectId(String messageEffectId) { - this.messageEffectId = messageEffectId; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "sendDice"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public enum Emoji { - DICE("🎲"), - DART("🎯"), - BASKETBALL("🏀"), - FOOTBALL("⚽"), - BOWLING("🎳"), - SLOT_MACHINE("🎰"); - - private final String emoji; - - Emoji(String emoji) { - this.emoji = emoji; - } - - public String getEmoji() { - return emoji; - } - - } - - - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java deleted file mode 100644 index 6187da7..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SendMessage.java +++ /dev/null @@ -1,226 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.*; -import hdvtdev.telegram.util.ParseMode; - -import okhttp3.RequestBody; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SendMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("text") - private final String text; - @JsonProperty("business_connection_id") - private String businessConnectionId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("parse_mode") - private ParseMode parseMode; - @JsonProperty("entities") - private MessageEntity[] entities; - @JsonProperty("link_preview_options") - private LinkPreviewOptions linkPreviewOptions; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("message_effect_id") - private String messageEffectId; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - private SendMessage(Builder builder) { - chatId = builder.chatId; - text = builder.text; - setBusinessConnectionId(builder.businessConnectionId); - setMessageThreadId(builder.messageThreadId); - setParseMode(builder.parseMode); - setEntities(builder.entities); - setLinkPreviewOptions(builder.linkPreviewOptions); - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setAllowPaidBroadcast(builder.allowPaidBroadcast); - setMessageEffectId(builder.messageEffectId); - setReplyParameters(builder.replyParameters); - setReplyMarkup(builder.replyMarkup); - } - - public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { - this.linkPreviewOptions = linkPreviewOptions; - } - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setParseMode(ParseMode parseMode) { - this.parseMode = parseMode; - } - - public void setEntities(MessageEntity[] entities) { - this.entities = entities; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setMessageEffectId(String messageEffectId) { - this.messageEffectId = messageEffectId; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyToMessage(long messageId) { - this.replyParameters = new ReplyParameters(messageId, chatId); - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - public SendMessage(String chatId, String text) { - if (chatId.isEmpty() || text.isEmpty()) - throw new IllegalArgumentException("chatId or/and message (text) cannot be empty."); - this.chatId = chatId; - this.text = text; - } - - public SendMessage(long chatIdAsLong, String text) { - this(String.valueOf(chatIdAsLong), text); - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "sendMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public static final class Builder { - private final String chatId; - private final String text; - private String businessConnectionId; - private Long messageThreadId; - private ParseMode parseMode; - private MessageEntity[] entities; - private LinkPreviewOptions linkPreviewOptions; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean allowPaidBroadcast; - private String messageEffectId; - private ReplyParameters replyParameters; - private ReplyMarkup replyMarkup; - - public Builder(long chatId, String text) { - this(String.valueOf(chatId), text); - } - - public Builder(String chatId, String text) { - this.chatId = chatId; - this.text = text; - } - - public Builder businessConnectionId(String val) { - businessConnectionId = val; - return this; - } - - public Builder messageThreadId(Long val) { - messageThreadId = val; - return this; - } - - public Builder parseMode(ParseMode val) { - parseMode = val; - return this; - } - - public Builder entities(MessageEntity[] val) { - entities = val; - return this; - } - - public Builder linkPreviewOptions(LinkPreviewOptions val) { - linkPreviewOptions = val; - return this; - } - - public Builder disableNotification() { - disableNotification = true; - return this; - } - - public Builder protectContent() { - protectContent = true; - return this; - } - - public Builder allowPaidBroadcast() { - allowPaidBroadcast = true; - return this; - } - - public Builder messageEffectId(String val) { - messageEffectId = val; - return this; - } - - public Builder replyParameters(ReplyParameters val) { - replyParameters = val; - return this; - } - - public Builder replyToMessage(long val) { - replyParameters = new ReplyParameters(val, this.chatId); - return this; - } - - public Builder replyMarkup(ReplyMarkup val) { - replyMarkup = val; - return this; - } - - public SendMessage build() { - return new SendMessage(this); - } - } -} - diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java deleted file mode 100644 index 3aecda3..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SetMessageReaction.java +++ /dev/null @@ -1,100 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.ReactionType; - -import okhttp3.RequestBody; - -import java.util.List; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SetMessageReaction implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("reaction") - private List reactions; - @JsonProperty("is_big") - private Boolean isBig; - - public SetMessageReaction(String chatId, long messageId) { - this.chatId = chatId; - this.messageId = messageId; - } - - public SetMessageReaction(long chatId, long messageId) { - this.chatId = String.valueOf(chatId); - this.messageId = messageId; - } - - private SetMessageReaction(Builder builder) { - chatId = builder.chatId; - messageId = builder.messageId; - setReactions(builder.reactions); - isBig = builder.isBig; - } - - public void setReactions(List reactions) { - this.reactions = reactions; - } - - public void setBig(Boolean big) { - isBig = big; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "setMessageReaction"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String chatId; - private final long messageId; - private List reactions; - private Boolean isBig; - - public Builder(String chatId, long messageId) { - this.chatId = chatId; - this.messageId = messageId; - } - - public Builder(long chatId, long messageId) { - this.chatId = String.valueOf(chatId); - this.messageId = messageId; - } - - public Builder reactions(List reactions) { - this.reactions = reactions; - return this; - } - - public Builder isBig(Boolean isBig) { - this.isBig = isBig; - return this; - } - - public SetMessageReaction build() { - return new SetMessageReaction(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java deleted file mode 100644 index 8dac79a..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyCommands.java +++ /dev/null @@ -1,100 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import okhttp3.RequestBody; - -import java.util.List; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SetMyCommands implements TelegramApiMethod { - - @JsonProperty("commands") - private final List commands; - @JsonProperty("scope") - private Object scope; - @JsonProperty("language_code") - private String languageCode; - - public SetMyCommands(List commands, Object scope, String languageCode) { - this.commands = commands; - this.scope = scope; - this.languageCode = languageCode; - } - - public SetMyCommands(BotCommand... commands) { - this.commands = List.of(commands); - } - - public SetMyCommands(List commands) { - this.commands = commands; - } - - private SetMyCommands(Builder builder) { - commands = builder.commands; - setScope(builder.scope); - setLanguageCode(builder.languageCode); - } - - public void setScope(Object scope) { - this.scope = scope; - } - - public void setLanguageCode(String languageCode) { - this.languageCode = languageCode; - } - - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "setMyCommands"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Boolean.class; - } - - - public static final class Builder { - private final List commands; - private Object scope; - private String languageCode; - - public Builder(List commands) { - this.commands = commands; - } - - public Builder(BotCommand... commands) { - this.commands = List.of(commands); - } - - public Builder scope(BotCommandScope scope) { - this.scope = scope; - return this; - } - - public Builder languageCode(String languageCode) { - this.languageCode = languageCode; - return this; - } - - public SetMyCommands build() { - return new SetMyCommands(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java deleted file mode 100644 index 2dc5c26..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyDescription.java +++ /dev/null @@ -1,41 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. - * Returns {@code true} on success. - * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. - * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. - */ -public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { - - public SetMyDescription() { - this(null, null); - } - - public SetMyDescription(String description) { - this(description, null); - } - - @Override - public RequestBody getBody() { - if (description == null) { - return null; - } - FormBody.Builder builder = new FormBody.Builder().add("description", description); - if (languageCode != null) builder.add("language_code", languageCode); - return builder.build(); - } - - @Override - public String getMethodName() { - return "setMyDescription"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java b/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java deleted file mode 100644 index fb7eff3..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SetMyName.java +++ /dev/null @@ -1,28 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -public record SetMyName(String name, String languageCode) implements TelegramApiMethod { - - public SetMyName(String name) { - this(name, null); - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("name", this.name); - if (languageCode != null) builder.add("language_code", this.languageCode); - return builder.build(); - } - - @Override - public String getMethodName() { - return "setMyName"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java index 59f7864..424bc63 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/SharedUser.java @@ -3,6 +3,7 @@ package hdvtdev.telegram.core.objects; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.PhotoSize; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java deleted file mode 100644 index 1035ba3..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/TelegramApiMethod.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.core.objects; - -import okhttp3.RequestBody; - -public interface TelegramApiMethod { - - RequestBody getBody(); - - String getMethodName(); - - Class getResponseClass(); - -} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/Update.java b/core/src/main/java/hdvtdev/telegram/core/objects/Update.java index 450da73..442909d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/Update.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/Update.java @@ -3,6 +3,21 @@ package hdvtdev.telegram.core.objects; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.business.BusinessConnection; +import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted; +import hdvtdev.telegram.core.objects.callback.CallbackQuery; +import hdvtdev.telegram.core.objects.chat.ChatJoinRequest; +import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated; +import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased; +import hdvtdev.telegram.core.objects.message.Message; +import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated; +import hdvtdev.telegram.core.objects.message.MessageReactionUpdated; +import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery; +import hdvtdev.telegram.core.objects.payment.ShippingQuery; +import hdvtdev.telegram.core.objects.poll.Poll; +import hdvtdev.telegram.core.objects.poll.PollAnswer; import java.util.Optional; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java index dd020c9..0a8f660 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFill.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java index 5dd0c4f..1a3bc32 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillDeserializer.java @@ -1,4 +1,27 @@ package hdvtdev.telegram.core.objects.background; -public class BackgroundFillDeserializer { +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; + +import java.io.IOException; + +public final class BackgroundFillDeserializer extends JsonDeserializer { + + @Override + public BackgroundFill deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException { + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + String type = node.get("type").asText(); + + return switch (type) { + case "solid" -> codec.treeToValue(node, BackgroundFillSolid.class); + case "gradient" -> codec.treeToValue(node, BackgroundFillGradient.class); + case "freeform_gradient" -> codec.treeToValue(node, BackgroundFillFreeformGradient.class); + default -> throw new IllegalArgumentException("Unknown type: " + type); + }; + } } diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java index c6ada4e..d6912cb 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillFreeformGradient.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java index bf70298..49c6101 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillGradient.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java index 3ef193e..73accb8 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundFillSolid.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java index 3073a05..2abc41c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundType.java @@ -1,19 +1,8 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BackgroundTypeFill.class, name = "fill"), - @JsonSubTypes.Type(value = BackgroundTypeWallpaper.class, name = "wallpaper"), - @JsonSubTypes.Type(value = BackgroundTypePattern.class, name = "pattern"), - @JsonSubTypes.Type(value = BackgroundTypeChatTheme.class, name = "chat_theme") -}) +@JsonDeserialize(using = BackgroundTypeDeserializer.class) public interface BackgroundType { String type(); } diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java index f6b9110..9718787 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeChatTheme.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java index ed96f2b..f389211 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeDeserializer.java @@ -1,4 +1,28 @@ package hdvtdev.telegram.core.objects.background; -public class BackgroundTypeDeserializer { +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; + +import java.io.IOException; + +public final class BackgroundTypeDeserializer extends JsonDeserializer { + + @Override + public BackgroundType deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException { + ObjectCodec codec = parser.getCodec(); + JsonNode node = codec.readTree(parser); + + String type = node.get("type").asText(); + + return switch (type) { + case "fill" -> codec.treeToValue(node, BackgroundTypeFill.class); + case "wallpaper" -> codec.treeToValue(node, BackgroundTypeWallpaper.class); + case "pattern" -> codec.treeToValue(node, BackgroundTypePattern.class); + case "chat_theme" -> codec.treeToValue(node, BackgroundTypeChatTheme.class); + default -> throw new IllegalArgumentException("Unknown type: " + type); + }; + } } diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java index c327930..a14dd9f 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeFill.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java index 1d8cca6..c12749c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypePattern.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.Document; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java index 79d88ee..7a3aae4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/background/BackgroundTypeWallpaper.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.background; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.Document; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java index af94133..8a8420a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessConnection.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.business; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java index 3f544b9..f718169 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/business/BusinessMessagesDeleted.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.business; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java index 7cce5fd..a14d45c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackGame.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.callback; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java index 2856d32..efd8a83 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/callback/CallbackQuery.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.callback; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; import hdvtdev.telegram.core.objects.message.MaybeInaccessibleMessage; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java index 15e8385..6717445 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/Chat.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java index 4d5310c..e9a4bc9 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatAdministratorRights.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java index debb727..0caf75d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatBackground.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; + import hdvtdev.telegram.core.objects.background.BackgroundType; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java index 677f38b..9224bab 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatInviteLink.java @@ -1,10 +1,10 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.jetbrains.annotations.NotNull; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -21,7 +21,6 @@ public record ChatInviteLink( @JsonProperty("subscription_period") int subscriptionPeriod, @JsonProperty("subscription_price") int subscriptionPrice ) { - @NotNull @Override public String toString() { return this.inviteLink; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java index 8ff0772..b60d304 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatJoinRequest.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java index fe32e82..ec1fbde 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMember.java @@ -1,7 +1,8 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import hdvtdev.telegram.core.objects.User; @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java index e3b69d3..1ef4002 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberAdministrator.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java index 6c620b1..2915819 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberBanned.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java index c2c6173..4f643b5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberLeft.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java index d1c72b1..97b9cfc 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberMember.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java index 15a79c9..af38ed9 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberOwner.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java index cfc94d3..0240b47 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberRestricted.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java index ebd92be..8f82c4c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatMemberUpdated.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java index 5c0c9a0..18d87f5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chat/ChatShared.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chat; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.PhotoSize; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java index c7a0bfb..972adea 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoost.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java index 917b417..5ca4d8c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostAdded.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java index 8f8cd8a..1dd3f4c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostRemoved.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java index 3352393..85afb55 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSource.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java index 2c4addb..61e9ecd 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiftCode.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java index 69d90c6..18d6937 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourceGiveaway.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java index a97339a..76259d5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostSourcePremium.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java index fe965d6..97d3c53 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/chatboost/ChatBoostUpdated.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.chatboost; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java index a6b0845..3602670 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommand.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java index 8413da0..3fea65e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScope.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java index 99df70b..8876594 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllChatAdministrators.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java index 52febd0..b5b3af7 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllGroupChats.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java index 4bc5332..9d6c2fd 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeAllPrivateChats.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java index 0defde5..cac79ce 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChat.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java index 9820090..14e6440 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatAdministrators.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java index 7b2fbdc..ff84bd4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeChatMember.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java index 9e8f73d..d9e6cef 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/command/BotCommandScopeDefault.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects.bot; +package hdvtdev.telegram.core.objects.command; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java index c1363d9..236afe4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicClosed.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java index 251cff6..b027e8c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicCreated.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java index fb5d498..73caa6d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicEdited.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java index 9d025e1..da882ba 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/ForumTopicReopened.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java index 78bae5d..86191e9 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicHidden.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java index 1469725..a62fd79 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/forum/GeneralForumTopicUnhidden.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.forum; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java index 955e52c..141a640 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/Giveaway.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.giveaway; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java index 22bee08..054f039 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCompleted.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.giveaway; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java index 30312b9..81aedbd 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayCreated.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.giveaway; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java index c356fb4..589cf9d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/giveaway/GiveawayWinners.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.giveaway; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java index d770957..ff614ab 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/CopyTextButton.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java index 52edddc..158c627 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ForceReply.java @@ -1,9 +1,8 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.core.objects.markup.ReplyMarkup; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java index a4e7586..f48aa1d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardButton.java @@ -1,9 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.*; +import hdvtdev.telegram.core.objects.callback.CallbackGame; @JsonInclude(JsonInclude.Include.NON_NULL) public final class InlineKeyboardButton { diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java index 9eae0f4..ebe09a1 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardMarkup.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.*; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java index f951109..4ecb637 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/InlineKeyboardRow.java @@ -1,8 +1,7 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonValue; -import org.jetbrains.annotations.NotNull; import java.util.AbstractList; import java.util.ArrayList; @@ -37,7 +36,7 @@ public final class InlineKeyboardRow extends AbstractList @JsonIgnore @Override - public boolean addAll(@NotNull Collection buttons) { + public boolean addAll(Collection buttons) { return this.buttonsList.addAll(buttons); } diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java index f653db7..87c8790 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButton.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.WebAppInfo; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java index 74be5d4..ea1cca4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonPollType.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java index 90c805f..027a9a6 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestChat.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java index 022c06b..47dd7d7 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/KeyboardButtonRequestUsers.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java index af1be9e..31aed91 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardMarkup.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java index e320039..1a3aca4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyKeyboardRemove.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java index 9325e99..6c232a6 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/ReplyMarkup.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java index 65044dd..dadf0ab 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/markup/SwitchInlineQueryChosenChat.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.markup; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java index 693eaf1..3f0b1f6 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Animation.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java index 0d27c8c..95a383b 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Audio.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java index 230e080..b2dfe10 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Document.java @@ -1,9 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.methods.GetFile; + +import hdvtdev.telegram.core.methods.GetFile; + @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @@ -15,7 +17,7 @@ public record Document( @JsonProperty("mime_type") String mimeType, @JsonProperty("file_size") long fileSize ) { - public GetFile getFile() { + public GetFile toGetFile() { return new GetFile(this.fileId); } } diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java index 1337781..eb2520b 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/PhotoSize.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java index ae66739..720fd49 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Sticker.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.MaskPosition; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java index fd95027..f75e5e0 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Story.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java index 60426f1..4a1a657 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/TelegramFile.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java index 6fc5d3c..d6f6bbf 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/Voice.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java index 405cf76..3d3c271 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMedia.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java index 34a488a..5736add 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaInfo.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java index a952f23..d2d3e90 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPhoto.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.PhotoSize; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java index f4464e7..10f03aa 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPreview.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java index 841da3b..e7ed083 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaPurchased.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java index b32b07e..0ff3204 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/paidmedia/PaidMediaVideo.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.paidmedia; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.video.Video; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java index 4cddbd3..ca30757 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/Video.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects.media; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.PhotoSize; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java index 47c6741..6e5edea 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatEnded.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java index 4c43c69..7dcf330 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatParticipantsInvited.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java index dff9e28..ee9bab4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatScheduled.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java index 82bc832..526f53b 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoChatStarted.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java index d2f1c3f..f100e46 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/media/video/VideoNote.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects.media; +package hdvtdev.telegram.core.objects.media.video; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.media.PhotoSize; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java index 9cecc55..bec0acf 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/ExternalReplyInfo.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.*; import hdvtdev.telegram.core.objects.chat.Chat; import hdvtdev.telegram.core.objects.giveaway.Giveaway; import hdvtdev.telegram.core.objects.giveaway.GiveawayWinners; @@ -10,8 +11,6 @@ import hdvtdev.telegram.core.objects.media.*; import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaInfo; import hdvtdev.telegram.core.objects.media.video.Video; import hdvtdev.telegram.core.objects.media.video.VideoNote; -import hdvtdev.telegram.core.objects.message.LinkPreviewOptions; -import hdvtdev.telegram.core.objects.message.MessageOrigin; import hdvtdev.telegram.core.objects.payment.Invoice; import hdvtdev.telegram.core.objects.poll.Poll; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java index 5c106ae..de319d5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/InaccessibleMessage.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java index f1af977..fc30855 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/LinkPreviewOptions.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java index 701308c..33e8733 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java @@ -1,6 +1,7 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonDeserialize(using = MaybeInaccessibleMessageDeserializer.class) public interface MaybeInaccessibleMessage { diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java index 70c96e6..f02036c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java index 74fdf14..92e1e5a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java @@ -1,9 +1,27 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.*; +import hdvtdev.telegram.core.objects.chat.Chat; +import hdvtdev.telegram.core.objects.chat.ChatBackground; +import hdvtdev.telegram.core.objects.chat.ChatShared; import hdvtdev.telegram.core.objects.chatboost.ChatBoostAdded; +import hdvtdev.telegram.core.objects.forum.*; +import hdvtdev.telegram.core.objects.giveaway.Giveaway; +import hdvtdev.telegram.core.objects.giveaway.GiveawayCompleted; +import hdvtdev.telegram.core.objects.giveaway.GiveawayCreated; +import hdvtdev.telegram.core.objects.giveaway.GiveawayWinners; +import hdvtdev.telegram.core.objects.markup.InlineKeyboardMarkup; +import hdvtdev.telegram.core.objects.media.*; +import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaInfo; +import hdvtdev.telegram.core.objects.media.video.*; +import hdvtdev.telegram.core.objects.passport.PassportData; +import hdvtdev.telegram.core.objects.payment.Invoice; +import hdvtdev.telegram.core.objects.payment.RefundedPayment; +import hdvtdev.telegram.core.objects.payment.SuccessfulPayment; +import hdvtdev.telegram.core.objects.poll.Poll; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java index c0908eb..eb963a8 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageAutoDeleteTimerChanged.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java index abc075f..99d7024 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageEntity.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java index 9de39a2..daad092 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOrigin.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java index aeb5c4d..1ead486 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChannel.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java index 3873b5c..a28beeb 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginChat.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java index 1fa924e..b8acfa2 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginHiddenUser.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java index 3a19e38..896640e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageOriginUser.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java index f389b84..181068a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionCountUpdated.java @@ -1,8 +1,10 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; +import hdvtdev.telegram.core.objects.reaction.ReactionCount; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java index 7135efb..595c94e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MessageReactionUpdated.java @@ -1,8 +1,11 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.chat.Chat; +import hdvtdev.telegram.core.objects.reaction.ReactionType; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java index 0a1a389..3435ca0 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/TextQuote.java @@ -1,9 +1,8 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.core.objects.message.MessageEntity; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java index 520fdc0..4d7922a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedCredentials.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java index 38dcb8a..ffe82eb 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/EncryptedPassportElement.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java index f34b0bb..e6d140e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportData.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java index 9019afa..f03d6f8 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/passport/PassportFile.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.passport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java index df557d6..9de230a 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/Invoice.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java index af6dce5..05f103d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/OrderInfo.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java index d0037b5..b8749bd 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/PreCheckoutQuery.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java index 78ac21a..e95d068 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/RefundedPayment.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java index 07c8693..d7a8a96 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingAddress.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java index 1d4a95d..3a3d741 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/ShippingQuery.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java b/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java index 88840ad..f523da4 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/payment/SuccessfulPayment.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.payment; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java index b25fd4c..0b32f5b 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/Poll.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.poll; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java index 05bab19..2bebc16 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollAnswer.java @@ -1,8 +1,9 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.poll; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import hdvtdev.telegram.core.objects.User; import hdvtdev.telegram.core.objects.chat.Chat; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java index 2e09c91..582595e 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/poll/PollOption.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.poll; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java index 3d0ec3c..10d0a79 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionCount.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.reaction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java index 93a2a1d..0e486db 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionType.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.reaction; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java index 8c9a561..055e766 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeCustomEmoji.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.reaction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java index 8d483bf..13a6659 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypeEmoji.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.reaction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java index 645b4f5..9ed6149 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/reaction/ReactionTypePaid.java @@ -1,4 +1,4 @@ -package hdvtdev.telegram.core.objects; +package hdvtdev.telegram.core.objects.reaction; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java deleted file mode 100644 index 4808610..0000000 --- a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiException.java +++ /dev/null @@ -1,30 +0,0 @@ -package hdvtdev.telegram.exceptions; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class TelegramApiException extends IllegalArgumentException { - - public TelegramApiException(String message) { - super(message); - } - - public TelegramApiException() { - super(); - } - - public TelegramApiException(ErrorResponse errorResponse) { - super(errorResponse.description); - } - - public TelegramApiException(Throwable throwable) { - super(throwable); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public record ErrorResponse(boolean ok, @JsonProperty("error_code") int errorCode, String description) { - - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java deleted file mode 100644 index 8ee9c6a..0000000 --- a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramApiNetworkException.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.exceptions; - -import java.io.IOException; - -public class TelegramApiNetworkException extends RuntimeException { - public TelegramApiNetworkException(String message) { - super(message); - } - - public TelegramApiNetworkException(IOException e) { - super(e); - } - - public TelegramApiNetworkException(String s, IOException e) { - super(s, e); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java b/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java deleted file mode 100644 index cad5c01..0000000 --- a/core/src/main/java/hdvtdev/telegram/exceptions/TelegramMethodParsingException.java +++ /dev/null @@ -1,11 +0,0 @@ -package hdvtdev.telegram.exceptions; - -public class TelegramMethodParsingException extends RuntimeException { - public TelegramMethodParsingException(String message) { - super(message); - } - - public TelegramMethodParsingException(Throwable throwable) { - super(throwable); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java b/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java deleted file mode 100644 index 3c983b2..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/AnswerCallbackQuery.java +++ /dev/null @@ -1,113 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Game; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to send answers to callback queries sent from inline keyboards. - * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. - * Alternatively, the user can be redirected to the specified {@link Game} URL. - * For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. - * @apiNote On success, {@code Boolean == true} is returned. - * @since 1.0.0 - */ - -@NotTested -public class AnswerCallbackQuery implements TelegramApiMethod { - - /** - * Unique identifier for the query to be answered - */ - private final String callbackQueryId; - /** - * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters - */ - private String text; - /** - * If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. - */ - private Boolean showAlert; - /** - * URL that will be opened by the user's client. - * If you have created a {@link Game} and accepted the conditions via @BotFather, specify the URL that opens your game. - * Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. - * @apiNote this will only work if the query comes from a callback_game button. - */ - private String url; - /** - * The maximum amount of time in seconds that the result of the callback query may be cached client-side. - * Telegram apps will support caching starting in version 3.14. Defaults to 0. - */ - private Integer cacheTime; - - public AnswerCallbackQuery(String callbackQueryId) { - this.callbackQueryId = callbackQueryId; - } - - private AnswerCallbackQuery(Builder builder) { - callbackQueryId = builder.callbackQueryId; - text = builder.text; - showAlert = builder.showAlert; - url = builder.url; - cacheTime = builder.cacheTime; - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("callback_query_id", this.callbackQueryId); - if (text != null) builder.add("text", this.text); - if (showAlert != null) builder.add("show_alert", String.valueOf(this.showAlert)); - if (url != null) builder.add("url", this.url); - if (cacheTime != null) builder.add("cache_time", String.valueOf(this.cacheTime)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "answerCallbackQuery"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String callbackQueryId; - private String text; - private Boolean showAlert; - private String url; - private Integer cacheTime; - - public Builder(String callbackQueryId) { - this.callbackQueryId = callbackQueryId; - } - - public Builder text(String text) { - this.text = text; - return this; - } - - public Builder showAlert(Boolean showAlert) { - this.showAlert = showAlert; - return this; - } - - public Builder url(String url) { - this.url = url; - return this; - } - - public Builder cacheTime(Integer cacheTime) { - this.cacheTime = cacheTime; - return this; - } - - public AnswerCallbackQuery build() { - return new AnswerCallbackQuery(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java deleted file mode 100644 index 7438c51..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/ApproveChatJoinRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.Chat; -import hdvtdev.telegram.objects.User; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to approve a chat join request. - * The bot must be an administrator in the chat for this to work and must have the {@link ChatAdministratorRights#canInviteUsers()} administrator right. - * Returns True on success. - * @param chatId Unique username of the target channel in the format @channelusername - * @param userId Unique identifier of the target user - * @see ChatAdministratorRights - * @see Chat - * @see Chat#id() - * @since 0.1.0 - */ -@NotTested -public record ApproveChatJoinRequest(@NotNull String chatId, long userId) implements TelegramApiMethod { - - /** - * @param chatId Unique identifier for the target chat - * @param userId Unique identifier of the target user - * @see User#id() - * @see Chat#id() - */ - public ApproveChatJoinRequest(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "approveChatJoinRequest"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java b/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java deleted file mode 100644 index a0829fb..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/BanChatMember.java +++ /dev/null @@ -1,110 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to ban a user in a group, a supergroup or a channel. - * In the case of supergroups and channels, the user will not be able to return - * to the chat on their own using invite links, etc., unless unbanned first. - * The bot must be an administrator in the chat for this to work and must have - * the appropriate administrator rights: {@link ChatAdministratorRights#canRestrictMembers()}. Returns True on success. - * @see ChatAdministratorRights - * @since 0.1.1 - */ -@NotTested -public final class BanChatMember implements TelegramApiMethod { - - /** - * Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) - */ - private final String chatId; - /** - * Unique identifier of the target user - */ - private final long userId; - /** - * Date when the user will be unbanned; Unix time. - * If user is banned for more than 366 days or less than 30 seconds from - * the current time they are considered to be banned forever. - * Applied for supergroups and channels only. - */ - private Long untilDate; - /** - * Pass true to delete all messages from the chat for the user that is being removed. - * If false, the user will be able to see messages in the group that were sent before the user was removed. - * Always True for supergroups and channels. - */ - private Boolean revokeMessages; - - public BanChatMember(String chatId, long userId) { - this.chatId = chatId; - this.userId = userId; - } - - public BanChatMember(long chatId, long userId) { - this.chatId = String.valueOf(chatId); - this.userId = userId; - } - - private BanChatMember(Builder builder) { - chatId = builder.chatId; - userId = builder.userId; - setUntilDate(builder.untilDate); - setRevokeMessages(builder.revokeMessages); - } - - public void setUntilDate(Long untilDate) { - this.untilDate = untilDate; - } - - public void setRevokeMessages(Boolean revokeMessages) { - this.revokeMessages = revokeMessages; - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("chat_id", this.chatId).add("user_id", String.valueOf(userId)); - if (untilDate != null) builder.add("until_date", String.valueOf(untilDate)); - if (revokeMessages != null) builder.add("revoke_messages", String.valueOf(revokeMessages)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "banChatMember"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String chatId; - private final long userId; - private Long untilDate; - private Boolean revokeMessages; - - public Builder(String chatId, long userId) { - this.chatId = chatId; - this.userId = userId; - } - - public Builder untilDate(Long untilDate) { - this.untilDate = untilDate; - return this; - } - - public Builder revokeMessages(Boolean revokeMessages) { - this.revokeMessages = revokeMessages; - return this; - } - - public BanChatMember build() { - return new BanChatMember(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java b/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java deleted file mode 100644 index 5bb2d4b..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/BanChatSenderChat.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to ban a channel chat in a supergroup or a channel. - * Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of - * their channels. The bot must be an administrator in the supergroup or channel for this to - * work and must have the appropriate administrator rights. Returns True on success. - * @since 1.0.0 - */ -@NotTested -public record BanChatSenderChat(@NotNull String chatId, long userId) implements TelegramApiMethod { - - public BanChatSenderChat(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "banChatSenderChat"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java b/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java deleted file mode 100644 index 36d35b0..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/CloseForumTopic.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to close an open topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, - * unless it is the creator of the topic. Returns {@code true} on success. - * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) - * @param messageThreadId Unique identifier for the target message thread of the forum topic - * @see ChatAdministratorRights#canManageTopics() - */ -@NotTested -public record CloseForumTopic(String chatId, long messageThreadId) implements TelegramApiMethod { - - public CloseForumTopic(long chatId, long messageThreadId) { - this(String.valueOf(chatId), messageThreadId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("message_thread_id", String.valueOf(messageThreadId)).build(); - } - - @Override - public String getMethodName() { - return "closeForumTopic"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java b/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java deleted file mode 100644 index 17cff82..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/CloseGeneralForumTopic.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatAdministratorRights; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to close an open 'General' topic in a forum supergroup chat. - * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. - * Returns {@code true} on success. - * @see ChatAdministratorRights#canManageTopics() - * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) - */ -@NotTested -public record CloseGeneralForumTopic(String chatId) implements TelegramApiMethod { - - public CloseGeneralForumTopic(long chatId) { - this(String.valueOf(chatId)); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); - } - - @Override - public String getMethodName() { - return "closeGeneralForumTopic"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java b/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java deleted file mode 100644 index 46ece7d..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/CopyMessage.java +++ /dev/null @@ -1,244 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.MessageEntity; -import hdvtdev.telegram.objects.Poll; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; -import hdvtdev.telegram.util.ParseMode; - -import okhttp3.RequestBody; - -import java.util.List; - -/** - * Use this method to copy messages of any kind. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. - * The method is analogous to the method {@link ForwardMessage}, but the copied message doesn't have a link to the original message. - * Returns the messageId as {@link Long} of the sent message on success. - * @see Poll#correctOptionId() - * @since 1.0.0 - */ -@NotTested -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class CopyMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("video_start_timestamp") - private long videoStartTimestamp; - @JsonProperty("caption") - private String caption; - @JsonProperty("parse_mode") - private ParseMode parseMode; - @JsonProperty("caption_entities") - private List captionEntities; - @JsonProperty("show_caption_above_media") - private Boolean showCaptionAboveMedia; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - public CopyMessage(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public CopyMessage(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public CopyMessage(long chatId, long fromChatId, long messageId) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); - } - - public CopyMessage(String chatId, long fromChatId, long messageId) { - this(chatId, String.valueOf(fromChatId), messageId); - } - - private CopyMessage(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageId = builder.messageId; - setVideoStartTimestamp(builder.videoStartTimestamp); - setCaption(builder.caption); - setParseMode(builder.parseMode); - setCaptionEntities(builder.captionEntities); - setShowCaptionAboveMedia(builder.showCaptionAboveMedia); - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setAllowPaidBroadcast(builder.allowPaidBroadcast); - setReplyParameters(builder.replyParameters); - setReplyMarkup(builder.replyMarkup); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setVideoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - } - - public void setCaption(String caption) { - this.caption = caption; - } - - public void setParseMode(ParseMode parseMode) { - this.parseMode = parseMode; - } - - public void setCaptionEntities(List captionEntities) { - this.captionEntities = captionEntities; - } - - public void setShowCaptionAboveMedia(Boolean showCaptionAboveMedia) { - this.showCaptionAboveMedia = showCaptionAboveMedia; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "copyMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long.class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final long messageId; - private long videoStartTimestamp; - private String caption; - private ParseMode parseMode; - private List captionEntities; - private Boolean showCaptionAboveMedia; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean allowPaidBroadcast; - private ReplyParameters replyParameters; - private ReplyMarkup replyMarkup; - - public Builder(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public Builder(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder videoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - return this; - } - - public Builder caption(String caption) { - this.caption = caption; - return this; - } - - public Builder parseMode(ParseMode parseMode) { - this.parseMode = parseMode; - return this; - } - - public Builder captionEntities(List captionEntities) { - this.captionEntities = captionEntities; - return this; - } - - public Builder showCaptionAboveMedia(Boolean showCaptionAboveMedia) { - this.showCaptionAboveMedia = showCaptionAboveMedia; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder allowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - return this; - } - - public Builder replyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - return this; - } - - public Builder replyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - return this; - } - - public CopyMessage build() { - return new CopyMessage(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java b/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java deleted file mode 100644 index ceafa51..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/CopyMessages.java +++ /dev/null @@ -1,181 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Poll; - -import okhttp3.RequestBody; - -import java.util.ArrayList; -import java.util.List; - -/** - * Use this method to copy messages of any kind. - * If some of the specified messages can't be found or copied, they are skipped. - * Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. - * A quiz {@link Poll} can be copied only if the value of the field correct_option_id is known to the bot. - * The method is analogous to the method {@link ForwardMessages}, but the copied messages don't have a link to the original message. - * Album grouping is kept for copied messages. - * On success, an array of MessageId as {@link Long}{@code []} of the sent messages is returned. - * @see Poll#correctOptionId() - * @since 1.0.0 - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class CopyMessages implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final List messageIds; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("remove_caption") - private Boolean removeCaption; - - /** - * @param chatId Username of the target channel (in the format @channelusername) - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(String chatId, String fromChatId, List messageIds) { - this.chatId = chatId; - this.fromChatId = fromChatId; - ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); - sortedMessageIds.sort(null); - this.messageIds = sortedMessageIds; - } - - /** - * @param chatId Unique identifier for the target chat - * @param fromChatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - /** - * @param chatId Unique identifier for the target chat - * @param fromChatId Unique identifier for the chat where the original messages were sent - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - /** - * @param chatId Channel username in the format @channelusername for the chat where the original messages were sent - * @param fromChatId Unique identifier for the target chat - * @param messageIds List of 1-100 identifiers of messages in the chat to copy. - */ - public CopyMessages(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - private CopyMessages(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageIds = builder.messageIds; - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setRemoveCaption(builder.removeCaption); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setRemoveCaption(Boolean removeCaption) { - this.removeCaption = removeCaption; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "copyMessages"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long[].class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final List messageIds; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean removeCaption; - - public Builder(String chatId, String fromChatId, List messageIds) { - this.chatId = chatId; - this.fromChatId = fromChatId; - ArrayList sortedMessageIds = new ArrayList<>(messageIds.subList(0, Math.min(messageIds.size(), 100))); - sortedMessageIds.sort(null); - this.messageIds = sortedMessageIds; - } - public Builder(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public Builder(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - public Builder(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder removeCaption(Boolean removeCaption) { - this.removeCaption = removeCaption; - return this; - } - - public CopyMessages build() { - return new CopyMessages(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java deleted file mode 100644 index 8294d9a..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/CreateChatInviteLink.java +++ /dev/null @@ -1,114 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.objects.ChatAdministratorRights; -import hdvtdev.telegram.objects.ChatInviteLink; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to create an additional invite link for a chat. - * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. - * The link can be revoked using the method {@link RevokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. - * @see ChatAdministratorRights#canInviteUsers() - */ -public final class CreateChatInviteLink implements TelegramApiMethod { - - private final String chatId; - private String name; - private Long expireDate; - private Integer memberLimit; - private Boolean createsJoinRequest; - - public CreateChatInviteLink(String chatId) { - this.chatId = chatId; - } - - public CreateChatInviteLink(long chatId) { - this(String.valueOf(chatId)); - } - - private CreateChatInviteLink(Builder builder) { - chatId = builder.chatId; - setName(builder.name); - setExpireDate(builder.expireDate); - setMemberLimit(builder.memberLimit); - setCreatesJoinRequest(builder.createsJoinRequest); - } - - public void setName(String name) { - this.name = name; - } - - public void setExpireDate(Long expireDate) { - this.expireDate = expireDate; - } - - public void setMemberLimit(Integer memberLimit) { - this.memberLimit = memberLimit; - } - - public void setCreatesJoinRequest(Boolean createsJoinRequest) { - this.createsJoinRequest = createsJoinRequest; - } - - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId); - if (expireDate != null) builder.add("expire_date", String.valueOf(expireDate)); - if (memberLimit != null) builder.add("member_limit", String.valueOf(memberLimit)); - if (createsJoinRequest != null) builder.add("creates_join_request", String.valueOf(createsJoinRequest)); - return builder.build(); - } - - @Override - public String getMethodName() { - return "createChatInviteLink"; - } - - @Override - public Class getResponseClass() { - return ChatInviteLink.class; - } - - public static final class Builder { - private final String chatId; - private String name; - private Long expireDate; - private Integer memberLimit; - private Boolean createsJoinRequest; - - public Builder(String chatId) { - this.chatId = chatId; - } - - public Builder(long chatId) { - this(String.valueOf(chatId)); - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder expireDate(Long expireDate) { - this.expireDate = expireDate; - return this; - } - - public Builder memberLimit(Integer memberLimit) { - this.memberLimit = memberLimit; - return this; - } - - public Builder createsJoinRequest(Boolean createsJoinRequest) { - this.createsJoinRequest = createsJoinRequest; - return this; - } - - public CreateChatInviteLink build() { - return new CreateChatInviteLink(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java deleted file mode 100644 index 4f43654..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessage.java +++ /dev/null @@ -1,133 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Message; - -import okhttp3.RequestBody; - -/** - * Use this method to forward messages of any kind. - * Service messages and messages with protected content can't be forwarded. - * On success, the sent {@link Message} is returned. - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class ForwardMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("video_start_timestamp") - private long videoStartTimestamp; - - public ForwardMessage(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public ForwardMessage(long chatId, String fromChatId, long messageId) { - this(String.valueOf(chatId), fromChatId, messageId); - } - - public ForwardMessage(long chatId, long fromChatId, long messageId) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageId); - } - - private ForwardMessage(Builder builder) { - chatId = builder.chatId; - setMessageThreadId(builder.messageThreadId); - fromChatId = builder.fromChatId; - messageId = builder.messageId; - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setVideoStartTimestamp(builder.videoStartTimestamp); - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setVideoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "forwardMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final long messageId; - private Boolean disableNotification; - private Boolean protectContent; - private long videoStartTimestamp; - - public Builder(String chatId, String fromChatId, long messageId) { - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageId = messageId; - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(Boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public Builder videoStartTimestamp(long videoStartTimestamp) { - this.videoStartTimestamp = videoStartTimestamp; - return this; - } - - public ForwardMessage build() { - return new ForwardMessage(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java b/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java deleted file mode 100644 index 664566f..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/ForwardMessages.java +++ /dev/null @@ -1,147 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; - -import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.Message; - -import okhttp3.RequestBody; - -import java.util.ArrayList; -import java.util.List; - -/** - * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. - * Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. - * On success, an array of MessageId as {@link Long} of the sent messages is returned. - * @see Message#hasProtectedContent() - */ -@Jsonable -@NotTested -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class ForwardMessages implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("from_chat_id") - private final String fromChatId; - @JsonProperty("message_id") - private final List messageIds; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - - public ForwardMessages(String chatId, String fromChatId, List messageIds) { - ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); - sortedMessageIds.sort(null); - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageIds = sortedMessageIds; - } - - public ForwardMessages(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public ForwardMessages(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public ForwardMessages(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - private ForwardMessages(Builder builder) { - chatId = builder.chatId; - messageThreadId = builder.messageThreadId; - fromChatId = builder.fromChatId; - messageIds = builder.messageIds; - disableNotification = builder.disableNotification; - protectContent = builder.protectContent; - } - - public void setMessageThreadId(long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setDisableNotification(boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(boolean protectContent) { - this.protectContent = protectContent; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "forwardMessages"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Long[].class; - } - - - public static final class Builder { - private final String chatId; - private Long messageThreadId; - private final String fromChatId; - private final List messageIds; - private Boolean disableNotification; - private Boolean protectContent; - - public Builder(String chatId, String fromChatId, List messageIds) { - ArrayList sortedMessageIds = new ArrayList<>(messageIds.size() > 100 ? messageIds.subList(0, 100) : messageIds); - sortedMessageIds.sort(null); - this.chatId = chatId; - this.fromChatId = fromChatId; - this.messageIds = sortedMessageIds; - } - - public Builder(long chatId, String fromChatId, List messageIds) { - this(String.valueOf(chatId), fromChatId, messageIds); - } - - public Builder(String chatId, long fromChatId, List messageIds) { - this(chatId, String.valueOf(fromChatId), messageIds); - } - - public Builder(long chatId, long fromChatId, List messageIds) { - this(String.valueOf(chatId), String.valueOf(fromChatId), messageIds); - } - - public Builder messageThreadId(long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public Builder disableNotification(boolean disableNotification) { - this.disableNotification = disableNotification; - return this; - } - - public Builder protectContent(boolean protectContent) { - this.protectContent = protectContent; - return this; - } - - public ForwardMessages build() { - return new ForwardMessages(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java deleted file mode 100644 index 231c2bc..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetChatAdministrators.java +++ /dev/null @@ -1,36 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.annotations.util.NotTested; -import hdvtdev.telegram.objects.ChatMember; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. - * @param chatId - */ -@NotTested -public record GetChatAdministrators(@NotNull String chatId) implements TelegramApiMethod { - - public GetChatAdministrators(long chatId) { - this(String.valueOf(chatId)); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).build(); - } - - @Override - public String getMethodName() { - return "getChatAdministrators"; - } - - @Override - public Class getResponseClass() { - return ChatMember[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java b/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java deleted file mode 100644 index fee4dd3..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetChatMember.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.objects.ChatMember; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -public record GetChatMember(@NotNull String chatId, long userId) implements TelegramApiMethod { - - public GetChatMember(long chatId, long userId) { - this(String.valueOf(chatId), userId); - } - - public GetChatMember(String chatId, String userId) { - this(chatId, Long.parseLong(userId)); - } - - public GetChatMember(long chatId, String userId) { - this(String.valueOf(chatId), userId); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("user_id", String.valueOf(userId)).build(); - } - - @Override - public String getMethodName() { - return "getChatMember"; - } - - @Override - public Class getResponseClass() { - return ChatMember.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetFile.java b/core/src/main/java/hdvtdev/telegram/methods/GetFile.java deleted file mode 100644 index c29f5df..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetFile.java +++ /dev/null @@ -1,23 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.objects.TelegramFile; -import okhttp3.FormBody; -import okhttp3.RequestBody; - -public record GetFile(String fileId) implements TelegramApiMethod { - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("file_id", fileId).build(); - } - - @Override - public String getMethodName() { - return "getFile"; - } - - @Override - public Class getResponseClass() { - return TelegramFile.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMe.java b/core/src/main/java/hdvtdev/telegram/methods/GetMe.java deleted file mode 100644 index 224bbae..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetMe.java +++ /dev/null @@ -1,22 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.objects.User; -import okhttp3.RequestBody; - -public final class GetMe implements TelegramApiMethod { - - @Override - public RequestBody getBody() { - return null; - } - - @Override - public String getMethodName() { - return "getMe"; - } - - @Override - public Class getResponseClass() { - return User.Bot.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java deleted file mode 100644 index abd0400..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetMyCommands.java +++ /dev/null @@ -1,58 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import hdvtdev.telegram.objects.bot.BotCommandScopeDefault; - -import okhttp3.RequestBody; - -/** - * Use this method to get the current list of the bot's commands for the given scope and user language. - * Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. - * @param scope Scope of users. Defaults to {@link BotCommandScopeDefault}. - * @param languageCode A two-letter ISO 639-1 language code or an empty string - * @see BotCommandScope - * @since 1.0.0 - */ -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public record GetMyCommands( - @JsonProperty("scope") BotCommandScope scope, - @JsonProperty("language_code") String languageCode -) implements TelegramApiMethod { - - public GetMyCommands() { - this(null, null); - } - - public GetMyCommands(String languageCode) { - this(null, languageCode); - } - - public GetMyCommands(BotCommandScope scope) { - this(scope, null); - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "getMyCommands"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return BotCommand[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java deleted file mode 100644 index 2c74024..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetMyDescription.java +++ /dev/null @@ -1,42 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -public record GetMyDescription(String languageCode) implements TelegramApiMethod { - - public GetMyDescription() { - this(null); - } - - @Override - public RequestBody getBody() { - return languageCode == null ? null : new FormBody.Builder().add("language_code", languageCode).build(); - } - - @Override - public String getMethodName() { - return "getMyDescription"; - } - - @Override - public Class getResponseClass() { - return BotDescription.class; - } - - public record BotDescription(String description) { - @NotNull - @Override - public String toString() { - return description; - } - - public boolean isEmpty() { - return description.isEmpty(); - } - - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java b/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java deleted file mode 100644 index 1e76f28..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetMyName.java +++ /dev/null @@ -1,38 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.FormBody; -import okhttp3.RequestBody; -import org.jetbrains.annotations.NotNull; - -public record GetMyName(String languageCode) implements TelegramApiMethod { - - public GetMyName() { - this(null); - } - - @Override - public RequestBody getBody() { - return this.languageCode == null ? null : new FormBody.Builder().add("language_code", this.languageCode).build(); - } - - @Override - public String getMethodName() { - return "getMyName"; - } - - @Override - public Class getResponseClass() { - return BotName.class; - } - - public record BotName(String name) { - - @NotNull - @Override - public String toString() { - return this.name; - } - - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java b/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java deleted file mode 100644 index 7dfcf74..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/GetUpdates.java +++ /dev/null @@ -1,42 +0,0 @@ -package hdvtdev.telegram.methods; - - -import hdvtdev.telegram.objects.Update; -import okhttp3.RequestBody; - -import java.util.ArrayList; - -public record GetUpdates( - Long offset, - Integer limit, - Integer timeout -) implements TelegramApiMethod { - - public GetUpdates() { - this(null, null, null); - } - - @Override - public RequestBody getBody() { - return null; - } - - @Override - public String getMethodName() { - ArrayList params = new ArrayList<>(3); - if (offset != null) params.add("offset=" + offset); - if (limit != null) params.add("limit=" + limit); - if (timeout != null) params.add("timeout=" + timeout); - - if (params.isEmpty()) { - return "getUpdates"; - } else { - return "getUpdates?" + String.join("&", params); - } - } - - @Override - public Class getResponseClass() { - return Update[].class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java deleted file mode 100644 index e201091..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/RevokeChatInviteLink.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.methods; - -import hdvtdev.telegram.objects.ChatInviteLink; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; - -/** - * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. - * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. - * Returns the revoked invite link as {@link ChatInviteLink} object. - * @param chatId Unique identifier of the target chat or username of the target channel (in the format @channelusername) - * @param link The invite link to revoke - */ -public record RevokeChatInviteLink(@NotNull String chatId, @NotNull String link) implements TelegramApiMethod { - - public RevokeChatInviteLink(long chatId, @NotNull String link) { - this(String.valueOf(chatId), link); - } - - @Override - public RequestBody getBody() { - return new FormBody.Builder().add("chat_id", chatId).add("link", link).build(); - } - - @Override - public String getMethodName() { - return "revokeChatInviteLink"; - } - - @Override - public Class getResponseClass() { - return ChatInviteLink.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java b/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java deleted file mode 100644 index 871c195..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SendChatAction.java +++ /dev/null @@ -1,104 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class SendChatAction implements TelegramApiMethod { - - private String businessConnectionId; - private final String chatId; - private Long messageThreadId; - private final ChatAction chatAction; - - public SendChatAction(@Nullable String businessConnectionId, @NotNull String chatId, @Nullable Long messageThreadId, @NotNull ChatAction chatAction) { - this.businessConnectionId = businessConnectionId; - this.chatId = chatId; - this.messageThreadId = messageThreadId; - this.chatAction = chatAction; - } - - public SendChatAction(String chatId, ChatAction chatAction) { - this(null, chatId, null, chatAction); - } - - public SendChatAction(long chatId, ChatAction chatAction) { - this(String.valueOf(chatId), chatAction); - } - - private SendChatAction(Builder builder) { - this(builder.businessConnectionId, builder.chatId, builder.messageThreadId, builder.chatAction); - } - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - @Override - public RequestBody getBody() { - - FormBody.Builder builder = new FormBody.Builder().add("chat_id", chatId).add("action", chatAction.equals(ChatAction.UPLOAD_FILE) ? ChatAction.UPLOAD_DOCUMENT.name() : chatAction.name()); - - if (businessConnectionId != null) builder.add("business_connection_id", businessConnectionId); - if (messageThreadId != null) builder.add("message_thread_id", String.valueOf(messageThreadId)); - - return builder.build(); - } - - @Override - public String getMethodName() { - return "sendChatAction"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public enum ChatAction { - TYPING, - UPLOAD_PHOTO, - RECORD_VIDEO, - UPLOAD_VIDEO, - RECORD_VOICE, - UPLOAD_VOICE, - UPLOAD_DOCUMENT, - UPLOAD_FILE, - CHOOSE_STICKER, - FIND_LOCATION, - RECORD_VIDEO_NOTE, - UPLOAD_VIDEO_NOTE - } - - public static final class Builder { - private String businessConnectionId; - private final String chatId; - private Long messageThreadId; - private final ChatAction chatAction; - - public Builder(String chatId, ChatAction chatAction) { - this.chatId = chatId; - this.chatAction = chatAction; - } - - public Builder businessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - return this; - } - - public Builder messageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - return this; - } - - public SendChatAction build() { - return new SendChatAction(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendDice.java b/core/src/main/java/hdvtdev/telegram/methods/SendDice.java deleted file mode 100644 index e71c879..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SendDice.java +++ /dev/null @@ -1,133 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.ReplyMarkup; -import hdvtdev.telegram.objects.ReplyParameters; - -import okhttp3.RequestBody; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SendDice implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("business_connection_id") - private String businessConnectionId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("emoji") - private String emoji; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("message_effect_id") - private String messageEffectId; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - public SendDice(String chatId) { - this.chatId = chatId; - } - - public SendDice(long chatId) { - this(String.valueOf(chatId)); - } - - public SendDice(String chatId, Emoji emoji) { - this.emoji = emoji.getEmoji(); - this.chatId = chatId; - } - - public SendDice(long chatId, Emoji emoji) { - this(String.valueOf(chatId), emoji); - } - - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setEmoji(Emoji emoji) { - this.emoji = emoji.getEmoji(); - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setMessageEffectId(String messageEffectId) { - this.messageEffectId = messageEffectId; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "sendDice"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public enum Emoji { - DICE("🎲"), - DART("🎯"), - BASKETBALL("🏀"), - FOOTBALL("⚽"), - BOWLING("🎳"), - SLOT_MACHINE("🎰"); - - private final String emoji; - - Emoji(String emoji) { - this.emoji = emoji; - } - - public String getEmoji() { - return emoji; - } - - } - - - -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java b/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java deleted file mode 100644 index 8c67974..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SendMessage.java +++ /dev/null @@ -1,226 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.*; -import hdvtdev.telegram.util.ParseMode; - -import okhttp3.RequestBody; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SendMessage implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("text") - private final String text; - @JsonProperty("business_connection_id") - private String businessConnectionId; - @JsonProperty("message_thread_id") - private Long messageThreadId; - @JsonProperty("parse_mode") - private ParseMode parseMode; - @JsonProperty("entities") - private MessageEntity[] entities; - @JsonProperty("link_preview_options") - private LinkPreviewOptions linkPreviewOptions; - @JsonProperty("disable_notification") - private Boolean disableNotification; - @JsonProperty("protect_content") - private Boolean protectContent; - @JsonProperty("allow_paid_broadcast") - private Boolean allowPaidBroadcast; - @JsonProperty("message_effect_id") - private String messageEffectId; - @JsonProperty("reply_parameters") - private ReplyParameters replyParameters; - @JsonProperty("reply_markup") - private ReplyMarkup replyMarkup; - - private SendMessage(Builder builder) { - chatId = builder.chatId; - text = builder.text; - setBusinessConnectionId(builder.businessConnectionId); - setMessageThreadId(builder.messageThreadId); - setParseMode(builder.parseMode); - setEntities(builder.entities); - setLinkPreviewOptions(builder.linkPreviewOptions); - setDisableNotification(builder.disableNotification); - setProtectContent(builder.protectContent); - setAllowPaidBroadcast(builder.allowPaidBroadcast); - setMessageEffectId(builder.messageEffectId); - setReplyParameters(builder.replyParameters); - setReplyMarkup(builder.replyMarkup); - } - - public void setLinkPreviewOptions(LinkPreviewOptions linkPreviewOptions) { - this.linkPreviewOptions = linkPreviewOptions; - } - - public void setBusinessConnectionId(String businessConnectionId) { - this.businessConnectionId = businessConnectionId; - } - - public void setMessageThreadId(Long messageThreadId) { - this.messageThreadId = messageThreadId; - } - - public void setParseMode(ParseMode parseMode) { - this.parseMode = parseMode; - } - - public void setEntities(MessageEntity[] entities) { - this.entities = entities; - } - - public void setDisableNotification(Boolean disableNotification) { - this.disableNotification = disableNotification; - } - - public void setProtectContent(Boolean protectContent) { - this.protectContent = protectContent; - } - - public void setAllowPaidBroadcast(Boolean allowPaidBroadcast) { - this.allowPaidBroadcast = allowPaidBroadcast; - } - - public void setMessageEffectId(String messageEffectId) { - this.messageEffectId = messageEffectId; - } - - public void setReplyParameters(ReplyParameters replyParameters) { - this.replyParameters = replyParameters; - } - - public void setReplyToMessage(long messageId) { - this.replyParameters = new ReplyParameters(messageId, chatId); - } - - public void setReplyMarkup(ReplyMarkup replyMarkup) { - this.replyMarkup = replyMarkup; - } - - public SendMessage(String chatId, String text) { - if (chatId.isEmpty() || text.isEmpty()) - throw new IllegalArgumentException("chatId or/and message (text) cannot be empty."); - this.chatId = chatId; - this.text = text; - } - - public SendMessage(long chatIdAsLong, String text) { - this(String.valueOf(chatIdAsLong), text); - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "sendMessage"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Message.class; - } - - public static final class Builder { - private final String chatId; - private final String text; - private String businessConnectionId; - private Long messageThreadId; - private ParseMode parseMode; - private MessageEntity[] entities; - private LinkPreviewOptions linkPreviewOptions; - private Boolean disableNotification; - private Boolean protectContent; - private Boolean allowPaidBroadcast; - private String messageEffectId; - private ReplyParameters replyParameters; - private ReplyMarkup replyMarkup; - - public Builder(long chatId, String text) { - this(String.valueOf(chatId), text); - } - - public Builder(String chatId, String text) { - this.chatId = chatId; - this.text = text; - } - - public Builder businessConnectionId(String val) { - businessConnectionId = val; - return this; - } - - public Builder messageThreadId(Long val) { - messageThreadId = val; - return this; - } - - public Builder parseMode(ParseMode val) { - parseMode = val; - return this; - } - - public Builder entities(MessageEntity[] val) { - entities = val; - return this; - } - - public Builder linkPreviewOptions(LinkPreviewOptions val) { - linkPreviewOptions = val; - return this; - } - - public Builder disableNotification() { - disableNotification = true; - return this; - } - - public Builder protectContent() { - protectContent = true; - return this; - } - - public Builder allowPaidBroadcast() { - allowPaidBroadcast = true; - return this; - } - - public Builder messageEffectId(String val) { - messageEffectId = val; - return this; - } - - public Builder replyParameters(ReplyParameters val) { - replyParameters = val; - return this; - } - - public Builder replyToMessage(long val) { - replyParameters = new ReplyParameters(val, this.chatId); - return this; - } - - public Builder replyMarkup(ReplyMarkup val) { - replyMarkup = val; - return this; - } - - public SendMessage build() { - return new SendMessage(this); - } - } -} - diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java b/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java deleted file mode 100644 index 2cf41ea..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SetMessageReaction.java +++ /dev/null @@ -1,100 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.ReactionType; - -import okhttp3.RequestBody; - -import java.util.List; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SetMessageReaction implements TelegramApiMethod { - - @JsonProperty("chat_id") - private final String chatId; - @JsonProperty("message_id") - private final long messageId; - @JsonProperty("reaction") - private List reactions; - @JsonProperty("is_big") - private Boolean isBig; - - public SetMessageReaction(String chatId, long messageId) { - this.chatId = chatId; - this.messageId = messageId; - } - - public SetMessageReaction(long chatId, long messageId) { - this.chatId = String.valueOf(chatId); - this.messageId = messageId; - } - - private SetMessageReaction(Builder builder) { - chatId = builder.chatId; - messageId = builder.messageId; - setReactions(builder.reactions); - isBig = builder.isBig; - } - - public void setReactions(List reactions) { - this.reactions = reactions; - } - - public void setBig(Boolean big) { - isBig = big; - } - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "setMessageReaction"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Boolean.class; - } - - public static final class Builder { - private final String chatId; - private final long messageId; - private List reactions; - private Boolean isBig; - - public Builder(String chatId, long messageId) { - this.chatId = chatId; - this.messageId = messageId; - } - - public Builder(long chatId, long messageId) { - this.chatId = String.valueOf(chatId); - this.messageId = messageId; - } - - public Builder reactions(List reactions) { - this.reactions = reactions; - return this; - } - - public Builder isBig(Boolean isBig) { - this.isBig = isBig; - return this; - } - - public SetMessageReaction build() { - return new SetMessageReaction(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java deleted file mode 100644 index 6fa9fbf..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SetMyCommands.java +++ /dev/null @@ -1,100 +0,0 @@ -package hdvtdev.telegram.methods; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import hdvtdev.telegram.annotations.util.Jsonable; -import hdvtdev.telegram.objects.bot.BotCommand; -import hdvtdev.telegram.objects.bot.BotCommandScope; -import okhttp3.RequestBody; - -import java.util.List; - -@Jsonable -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class SetMyCommands implements TelegramApiMethod { - - @JsonProperty("commands") - private final List commands; - @JsonProperty("scope") - private Object scope; - @JsonProperty("language_code") - private String languageCode; - - public SetMyCommands(List commands, Object scope, String languageCode) { - this.commands = commands; - this.scope = scope; - this.languageCode = languageCode; - } - - public SetMyCommands(BotCommand... commands) { - this.commands = List.of(commands); - } - - public SetMyCommands(List commands) { - this.commands = commands; - } - - private SetMyCommands(Builder builder) { - commands = builder.commands; - setScope(builder.scope); - setLanguageCode(builder.languageCode); - } - - public void setScope(Object scope) { - this.scope = scope; - } - - public void setLanguageCode(String languageCode) { - this.languageCode = languageCode; - } - - - @JsonIgnore - @Override - public RequestBody getBody() { - return null; - } - - @JsonIgnore - @Override - public String getMethodName() { - return "setMyCommands"; - } - - @JsonIgnore - @Override - public Class getResponseClass() { - return Boolean.class; - } - - - public static final class Builder { - private final List commands; - private Object scope; - private String languageCode; - - public Builder(List commands) { - this.commands = commands; - } - - public Builder(BotCommand... commands) { - this.commands = List.of(commands); - } - - public Builder scope(BotCommandScope scope) { - this.scope = scope; - return this; - } - - public Builder languageCode(String languageCode) { - this.languageCode = languageCode; - return this; - } - - public SetMyCommands build() { - return new SetMyCommands(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java deleted file mode 100644 index 8757cc7..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SetMyDescription.java +++ /dev/null @@ -1,41 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -/** - * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. - * Returns {@code true} on success. - * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. - * @param languageCode A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. - */ -public record SetMyDescription(String description, String languageCode) implements TelegramApiMethod { - - public SetMyDescription() { - this(null, null); - } - - public SetMyDescription(String description) { - this(description, null); - } - - @Override - public RequestBody getBody() { - if (description == null) { - return null; - } - FormBody.Builder builder = new FormBody.Builder().add("description", description); - if (languageCode != null) builder.add("language_code", languageCode); - return builder.build(); - } - - @Override - public String getMethodName() { - return "setMyDescription"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java b/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java deleted file mode 100644 index 536002c..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/SetMyName.java +++ /dev/null @@ -1,28 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.FormBody; -import okhttp3.RequestBody; - -public record SetMyName(String name, String languageCode) implements TelegramApiMethod { - - public SetMyName(String name) { - this(name, null); - } - - @Override - public RequestBody getBody() { - FormBody.Builder builder = new FormBody.Builder().add("name", this.name); - if (languageCode != null) builder.add("language_code", this.languageCode); - return builder.build(); - } - - @Override - public String getMethodName() { - return "setMyName"; - } - - @Override - public Class getResponseClass() { - return Boolean.class; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java b/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java deleted file mode 100644 index 268f6db..0000000 --- a/core/src/main/java/hdvtdev/telegram/methods/TelegramApiMethod.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.methods; - -import okhttp3.RequestBody; - -public interface TelegramApiMethod { - - RequestBody getBody(); - - String getMethodName(); - - Class getResponseClass(); - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Animation.java b/core/src/main/java/hdvtdev/telegram/objects/Animation.java deleted file mode 100644 index e5c3785..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Animation.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) -public record Animation( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("width") int width, - @JsonProperty("height") int height, - @JsonProperty("duration") int duration, - @JsonProperty("thumbnail") PhotoSize thumbnail, - @JsonProperty("file_name") String fileName, - @JsonProperty("mime_type") String mimeType, - @JsonProperty("file_size") Long fileSize -) { - - public boolean hasThumbnail() { - return this.thumbnail != null; - } - - public boolean hasFileName() { - return this.fileName != null; - } - - public boolean hasMimeType() { - return this.mimeType != null; - } - - public boolean hasFileSize() { - return this.fileSize != null; - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Audio.java b/core/src/main/java/hdvtdev/telegram/objects/Audio.java deleted file mode 100644 index 591f8be..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Audio.java +++ /dev/null @@ -1,37 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Audio( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("duration") int duration, - @JsonProperty("performer") String performer, - @JsonProperty("title") String title, - @JsonProperty("file_name") String fileName, - @JsonProperty("mime_type") String mimeType, - @JsonProperty("file_size") Long fileSize, - @JsonProperty("thumbnail") PhotoSize thumbnail -) { - - public boolean hasThumbnail() { - return this.thumbnail != null; - } - - public boolean hasFileName() { - return this.fileName != null; - } - - public boolean hasMimeType() { - return this.mimeType != null; - } - - public boolean hasFileSize() { - return this.fileSize != null; - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java deleted file mode 100644 index 94fe350..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFill.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BackgroundFillSolid.class, name = "solid"), - @JsonSubTypes.Type(value = BackgroundFillGradient.class, name = "gradient"), - @JsonSubTypes.Type(value = BackgroundFillFreeformGradient.class, name = "freeform_gradient") -}) -public interface BackgroundFill { - String type(); -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java deleted file mode 100644 index 6e9c38d..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillFreeformGradient.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundFillFreeformGradient( - @JsonProperty("type") String type, - @JsonProperty("colors") int[] colors -) implements BackgroundFill { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java deleted file mode 100644 index a1573fe..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillGradient.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundFillGradient( - @JsonProperty("type") String type, - @JsonProperty("top_color") int topColor, - @JsonProperty("bottom_color") int bottomColor, - @JsonProperty("rotation_angle") int rotationAngle -) implements BackgroundFill { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java deleted file mode 100644 index c2bfba8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundFillSolid.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundFillSolid( - @JsonProperty("type") String type, - @JsonProperty("color") int color -) implements BackgroundFill { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java deleted file mode 100644 index 9b3c347..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundType.java +++ /dev/null @@ -1,19 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BackgroundTypeFill.class, name = "fill"), - @JsonSubTypes.Type(value = BackgroundTypeWallpaper.class, name = "wallpaper"), - @JsonSubTypes.Type(value = BackgroundTypePattern.class, name = "pattern"), - @JsonSubTypes.Type(value = BackgroundTypeChatTheme.class, name = "chat_theme") -}) -public interface BackgroundType { - String type(); -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java deleted file mode 100644 index 1d7323d..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeChatTheme.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundTypeChatTheme( - @JsonProperty("type") String type, - @JsonProperty("theme_name") String themeName -) implements BackgroundType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java deleted file mode 100644 index 00efd83..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeFill.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundTypeFill( - @JsonProperty("type") String type, - @JsonProperty("fill") BackgroundFill fill, - @JsonProperty("dark_theme_dimming") int darkThemeDimming -) implements BackgroundType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java deleted file mode 100644 index 201eef1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypePattern.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundTypePattern( - @JsonProperty("type") String type, - @JsonProperty("document") Document document, - @JsonProperty("fill") BackgroundFill fill, - @JsonProperty("is_inverted") boolean isInverted, - @JsonProperty("is_moving") boolean isMoving -) implements BackgroundType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java b/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java deleted file mode 100644 index da3a7ef..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BackgroundTypeWallpaper.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BackgroundTypeWallpaper( - @JsonProperty("type") String type, - @JsonProperty("document") Document document, - @JsonProperty("dark_theme_dimming") int darkThemeDimming, - @JsonProperty("is_blurred") boolean isBlurred, - @JsonProperty("is_moving") boolean isMoving -) implements BackgroundType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java b/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java deleted file mode 100644 index 2917f45..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BusinessConnection.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BusinessConnection( - @JsonProperty("id") String id, - @JsonProperty("user") User user, - @JsonProperty("user_chat_id") long userChatId, - @JsonProperty("date") long date, - @JsonProperty("can_reply") boolean canReply, - @JsonProperty("is_enabled") boolean isEnabled -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java b/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java deleted file mode 100644 index 06a4536..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/BusinessMessagesDeleted.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BusinessMessagesDeleted( - @JsonProperty("business_connection_id") String businessConnectionId, - @JsonProperty("chat") Chat chat, - @JsonProperty("message_ids") long[] messageIds -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java b/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java deleted file mode 100644 index 4213d42..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/CallbackGame.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record CallbackGame() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java b/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java deleted file mode 100644 index add7ba0..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/CallbackQuery.java +++ /dev/null @@ -1,39 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record CallbackQuery( - @JsonProperty("id") String id, - @JsonProperty("from") User from, - @JsonProperty("message") MaybeInaccessibleMessage message, - @JsonProperty("inline_message_id") String inlineMessageId, - @JsonProperty("chat_instance") String chatInstance, - @JsonProperty("data") String data, - @JsonProperty("game_short_name") String gameShortName -) { - - public boolean hasMessage() { - return this.message != null; - } - - public boolean hasInlineMessageId() { - return this.inlineMessageId != null; - } - - public boolean hasChatInstance() { - return this.chatInstance != null; - } - - public boolean hasData() { - return this.data != null; - } - - public boolean hasGameShortName() { - return this.gameShortName != null; - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Chat.java b/core/src/main/java/hdvtdev/telegram/objects/Chat.java deleted file mode 100644 index 4d15355..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Chat.java +++ /dev/null @@ -1,35 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Chat( - @JsonProperty("id") long id, - @JsonProperty("type") String type, - @JsonProperty("title") String title, - @JsonProperty("username") String username, - @JsonProperty("first_name") String firstName, - @JsonProperty("last_name") String lastName, - @JsonProperty("is_forum") boolean isForum -) { - - public boolean hasTitle() { - return this.title != null; - } - - public boolean hasUsername() { - return this.username != null; - } - - public boolean hasFirstName() { - return this.firstName != null; - } - - public boolean hasLastName() { - return this.lastName != null; - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java b/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java deleted file mode 100644 index 0653c1a..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatAdministratorRights.java +++ /dev/null @@ -1,26 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatAdministratorRights( - @JsonProperty("is_anonymous") boolean isAnonymous, - @JsonProperty("can_manage_chat") boolean canManageChat, - @JsonProperty("can_delete_messages") boolean canDeleteMessages, - @JsonProperty("can_manage_video_chats") boolean canManageVideoChats, - @JsonProperty("can_restrict_members") boolean canRestrictMembers, - @JsonProperty("can_promote_members") boolean canPromoteMembers, - @JsonProperty("can_change_info") boolean canChangeInfo, - @JsonProperty("can_invite_users") boolean canInviteUsers, - @JsonProperty("can_post_stories") boolean canPostStories, - @JsonProperty("can_edit_stories") boolean canEditStories, - @JsonProperty("can_delete_stories") boolean canDeleteStories, - @JsonProperty("can_post_messages") boolean canPostMessages, - @JsonProperty("can_edit_messages") boolean canEditMessages, - @JsonProperty("can_pin_messages") boolean canPinMessages, - @JsonProperty("can_manage_topics") boolean canManageTopics -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java deleted file mode 100644 index af2af91..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBackground.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBackground(@JsonProperty("type") BackgroundType type) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java deleted file mode 100644 index 2f16be1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoost.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoost( - @JsonProperty("boost_id") String boostId, - @JsonProperty("add_date") long addDate, - @JsonProperty("expiration_date") long expirationDate, - @JsonProperty("source") ChatBoostSource source -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java deleted file mode 100644 index de0db01..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostAdded.java +++ /dev/null @@ -1,12 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostAdded( - @JsonProperty("boost_count") int boostCount -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java deleted file mode 100644 index 2c04426..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostRemoved.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostRemoved( - @JsonProperty("chat") Chat chat, - @JsonProperty("boost_id") String boostId, - @JsonProperty("remove_date") long removeDate, - @JsonProperty("source") ChatBoostSource source -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java deleted file mode 100644 index 0b46d25..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSource.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "source" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ChatBoostSourcePremium.class, name = "premium"), - @JsonSubTypes.Type(value = ChatBoostSourceGiveaway.class, name = "giveaway"), - @JsonSubTypes.Type(value = ChatBoostSourceGiftCode.class, name = "gift_code") -}) -public interface ChatBoostSource { - String source(); -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java deleted file mode 100644 index c3e8cd8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiftCode.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostSourceGiftCode( - @JsonProperty("source") String source, - @JsonProperty("user") User user -) implements ChatBoostSource { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java deleted file mode 100644 index d48c42c..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourceGiveaway.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostSourceGiveaway( - @JsonProperty("source") String source, - @JsonProperty("giveaway_message_id") long giveawayMessageId, - @JsonProperty("user") User user, - @JsonProperty("prize_star_count") int prizeStarCount, - @JsonProperty("is_unclaimed") boolean isUnclaimed -) implements ChatBoostSource { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java deleted file mode 100644 index a096875..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostSourcePremium.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostSourcePremium( - @JsonProperty("source") String source, - @JsonProperty("user") User user -) implements ChatBoostSource { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java deleted file mode 100644 index 05dd19d..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatBoostUpdated.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatBoostUpdated( - @JsonProperty("chat") Chat chat, - @JsonProperty("boost") ChatBoost boost -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java b/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java deleted file mode 100644 index c8a57ee..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatInviteLink.java +++ /dev/null @@ -1,29 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatInviteLink( - @JsonProperty("invite_link") String inviteLink, - @JsonProperty("creator") User creator, - @JsonProperty("creates_join_request") boolean createsJoinRequest, - @JsonProperty("is_primary") boolean isPrimary, - @JsonProperty("is_revoked") boolean isRevoked, - @JsonProperty("name") String name, - @JsonProperty("expire_date") long expireDate, - @JsonProperty("member_limit") int memberLimit, - @JsonProperty("pending_join_request_count") int pendingJoinRequestCount, - @JsonProperty("subscription_period") int subscriptionPeriod, - @JsonProperty("subscription_price") int subscriptionPrice -) { - @NotNull - @Override - public String toString() { - return this.inviteLink; - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java b/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java deleted file mode 100644 index d5e8a86..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatJoinRequest.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatJoinRequest( - @JsonProperty("chat") Chat chat, - @JsonProperty("from") User from, - @JsonProperty("user_chat_id") long userChatId, - @JsonProperty("date") long date, - @JsonProperty("bio") String bio, - @JsonProperty("invite_link") ChatInviteLink chatInviteLink -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java deleted file mode 100644 index fdce955..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMember.java +++ /dev/null @@ -1,28 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "status" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ChatMemberAdministrator.class, name = "administrator"), - @JsonSubTypes.Type(value = ChatMemberBanned.class, name = "kicked"), - @JsonSubTypes.Type(value = ChatMemberLeft.class, name = "left"), - @JsonSubTypes.Type(value = ChatMemberMember.class, name = "member"), - @JsonSubTypes.Type(value = ChatMemberOwner.class, name = "creator"), - @JsonSubTypes.Type(value = ChatMemberRestricted.class, name = "restricted"), -}) -public interface ChatMember { - User user(); - String status(); - - default ChatMemberAdministrator getAsChatMemberAdministrator() { - return (ChatMemberAdministrator) this; - } - -} - diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java deleted file mode 100644 index c2ee0ed..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberAdministrator.java +++ /dev/null @@ -1,30 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberAdministrator( - @JsonProperty("status") String status, - @JsonProperty("user") User user, - @JsonProperty("can_be_edited") boolean canBeEdited, - @JsonProperty("is_anonymous") boolean isAnonymous, - @JsonProperty("can_manage_chat") boolean canManageChat, - @JsonProperty("can_delete_messages") boolean canDeleteMessages, - @JsonProperty("can_manage_video_chats") boolean canManageVideoChat, - @JsonProperty("can_restrict_members") boolean canRestrictMembers, - @JsonProperty("can_promote_members") boolean canPromoteMembers, - @JsonProperty("can_change_info") boolean canChangeInfo, - @JsonProperty("can_invite_users") boolean canInviteUsers, - @JsonProperty("can_post_stories") boolean canPostStories, - @JsonProperty("can_edit_stories") boolean canEditStories, - @JsonProperty("can_delete_stories") boolean canDeleteStories, - @JsonProperty("can_post_messages") boolean canPostMessages, - @JsonProperty("can_edit_messages") boolean canEditMessages, - @JsonProperty("can_pin_messages") boolean canPinMessages, - @JsonProperty("can_manage_topics") boolean canManageTopics, - @JsonProperty("custom_title") boolean hasCustomTitle -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java deleted file mode 100644 index e31b1f2..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberBanned.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberBanned( - @JsonProperty("status") String status, - @JsonProperty("user") User user, - @JsonProperty("until_date") long untilDate -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java deleted file mode 100644 index a8511e7..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberLeft.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberLeft( - @JsonProperty("status") String status, - @JsonProperty("user") User user -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java deleted file mode 100644 index 6462ead..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberMember.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberMember( - @JsonProperty("status") String status, - @JsonProperty("user") User user, - @JsonProperty("until_date") long untilDate -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java deleted file mode 100644 index b41346b..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberOwner.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberOwner( - @JsonProperty("status") String status, - @JsonProperty("user") User user, - @JsonProperty("is_anonymous") boolean isAnonymous, - @JsonProperty("custom_title") String customTitle -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java deleted file mode 100644 index d801758..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberRestricted.java +++ /dev/null @@ -1,29 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberRestricted( - @JsonProperty("status") String status, - @JsonProperty("user") User user, - @JsonProperty("is_member") boolean isMember, - @JsonProperty("can_send_messages") boolean canSendMessage, - @JsonProperty("can_send_audios") boolean canSendAudios, - @JsonProperty("can_send_documents") boolean canSendDocuments, - @JsonProperty("can_send_photos") boolean canSendPhotos, - @JsonProperty("can_send_videos") boolean canSendVideos, - @JsonProperty("can_send_video_notes") boolean canSendVideoNotes, - @JsonProperty("can_send_voice_notes") boolean canSendVoiceNotes, - @JsonProperty("can_send_polls") boolean canSendPolls, - @JsonProperty("can_send_other_messages") boolean canSendOtherMessages, - @JsonProperty("can_add_web_page_previews") boolean canAddWebPagePreviews, - @JsonProperty("can_change_info") boolean canChangeInfo, - @JsonProperty("can_invite_users") boolean canInviteUsers, - @JsonProperty("can_pin_messages") boolean canPinMessages, - @JsonProperty("can_manage_topics") boolean canManageTopics, - @JsonProperty("until_date") long untilDate -) implements ChatMember { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java deleted file mode 100644 index 0634715..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatMemberUpdated.java +++ /dev/null @@ -1,19 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatMemberUpdated( - @JsonProperty("chat") Chat chat, - @JsonProperty("from") User from, - @JsonProperty("date") long date, - @JsonProperty("old_chat_member") ChatMember oldChatMember, - @JsonProperty("new_chat_member") ChatMember newChatMember, - @JsonProperty("invite_link") ChatInviteLink chatInviteLink, - @JsonProperty("via_join_request") boolean viaJoinRequest, - @JsonProperty("via_chat_folder_invite_link") boolean viaChatFolderInviteLink -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java b/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java deleted file mode 100644 index 114346a..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChatShared.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChatShared( - @JsonProperty("request_id") int requestId, - @JsonProperty("chat_id") long chatId, - @JsonProperty("title") String title, - @JsonProperty("username") String username, - @JsonProperty("photo") PhotoSize[] photo -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java b/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java deleted file mode 100644 index d57196f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ChosenInlineResult.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ChosenInlineResult( - @JsonProperty("result_id") String resultId, - @JsonProperty("from") User from, - @JsonProperty("location") Location location, - @JsonProperty("inline_message_id") String inlineMessageId, - @JsonProperty("query") String query -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Contact.java b/core/src/main/java/hdvtdev/telegram/objects/Contact.java deleted file mode 100644 index 5e28ed9..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Contact.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Contact( - @JsonProperty("phone_number") String phoneNumber, - @JsonProperty("first_name") String firstName, - @JsonProperty("last_name") String lastName, - @JsonProperty("user_id") long userId, - @JsonProperty("vcard") String vcard -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java b/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java deleted file mode 100644 index 895f845..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/CopyTextButton.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record CopyTextButton(@JsonProperty("text") String text) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Dice.java b/core/src/main/java/hdvtdev/telegram/objects/Dice.java deleted file mode 100644 index 5c3061b..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Dice.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Dice( - @JsonProperty("emoji") String emoji, - @JsonProperty("value") int value -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Document.java b/core/src/main/java/hdvtdev/telegram/objects/Document.java deleted file mode 100644 index 8e3fd8c..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Document.java +++ /dev/null @@ -1,21 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import hdvtdev.telegram.methods.GetFile; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Document( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("thumbnail") PhotoSize thumbnail, - @JsonProperty("file_name") String fileName, - @JsonProperty("mime_type") String mimeType, - @JsonProperty("file_size") long fileSize -) { - public GetFile getFile() { - return new GetFile(this.fileId); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java b/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java deleted file mode 100644 index 90a57ae..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/EncryptedCredentials.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record EncryptedCredentials( - @JsonProperty("data") String data, - @JsonProperty("hash") String hash, - @JsonProperty("secret") String secret -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java b/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java deleted file mode 100644 index a1dfa54..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/EncryptedPassportElement.java +++ /dev/null @@ -1,21 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record EncryptedPassportElement( - @JsonProperty("type") String type, - @JsonProperty("data") String data, - @JsonProperty("phone_number") String phoneNumber, - @JsonProperty("email") String email, - @JsonProperty("files") PassportFile[] files, - @JsonProperty("front_side") PassportFile frontSide, - @JsonProperty("reverse_side") PassportFile reverseSide, - @JsonProperty("selfie") PassportFile selfie, - @JsonProperty("translation") PassportFile[] translation, - @JsonProperty("hash") String hash -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java b/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java deleted file mode 100644 index 84f2ce8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ExternalReplyInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ExternalReplyInfo( - @JsonProperty("origin") MessageOrigin origin, - @JsonProperty("chat") Chat chat, - @JsonProperty("message_id") long messageId, - @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, - @JsonProperty("animation") Animation animation, - @JsonProperty("audio") Audio audio, - @JsonProperty("document") Document document, - @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, - @JsonProperty("photo") PhotoSize[] photo, - @JsonProperty("sticker") Sticker sticker, - @JsonProperty("story") Story story, - @JsonProperty("video") Video video, - @JsonProperty("video_note") VideoNote videoNote, - @JsonProperty("voice") Voice voice, - @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, - @JsonProperty("contact") Contact contact, - @JsonProperty("dice") Dice dice, - @JsonProperty("game") Game game, - @JsonProperty("giveaway") Giveaway giveaway, - @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, - @JsonProperty("invoice") Invoice invoice, - @JsonProperty("location") Location location, - @JsonProperty("poll") Poll poll, - @JsonProperty("venue") Venue venue -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java b/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java deleted file mode 100644 index 61df0cb..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ForceReply.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ForceReply( - @JsonProperty("force_reply") boolean forceReply, - @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, - @JsonProperty("selective") boolean selective -) implements ReplyMarkup { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java deleted file mode 100644 index 619afff..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicClosed.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ForumTopicClosed() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java deleted file mode 100644 index 166e12f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicCreated.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ForumTopicCreated( - @JsonProperty("name") String name, - @JsonProperty("icon_color") int iconColor, - @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java deleted file mode 100644 index 85e3c3f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicEdited.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ForumTopicEdited( - @JsonProperty("name") String name, - @JsonProperty("icon_custom_emoji_id") String iconCustomEmojiId -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java b/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java deleted file mode 100644 index 1beab80..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ForumTopicReopened.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ForumTopicReopened() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Game.java b/core/src/main/java/hdvtdev/telegram/objects/Game.java deleted file mode 100644 index ec4a513..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Game.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Game( - @JsonProperty("title") String title, - @JsonProperty("description") String description, - @JsonProperty("photo") PhotoSize[] photo, - @JsonProperty("text") String text, - @JsonProperty("text_entities") MessageEntity[] textEntities, - @JsonProperty("animation") Animation animation -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java deleted file mode 100644 index cc154a1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicHidden.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record GeneralForumTopicHidden() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java b/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java deleted file mode 100644 index 81616f9..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/GeneralForumTopicUnhidden.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record GeneralForumTopicUnhidden() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java b/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java deleted file mode 100644 index 9f7a292..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Giveaway.java +++ /dev/null @@ -1,20 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Giveaway( - @JsonProperty("chats") Chat[] chats, - @JsonProperty("winners_selection_date") long winnersSelectionDate, - @JsonProperty("winner_count") int winnerCount, - @JsonProperty("only_new_members") boolean onlyNewMembers, - @JsonProperty("has_public_winners") boolean hasPublicWinners, - @JsonProperty("prize_description") String prizeDescription, - @JsonProperty("country_codes") String[] countryCodes, - @JsonProperty("prize_star_count") int prizeStarCount, - @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java deleted file mode 100644 index b293899..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCompleted.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record GiveawayCompleted( - @JsonProperty("winner_count") int winnerCount, - @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, - @JsonProperty("giveaway_message") Message giveawayMessage, - @JsonProperty("is_star_giveaway") boolean isStarGiveaway -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java deleted file mode 100644 index e69d7c4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/GiveawayCreated.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record GiveawayCreated(@JsonProperty("prize_star_count") int prizeStarCount) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java b/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java deleted file mode 100644 index 028819e..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/GiveawayWinners.java +++ /dev/null @@ -1,23 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record GiveawayWinners( - @JsonProperty("chat") Chat chat, - @JsonProperty("giveaway_message_id") long giveawayMessageId, - @JsonProperty("winners_selection_date") long winnersSelectionDate, - @JsonProperty("winners_count") int winnersCount, - @JsonProperty("winners") User[] winners, - @JsonProperty("additional_chat_count") int additionalChatCount, - @JsonProperty("prize_star_count") int prizeStarCount, - @JsonProperty("premium_subscription_month_count") int premiumSubscriptionMonthCount, - @JsonProperty("unclaimed_prize_count") int unclaimedPrizeCount, - @JsonProperty("only_new_members") boolean onlyNewMembers, - @JsonProperty("was_refunded") boolean wasRefunded, - @JsonProperty("prize_description") String prizeDescription -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java deleted file mode 100644 index ec66ce7..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/InaccessibleMessage.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record InaccessibleMessage(Chat chat, @JsonProperty("message_id") int messageId, - long date) implements MaybeInaccessibleMessage { - @Override - public long chatId() { - return chat.id(); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java deleted file mode 100644 index 0b71217..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardButton.java +++ /dev/null @@ -1,250 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public final class InlineKeyboardButton { - - @JsonProperty("text") - private final String text; - @JsonProperty("url") - private String url; - @JsonProperty("callback_data") - private String callbackData; - @JsonProperty("web_app") - private WebAppInfo webApp; - @JsonProperty("login_url") - private LoginUrl loginUrl; - @JsonProperty("switch_inline_query") - private String switchInlineQuery; - @JsonProperty("switch_inline_query_current_chat") - private String switchInlineQueryCurrentChat; - @JsonProperty("switch_inline_query_chosen_chat") - private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; - @JsonProperty("copy_text") - private CopyTextButton copyTextButton; - @JsonProperty("callback_game") - private CallbackGame callbackGame; - @JsonProperty("pay") - private Boolean pay; - - @JsonCreator - public InlineKeyboardButton( - @JsonProperty("text") String text, - @JsonProperty("url") String url, - @JsonProperty("callback_data") String callbackData, - @JsonProperty("web_app") WebAppInfo webApp, - @JsonProperty("login_url") LoginUrl loginUrl, - @JsonProperty("switch_inline_query") String switchInlineQuery, - @JsonProperty("switch_inline_query_current_chat") String switchInlineQueryCurrentChat, - @JsonProperty("switch_inline_query_chosen_chat") SwitchInlineQueryChosenChat switchInlineQueryChosenChat, - @JsonProperty("copy_text") CopyTextButton copyTextButton, - @JsonProperty("callback_game") CallbackGame callbackGame, - @JsonProperty("pay") Boolean pay - ) { - this.text = text; - this.url = url; - this.callbackData = callbackData; - this.webApp = webApp; - this.loginUrl = loginUrl; - this.switchInlineQuery = switchInlineQuery; - this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; - this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; - this.copyTextButton = copyTextButton; - this.callbackGame = callbackGame; - this.pay = pay; - } - - private InlineKeyboardButton(Builder builder) { - this.text = builder.text; - setUrl(builder.url); - setCallbackData(builder.callbackData); - setWebApp(builder.webApp); - setLoginUrl(builder.loginUrl); - setSwitchInlineQuery(builder.switchInlineQuery); - setSwitchInlineQueryCurrentChat(builder.switchInlineQueryCurrentChat); - setSwitchInlineQueryChosenChat(builder.switchInlineQueryChosenChat); - setCopyTextButton(builder.copyTextButton); - setCallbackGame(builder.callbackGame); - setPay(builder.pay); - } - - public InlineKeyboardButton(String text) { - this.text = text; - } - - public InlineKeyboardButton(String text, String data) { - this.text = text; - this.callbackData = data; - } - - @JsonIgnore - public String getText() { - return text; - } - - @JsonIgnore - public String getUrl() { - return url; - } - - @JsonIgnore - public String getCallbackData() { - return callbackData; - } - - @JsonIgnore - public WebAppInfo getWebApp() { - return webApp; - } - - @JsonIgnore - public LoginUrl getLoginUrl() { - return loginUrl; - } - - @JsonIgnore - public String getSwitchInlineQuery() { - return switchInlineQuery; - } - - @JsonIgnore - public String getSwitchInlineQueryCurrentChat() { - return switchInlineQueryCurrentChat; - } - - @JsonIgnore - public SwitchInlineQueryChosenChat getSwitchInlineQueryChosenChat() { - return switchInlineQueryChosenChat; - } - - @JsonIgnore - public CopyTextButton getCopyTextButton() { - return copyTextButton; - } - - @JsonIgnore - public CallbackGame getCallbackGame() { - return callbackGame; - } - - @JsonIgnore - public Boolean getPay() { - return pay; - } - - public void setUrl(String url) { - this.url = url; - } - - public void setCallbackData(String callbackData) { - this.callbackData = callbackData; - } - - public void setWebApp(WebAppInfo webApp) { - this.webApp = webApp; - } - - public void setLoginUrl(LoginUrl loginUrl) { - this.loginUrl = loginUrl; - } - - public void setSwitchInlineQuery(String switchInlineQuery) { - this.switchInlineQuery = switchInlineQuery; - } - - public void setSwitchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { - this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; - } - - public void setSwitchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { - this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; - } - - public void setCopyTextButton(CopyTextButton copyTextButton) { - this.copyTextButton = copyTextButton; - } - - public void setCallbackGame(CallbackGame callbackGame) { - this.callbackGame = callbackGame; - } - - public void setPay(Boolean pay) { - this.pay = pay; - } - - public static final class Builder { - private final String text; - private String url; - private String callbackData; - private WebAppInfo webApp; - private LoginUrl loginUrl; - private String switchInlineQuery; - private String switchInlineQueryCurrentChat; - private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; - private CopyTextButton copyTextButton; - private CallbackGame callbackGame; - private Boolean pay; - - public Builder(String text) { - this.text = text; - } - - public Builder pay(boolean pay) { - this.pay = pay; - return this; - } - - public Builder url(String url) { - this.url = url; - return this; - } - - public Builder callbackData(String callbackData) { - this.callbackData = callbackData; - return this; - } - - public Builder webApp(WebAppInfo webApp) { - this.webApp = webApp; - return this; - } - - public Builder loginUrl(LoginUrl loginUrl) { - this.loginUrl = loginUrl; - return this; - } - - public Builder switchInlineQuery(String switchInlineQuery) { - this.switchInlineQuery = switchInlineQuery; - return this; - } - - public Builder switchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { - this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; - return this; - } - - public Builder switchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat) { - this.switchInlineQueryChosenChat = switchInlineQueryChosenChat; - return this; - } - - public Builder copyTextButton(CopyTextButton copyTextButton) { - this.copyTextButton = copyTextButton; - return this; - } - - public Builder callbackGame(CallbackGame callbackGame) { - this.callbackGame = callbackGame; - return this; - } - - public InlineKeyboardButton build() { - return new InlineKeyboardButton(this); - } - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java deleted file mode 100644 index 34ff270..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardMarkup.java +++ /dev/null @@ -1,35 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.*; - -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) -public record InlineKeyboardMarkup( - @JsonProperty("inline_keyboard") InlineKeyboardRow... keyboard) implements ReplyMarkup { - - @JsonCreator - public InlineKeyboardMarkup(@JsonProperty("inline_keyboard") InlineKeyboardButton[][] keyboardButtons) { - this(convertToInlineKeyboardRow(keyboardButtons)); - } - - public InlineKeyboardMarkup(List inlineKeyboardRows) { - this(inlineKeyboardRows.toArray(new InlineKeyboardRow[0])); - } - - @JsonIgnore - private static InlineKeyboardRow[] convertToInlineKeyboardRow(InlineKeyboardButton[][] keyboardButtons) { - InlineKeyboardRow[] rows = new InlineKeyboardRow[keyboardButtons.length]; - for (int i = 0; i < keyboardButtons.length; i++) { - rows[i] = new InlineKeyboardRow(keyboardButtons[i]); - } - return rows; - } - - @JsonIgnore - public static InlineKeyboardMarkup ofSingleButton(InlineKeyboardButton button) { - return new InlineKeyboardMarkup(new InlineKeyboardRow(button)); - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java b/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java deleted file mode 100644 index cb1665e..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/InlineKeyboardRow.java +++ /dev/null @@ -1,69 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonValue; -import org.jetbrains.annotations.NotNull; - -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - - -public final class InlineKeyboardRow extends AbstractList { - - @JsonIgnore - private final ArrayList buttonsList = new ArrayList<>(); - - public InlineKeyboardRow() { - - } - - public InlineKeyboardButton remove(int i) { - return this.buttonsList.remove(i); - } - - @JsonIgnore - @Override - public void clear() { - this.buttonsList.clear(); - } - - @JsonIgnore - @Override - public int size() { - return this.buttonsList.size(); - } - - @JsonIgnore - @Override - public boolean addAll(@NotNull Collection buttons) { - return this.buttonsList.addAll(buttons); - } - - public void addAll(InlineKeyboardButton... buttons) { - this.buttonsList.addAll(List.of(buttons)); - } - - public InlineKeyboardRow(InlineKeyboardButton... buttons) { - this.buttonsList.addAll(List.of(buttons)); - } - - @JsonIgnore - @Override - public boolean add(InlineKeyboardButton button) { - return this.buttonsList.add(button); - } - - @JsonIgnore - @Override - public InlineKeyboardButton get(int i) { - return this.buttonsList.get(i); - } - - @JsonValue - public List buttons() { - return buttonsList; - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java b/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java deleted file mode 100644 index 2738525..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/InlineQuery.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record InlineQuery( - @JsonProperty("id") String id, - @JsonProperty("from") User from, - @JsonProperty("query") String query, - @JsonProperty("offset") String offset, - @JsonProperty("chat_type") String chatType, - @JsonProperty("location") Location location -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Invoice.java b/core/src/main/java/hdvtdev/telegram/objects/Invoice.java deleted file mode 100644 index 04b2ca1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Invoice.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Invoice( - @JsonProperty("title") String title, - @JsonProperty("description") String description, - @JsonProperty("start_parameter") String startParameter, - @JsonProperty("currency") String currency, - @JsonProperty("total_amount") int totalAmount -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java deleted file mode 100644 index 6e82940..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButton.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record KeyboardButton( - @JsonProperty("text") String text, - @JsonProperty("request_users") KeyboardButtonRequestUsers requestUsers, - @JsonProperty("request_chat") KeyboardButtonRequestChat requestChat, - @JsonProperty("request_contact") boolean requestContact, - @JsonProperty("request_location") boolean requestLocation, - @JsonProperty("request_poll") KeyboardButtonPollType requestPoll, - @JsonProperty("web_app") WebAppInfo webApp -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java deleted file mode 100644 index 3f6c38b..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonPollType.java +++ /dev/null @@ -1,12 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record KeyboardButtonPollType( - @JsonProperty("type") String type -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java deleted file mode 100644 index d5181f1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestChat.java +++ /dev/null @@ -1,22 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record KeyboardButtonRequestChat( - @JsonProperty("request_id") Integer requestId, - @JsonProperty("chat_is_channel") boolean chatIsChannel, - @JsonProperty("chat_is_forum") boolean chatIsForum, - @JsonProperty("chat_has_username") boolean chatHasUsername, - @JsonProperty("chat_is_created") boolean chatIsCreated, - @JsonProperty("user_administrator_rights") ChatAdministratorRights userAdministratorRights, - @JsonProperty("bot_administrator_rights") ChatAdministratorRights botAdministratorRights, - @JsonProperty("bot_is_member") boolean botIsMember, - @JsonProperty("request_title") boolean requestTitle, - @JsonProperty("request_username") boolean requestUsername, - @JsonProperty("request_photo") boolean requestPhoto -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java b/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java deleted file mode 100644 index 9f417c4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/KeyboardButtonRequestUsers.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record KeyboardButtonRequestUsers( - @JsonProperty("request_id") Integer requestId, - @JsonProperty("user_is_bot") boolean userIsBot, - @JsonProperty("user_is_premium") boolean userIsPremium, - @JsonProperty("max_quantity") Integer maxQuantity, - @JsonProperty("request_name") Boolean requestName, - @JsonProperty("request_username") Boolean requestUsername, - @JsonProperty("request_photo") Boolean requestPhoto -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java b/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java deleted file mode 100644 index 9aefc6e..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/LinkPreviewOptions.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record LinkPreviewOptions( - @JsonProperty("is_disabled") boolean isDisabled, - @JsonProperty("url") String url, - @JsonProperty("prefer_small_media") boolean preferSmallMedia, - @JsonProperty("prefer_large_media") boolean preferLargeMedia, - @JsonProperty("show_above_text") boolean showAboveText - -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Location.java b/core/src/main/java/hdvtdev/telegram/objects/Location.java deleted file mode 100644 index 23f669b..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Location.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Location( - @JsonProperty("latitude") float latitude, - @JsonProperty("longitude") float longitude, - @JsonProperty("horizontal_accuracy") float horizontalAccuracy, - @JsonProperty("live_period") int livePeriod, - @JsonProperty("heading") int heading, - @JsonProperty("proximity_alert_radius") int proximityAlertRadius -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java b/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java deleted file mode 100644 index 6fce8da..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/LoginUrl.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record LoginUrl( - @JsonProperty("url") String url, - @JsonProperty("forward_text") String forwardText, - @JsonProperty("bot_username") String botUsername, - @JsonProperty("request_write_access") boolean requestWriteAccess -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java b/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java deleted file mode 100644 index deb02df..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MaskPosition.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MaskPosition( - @JsonProperty("point") String point, - @JsonProperty("x_shift") float xShift, - @JsonProperty("y_shift") float yShift, - @JsonProperty("scale") float scale -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java deleted file mode 100644 index bb27697..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessage.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -@JsonDeserialize(using = MaybeInaccessibleMessageDeserializer.class) -public interface MaybeInaccessibleMessage { - long chatId(); - - Chat chat(); - - int messageId(); - - long date(); - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java b/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java deleted file mode 100644 index 44ecc07..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MaybeInaccessibleMessageDeserializer.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -import java.io.IOException; - -public class MaybeInaccessibleMessageDeserializer extends JsonDeserializer { - - @Override - public MaybeInaccessibleMessage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Message msg = p.getCodec().readValue(p, Message.class); - return msg.date() == 0 ? new InaccessibleMessage(msg.chat(), msg.messageId(), 0) : msg; - } -} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/objects/Message.java b/core/src/main/java/hdvtdev/telegram/objects/Message.java deleted file mode 100644 index 64ba755..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Message.java +++ /dev/null @@ -1,274 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Message( - @JsonProperty("message_id") int messageId, - @JsonProperty("message_thread_id") Long messageThreadId, - @JsonProperty("from") User user, - @JsonProperty("sender_chat") Chat senderChat, - @JsonProperty("sender_boost_count") Integer senderBoostCount, - @JsonProperty("sender_business_bot") User senderBusinessBot, - @JsonProperty("date") long date, - @JsonProperty("business_connection_id") String businessConnectionId, - @JsonProperty("chat") Chat chat, - @JsonProperty("forward_origin") MessageOrigin forwardOrigin, - @JsonProperty("is_topic_message") boolean isTopicMessage, - @JsonProperty("is_automatic_forward") boolean isAutomaticForward, - @JsonProperty("reply_to_message") Message replyToMessage, - @JsonProperty("external_reply") ExternalReplyInfo externalReply, - @JsonProperty("quote") TextQuote quote, - @JsonProperty("reply_to_story") Story replyToStory, - @JsonProperty("via_bot") User viaBot, - @JsonProperty("edit_date") long editDate, - @JsonProperty("has_protected_content") boolean hasProtectedContent, - @JsonProperty("is_from_offline") boolean isFromOnline, - @JsonProperty("media_group_id") String mediaGroupId, - @JsonProperty("author_signature") String authorSignature, - @JsonProperty("text") String text, - @JsonProperty("entities") MessageEntity[] entities, - @JsonProperty("link_preview_options") LinkPreviewOptions linkPreviewOptions, - @JsonProperty("effect_id") String effectId, - @JsonProperty("animation") Animation animation, - @JsonProperty("audio") Audio audio, - @JsonProperty("document") Document document, - @JsonProperty("paid_media") PaidMediaInfo paidMediaInfo, - @JsonProperty("photo") PhotoSize[] photo, - @JsonProperty("sticker") Sticker sticker, - @JsonProperty("story") Story story, - @JsonProperty("video") Video video, - @JsonProperty("video_note") VideoNote videoNote, - @JsonProperty("voice") Voice voice, - @JsonProperty("caption") String caption, - @JsonProperty("caption_entities") MessageEntity[] captionEntities, - @JsonProperty("show_caption_above_media") boolean showCaptionAboveMedia, - @JsonProperty("has_media_spoiler") boolean hasMediaSpoiler, - @JsonProperty("contact") Contact contact, - @JsonProperty("dice") Dice dice, - @JsonProperty("game") Game game, - @JsonProperty("poll") Poll poll, - @JsonProperty("venue") Venue venue, - @JsonProperty("location") Location location, - @JsonProperty("new_chat_members") User[] newChatMembers, - @JsonProperty("left_chat_member") User leftChatMember, - @JsonProperty("new_chat_title") String newChatTitle, - @JsonProperty("new_chat_photo") PhotoSize[] newChatPhoto, - @JsonProperty("delete_chat_photo") boolean deleteChatPhoto, - @JsonProperty("group_chat_created") boolean groupChatCreated, - @JsonProperty("supergroup_chat_created") boolean supergroupChatCreated, - @JsonProperty("channel_chat_created") boolean channelChatCreated, - @JsonProperty("message_auto_delete_timer_changed") MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged, - @JsonProperty("migrate_to_chat_id") Long migrateToChatId, - @JsonProperty("migrate_from_chat_id") Long migrateFromChatId, - @JsonProperty("pinned_message") MaybeInaccessibleMessage pinnedMessage, - @JsonProperty("invoice") Invoice invoice, - @JsonProperty("successful_payment") SuccessfulPayment successfulPayment, - @JsonProperty("refunded_payment") RefundedPayment refundedPayment, - @JsonProperty("users_shared") UsersShared usersShared, - @JsonProperty("chat_shared") ChatShared chatShared, - @JsonProperty("connected_website") String connectedWebsite, - @JsonProperty("write_access_allowed") WriteAccessAllowed writeAccessAllowed, - @JsonProperty("passport_data") PassportData passportData, - @JsonProperty("proximity_alert_triggered") ProximityAlertTriggered proximityAlertTriggered, - @JsonProperty("boost_added") ChatBoostAdded chatBoostAdded, - @JsonProperty("chat_background_set") ChatBackground chatBackground, - @JsonProperty("forum_topic_created") ForumTopicCreated forumTopicCreated, - @JsonProperty("forum_topic_edited") ForumTopicEdited forumTopicEdited, - @JsonProperty("forum_topic_closed") ForumTopicClosed forumTopicClosed, - @JsonProperty("forum_topic_reopened") ForumTopicReopened forumTopicReopened, - @JsonProperty("general_forum_topic_hidden") GeneralForumTopicHidden generalForumTopicHidden, - @JsonProperty("general_forum_topic_unhidden") GeneralForumTopicUnhidden generalForumTopicUnhidden, - @JsonProperty("giveaway_created") GiveawayCreated giveawayCreated, - @JsonProperty("giveaway") Giveaway giveaway, - @JsonProperty("giveaway_winners") GiveawayWinners giveawayWinners, - @JsonProperty("giveaway_completed") GiveawayCompleted giveawayCompleted, - @JsonProperty("video_chat_scheduled") VideoChatScheduled videoChatScheduled, - @JsonProperty("video_chat_started") VideoChatStarted videoChatStarted, - @JsonProperty("video_chat_ended") VideoChatEnded videoChatEnded, - @JsonProperty("video_chat_participants_invited") VideoChatParticipantsInvited videoChatParticipantsInvited, - @JsonProperty("web_app_data") WebAppData webAppData, - @JsonProperty("reply_markup") InlineKeyboardMarkup inlineKeyboardMarkup - -) implements MaybeInaccessibleMessage { - - public boolean hasMessageThreadId() { - return messageThreadId != null; - } - - public boolean hasSenderChat() { - return senderChat != null; - } - - public boolean hasSenderBoostCount() { - return senderBoostCount != null; - } - - public boolean hasSenderBusinessBot() { - return senderBusinessBot != null; - } - - public boolean hasBusinessConnectionId() { - return businessConnectionId != null; - } - - public boolean hasForwardOrigin() { - return forwardOrigin != null; - } - - public boolean hasReplyToMessage() { - return replyToMessage != null; - } - - public boolean hasExternalReply() { - return externalReply != null; - } - - public boolean hasQuote() { - return quote != null; - } - - public boolean hasReplyToStory() { - return replyToStory != null; - } - - public boolean hasViaBot() { - return viaBot != null; - } - - public boolean hasEditDate() { - return editDate != 0; - } - - public boolean hasMediaGroupId() { - return mediaGroupId != null; - } - - public boolean hasAuthorSignature() { - return authorSignature != null; - } - - public boolean hasText() { - return text != null; - } - - public boolean hasEntities() { - return entities != null; - } - - public boolean hasLinkPreviewOptions() { - return linkPreviewOptions != null; - } - - public boolean hasEffectId() { - return effectId != null; - } - - public boolean hasAnimation() { - return animation != null; - } - - public boolean hasAudio() { - return audio != null; - } - - public boolean hasDocument() { - return document != null; - } - - public boolean hasPaidMediaInfo() { - return paidMediaInfo != null; - } - - public boolean hasPhoto() { - return photo != null; - } - - public boolean hasSticker() { - return sticker != null; - } - - public boolean hasStory() { - return story != null; - } - - public boolean hasVideo() { - return video != null; - } - - public boolean hasVideoNote() { - return videoNote != null; - } - - public boolean hasVoice() { - return voice != null; - } - - public boolean hasCaption() { - return caption != null; - } - - public boolean hasCaptionEntities() { - return captionEntities != null; - } - - public boolean hasContact() { - return contact != null; - } - - public boolean hasDice() { - return dice != null; - } - - public boolean hasGame() { - return game != null; - } - - public boolean hasPoll() { - return poll != null; - } - - public boolean hasVenue() { - return venue != null; - } - - public boolean hasLocation() { - return location != null; - } - - public boolean hasNewChatMembers() { - return newChatMembers != null; - } - - public boolean hasLeftChatMember() { - return leftChatMember != null; - } - - public boolean hasNewChatTitle() { - return newChatTitle != null; - } - - public boolean hasNewChatPhoto() { - return newChatPhoto != null; - } - - public boolean hasMessageAutoDeleteTimerChanged() { - return messageAutoDeleteTimerChanged != null; - } - - public boolean hasMigrateToChatId() { - return migrateToChatId != null; - } - - public boolean hasMigrateFromChatId() { - return migrateFromChatId != null; - } - - @Override - public long chatId() { - return this.chat.id(); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java b/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java deleted file mode 100644 index d2b30a0..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageAutoDeleteTimerChanged.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageAutoDeleteTimerChanged(@JsonProperty("message_auto_delete_time") long messageAutoDeleteTime) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java b/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java deleted file mode 100644 index 68f6bb5..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageEntity.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageEntity( - @JsonProperty("type") String type, - @JsonProperty("offset") int offset, - @JsonProperty("length") int length, - @JsonProperty("url") String url, - @JsonProperty("user") User user, - @JsonProperty("language") String language, - @JsonProperty("custom_emoji_id") String customEmojiId -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java deleted file mode 100644 index 4716239..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageOrigin.java +++ /dev/null @@ -1,19 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = MessageOriginUser.class, name = "user"), - @JsonSubTypes.Type(value = MessageOriginHiddenUser.class, name = "hidden_user"), - @JsonSubTypes.Type(value = MessageOriginChat.class, name = "chat"), - @JsonSubTypes.Type(value = MessageOriginChannel.class, name = "channel") -}) -public interface MessageOrigin { - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java deleted file mode 100644 index 73903e3..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChannel.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageOriginChannel( - @JsonProperty("type") String type, - @JsonProperty("date") long date, - @JsonProperty("chat") Chat chat, - @JsonProperty("message_id") long messageId, - @JsonProperty("author_signature") String authorSignature -) implements MessageOrigin { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java deleted file mode 100644 index 558e3a7..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginChat.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageOriginChat( - @JsonProperty("type") String type, - @JsonProperty("date") long date, - @JsonProperty("sender_chat") Chat senderChat, - @JsonProperty("author_signature") String authorSignature -) implements MessageOrigin { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java deleted file mode 100644 index ea5b8ca..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginHiddenUser.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageOriginHiddenUser( - @JsonProperty("type") String type, - @JsonProperty("date") long date, - @JsonProperty("sender_user_name") String senderUserName -) implements MessageOrigin { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java b/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java deleted file mode 100644 index 1b3614e..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageOriginUser.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageOriginUser( - @JsonProperty("type") String type, - @JsonProperty("date") long date, - @JsonProperty("sender_user") User senderUser -) implements MessageOrigin { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java deleted file mode 100644 index ef74f64..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionCountUpdated.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageReactionCountUpdated( - @JsonProperty("chat") Chat chat, - @JsonProperty("message_id") long messageId, - @JsonProperty("date") long date, - @JsonProperty("reactions") ReactionCount[] reactions -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java b/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java deleted file mode 100644 index fea1ccc..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/MessageReactionUpdated.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record MessageReactionUpdated( - @JsonProperty("chat") Chat chat, - @JsonProperty("message_id") long messageId, - @JsonProperty("user") User user, - @JsonProperty("actor_chat") Chat actorChat, - @JsonProperty("date") long date, - @JsonProperty("old_reaction") ReactionType[] oldReaction, - @JsonProperty("new_reaction") ReactionType[] newReaction -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java b/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java deleted file mode 100644 index f214e41..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/OrderInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record OrderInfo( - @JsonProperty("name") String name, - @JsonProperty("phone_number") String phoneNumber, - @JsonProperty("email") String email, - @JsonProperty("shipping_address") ShippingAddress shippingAddress -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java deleted file mode 100644 index 73703a3..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMedia.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = PaidMediaPreview.class, name = "preview"), - @JsonSubTypes.Type(value = PaidMediaPhoto.class, name = "photo"), - @JsonSubTypes.Type(value = PaidMediaVideo.class, name = "video") -}) -public interface PaidMedia { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java deleted file mode 100644 index ff95de6..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PaidMediaInfo( - @JsonProperty("star_count") int startCount, - @JsonProperty("paid_media") PaidMedia[] paidMedia -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java deleted file mode 100644 index a78e5b9..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPhoto.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PaidMediaPhoto( - @JsonProperty("type") String type, - @JsonProperty("photo") PhotoSize[] photo -) implements PaidMedia { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java deleted file mode 100644 index f763a38..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPreview.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PaidMediaPreview( - @JsonProperty("type") String type, - @JsonProperty("width") int width, - @JsonProperty("height") int height, - @JsonProperty("duration") int duration -) implements PaidMedia { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java deleted file mode 100644 index 32475dd..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaPurchased.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PaidMediaPurchased( - @JsonProperty("from") User from, - @JsonProperty("paid_media_payload") String paidMediaPayload -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java b/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java deleted file mode 100644 index dc65b58..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PaidMediaVideo.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PaidMediaVideo( - @JsonProperty("type") String type, - @JsonProperty("video") Video video -) implements PaidMedia { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PassportData.java b/core/src/main/java/hdvtdev/telegram/objects/PassportData.java deleted file mode 100644 index 6633ae8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PassportData.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PassportData( - @JsonProperty("data") EncryptedPassportElement[] data, - @JsonProperty("credentials") EncryptedCredentials credentials -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java b/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java deleted file mode 100644 index 6247580..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PassportFile.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PassportFile( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("file_size") long fileSize, - @JsonProperty("file_date") long fileDate -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java b/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java deleted file mode 100644 index 6fcf9ad..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PhotoSize.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PhotoSize( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("width") int width, - @JsonProperty("height") int height, - @JsonProperty("file_size") long file_size -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Poll.java b/core/src/main/java/hdvtdev/telegram/objects/Poll.java deleted file mode 100644 index 43637d8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Poll.java +++ /dev/null @@ -1,25 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Poll( - @JsonProperty("id") String id, - @JsonProperty("question") String question, - @JsonProperty("question_entities") MessageEntity[] questionEntities, - @JsonProperty("options") PollOption[] options, - @JsonProperty("total_voter_count") int totalVoterCount, - @JsonProperty("is_closed") boolean isClosed, - @JsonProperty("is_anonymous") boolean isAnonymous, - @JsonProperty("type") String type, - @JsonProperty("allows_multiple_answers") boolean allowMultipleAnswers, - @JsonProperty("correct_option_id") int correctOptionId, - @JsonProperty("explanation") String explanation, - @JsonProperty("explanation_entities") MessageEntity[] explanationEntities, - @JsonProperty("open_period") long openPeriod, - @JsonProperty("close_date") long closeDate -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java b/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java deleted file mode 100644 index beea375..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PollAnswer.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PollAnswer( - @JsonProperty("poll_id") String pollId, - @JsonProperty("voter_chat") Chat voterChat, - @JsonProperty("user") User user, - @JsonProperty("option_ids") int[] optionsIds -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PollOption.java b/core/src/main/java/hdvtdev/telegram/objects/PollOption.java deleted file mode 100644 index 2616815..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PollOption.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PollOption( - @JsonProperty("text") String text, - @JsonProperty("text_entities") MessageEntity[] textEntities, - @JsonProperty("voter_count") int voterCount -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java b/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java deleted file mode 100644 index d42e5c4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/PreCheckoutQuery.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record PreCheckoutQuery( - @JsonProperty("id") String id, - @JsonProperty("from") User from, - @JsonProperty("currency") String currency, - @JsonProperty("total_amount") int totalAmount, - @JsonProperty("invoice_payload") String invoicePayload, - @JsonProperty("shipping_option_id") String shippingOptionId, - @JsonProperty("order_info") OrderInfo orderInfo -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java b/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java deleted file mode 100644 index 303c3b8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ProximityAlertTriggered.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ProximityAlertTriggered( - @JsonProperty("traveler") User traveler, - @JsonProperty("watcher") User watcher, - @JsonProperty("distance") int distance -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java deleted file mode 100644 index 9ace7e4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReactionCount.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReactionCount( - @JsonProperty("type") ReactionType type, - @JsonProperty("total_count") int totalCount -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java deleted file mode 100644 index 76aaff4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReactionType.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ReactionTypeEmoji.class, name = "emoji"), - @JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = "custom_emoji"), - @JsonSubTypes.Type(value = ReactionTypePaid.class, name = "paid") -}) -public interface ReactionType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java deleted file mode 100644 index 2b5ee8f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeCustomEmoji.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReactionTypeCustomEmoji( - @JsonProperty("type") String type, - @JsonProperty("custom_emoji_id") String customEmojiId -) implements ReactionType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java deleted file mode 100644 index a6b31f2..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypeEmoji.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReactionTypeEmoji( - @JsonProperty("type") String type, - @JsonProperty("emoji") String emoji -) implements ReactionType { - public ReactionTypeEmoji(String emoji) { - this("emoji", emoji); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java b/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java deleted file mode 100644 index cc639b8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReactionTypePaid.java +++ /dev/null @@ -1,12 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReactionTypePaid( - @JsonProperty("type") String type -) implements ReactionType { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java b/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java deleted file mode 100644 index 3c98a87..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/RefundedPayment.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record RefundedPayment( - @JsonProperty("currency") String currency, - @JsonProperty("total_amount") int totalAmount, - @JsonProperty("invoice_payload") String invoicePayload, - @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, - @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java deleted file mode 100644 index e34dec0..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardMarkup.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReplyKeyboardMarkup( - @JsonProperty("keyboard") KeyboardButton[][] keyboard, - @JsonProperty("is_persistent") boolean isPersistent, - @JsonProperty("resize_keyboard") boolean resizeKeyboard, - @JsonProperty("one_time_keyboard") boolean oneTimeKeyboard, - @JsonProperty("input_field_placeholder") String inputFieldPlaceholder, - @JsonProperty("selective") boolean selective -) implements ReplyMarkup { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java deleted file mode 100644 index cf1c8f9..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReplyKeyboardRemove.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReplyKeyboardRemove( - @JsonProperty("remove_keyboard") boolean removeKeyboard, - @JsonProperty("selective") boolean selective -) implements ReplyMarkup { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java deleted file mode 100644 index 42abbbb..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReplyMarkup.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.DEDUCTION, - defaultImpl = Void.class -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ReplyKeyboardMarkup.class), - @JsonSubTypes.Type(value = InlineKeyboardMarkup.class), - @JsonSubTypes.Type(value = ReplyKeyboardRemove.class) -}) -public interface ReplyMarkup { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java b/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java deleted file mode 100644 index cf10443..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ReplyParameters.java +++ /dev/null @@ -1,28 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ReplyParameters( - @JsonProperty("message_id") long messageId, - @JsonProperty("chat_id") String chatId, - @JsonProperty("allow_sending_without_reply") boolean allowSendingWithoutReply, - @JsonProperty("quote") String quote, - @JsonProperty("quote_parse_mode") String quoteParseMode, - @JsonProperty("quote_entities") MessageEntity[] quoteEntities, - @JsonProperty("quote_position") Integer quotePosition -) { - - public ReplyParameters(long messageId, String chatId) { - this(messageId, chatId, false, null, null, null, null); - } - - public ReplyParameters(long messageId, long chatId) { - this(messageId, String.valueOf(chatId)); - } - - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java b/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java deleted file mode 100644 index 540c0cb..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/SharedUser.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record SharedUser( - @JsonProperty("user_id") long userId, - @JsonProperty("first_name") String firstName, - @JsonProperty("last_name") String lastName, - @JsonProperty("username") String username, - @JsonProperty("photo") PhotoSize[] photo -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java b/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java deleted file mode 100644 index a894bc9..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ShippingAddress.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ShippingAddress( - @JsonProperty("country_code") String countryCode, - @JsonProperty("state") String state, - @JsonProperty("city") String city, - @JsonProperty("street_line1") String firstStreetLine, - @JsonProperty("street_line2") String secondStreetLine, - @JsonProperty("post_code") String postCode -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java b/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java deleted file mode 100644 index 6916978..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/ShippingQuery.java +++ /dev/null @@ -1,15 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record ShippingQuery( - @JsonProperty("id") String id, - @JsonProperty("from") User from, - @JsonProperty("invoice_payload") String invoicePayload, - @JsonProperty("shipping_address") ShippingAddress shippingAddress -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Sticker.java b/core/src/main/java/hdvtdev/telegram/objects/Sticker.java deleted file mode 100644 index 859a71a..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Sticker.java +++ /dev/null @@ -1,26 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Sticker( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("type") String type, - @JsonProperty("width") int width, - @JsonProperty("height") int height, - @JsonProperty("is_animated") boolean isAnimated, - @JsonProperty("is_video") boolean isVideo, - @JsonProperty("thumbnail") PhotoSize thumbnail, - @JsonProperty("emoji") String emoji, - @JsonProperty("set_name") String setName, - @JsonProperty("premium_animation") TelegramFile premiumAnimation, - @JsonProperty("mask_position") MaskPosition maskPosition, - @JsonProperty("custom_emoji_id") String customEmojiId, - @JsonProperty("needs_repairing") boolean needsRepairing, - @JsonProperty("file_size") long fileSize -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Story.java b/core/src/main/java/hdvtdev/telegram/objects/Story.java deleted file mode 100644 index 518583e..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Story.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Story( - @JsonProperty("chat") Chat chat, - @JsonProperty("id") long id -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java b/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java deleted file mode 100644 index a4e2029..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/SuccessfulPayment.java +++ /dev/null @@ -1,21 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record SuccessfulPayment( - @JsonProperty("currency") String currency, - @JsonProperty("total_amount") int totalAmount, //price - @JsonProperty("invoice_payload") String invoicePayload, - @JsonProperty("subscription_expiration_date") long subscriptionExpirationDate, - @JsonProperty("is_recurring") boolean isRecurring, - @JsonProperty("is_first_recurring") boolean isFirstRecurring, - @JsonProperty("shipping_option_id") String shippingOptionId, - @JsonProperty("order_info") OrderInfo orderInfo, - @JsonProperty("telegram_payment_charge_id") String telegramPaymentChargeId, - @JsonProperty("provider_payment_charge_id") String providerPaymentChargeId -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java b/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java deleted file mode 100644 index 42282c6..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/SwitchInlineQueryChosenChat.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record SwitchInlineQueryChosenChat( - @JsonProperty("query") String query, - @JsonProperty("allow_user_chats") boolean allowUserChats, - @JsonProperty("allow_bot_chats") boolean allowBotChats, - @JsonProperty("allow_group_chats") boolean allowGroupChats, - @JsonProperty("allow_channel_chats") boolean allowChannelChats -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java b/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java deleted file mode 100644 index 2f4f403..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/TelegramFile.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName("file") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record TelegramFile( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("file_size") long fileSize, - @JsonProperty("file_path") String filePath //link to file -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java b/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java deleted file mode 100644 index 11ccc52..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/TextQuote.java +++ /dev/null @@ -1,11 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record TextQuote(String text, MessageEntity[] entities, int position, - @JsonProperty("is_manual") boolean isManual) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Update.java b/core/src/main/java/hdvtdev/telegram/objects/Update.java deleted file mode 100644 index f1f460b..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Update.java +++ /dev/null @@ -1,139 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Update( - @JsonProperty("update_id") long updateId, - @JsonProperty("message") Message message, - @JsonProperty("edited_message") Message editedMessage, - @JsonProperty("channel_post") Message channelPost, - @JsonProperty("edited_channel_post") Message editedChannelPost, - @JsonProperty("business_connection") BusinessConnection businessConnection, - @JsonProperty("business_message") Message businessMessage, - @JsonProperty("edited_business_message") Message editedBusinessMessage, - @JsonProperty("deleted_business_messages") BusinessMessagesDeleted businessMessagesDeleted, - @JsonProperty("message_reaction") MessageReactionUpdated messageReaction, - @JsonProperty("message_reaction_count") MessageReactionCountUpdated messageReactionCount, - @JsonProperty("inline_query") InlineQuery inlineQuery, - @JsonProperty("chosen_inline_result") ChosenInlineResult chosenInlineResult, - @JsonProperty("callback_query") CallbackQuery callbackQuery, - @JsonProperty("shipping_query") ShippingQuery shippingQuery, - @JsonProperty("pre_checkout_query") PreCheckoutQuery preCheckoutQuery, - @JsonProperty("purchased_paid_media") PaidMediaPurchased paidMediaPurchased, - @JsonProperty("poll") Poll poll, - @JsonProperty("poll_answer") PollAnswer pollAnswer, - @JsonProperty("my_chat_member") ChatMemberUpdated myChatMember, - @JsonProperty("chat_member") ChatMemberUpdated chatMember, - @JsonProperty("chat_join_request") ChatJoinRequest chatJoinRequest, - @JsonProperty("chat_boost") ChatBoostUpdated chatBoost, - @JsonProperty("removed_chat_boost") ChatBoostRemoved chatBoostRemoved -) { - - public boolean hasMessage() { - return this.message != null; - } - - public boolean hasEditedMessage() { - return this.editedMessage != null; - } - - public boolean hasChannelPost() { - return this.channelPost != null; - } - - public boolean hasEditedChannelPost() { - return this.editedChannelPost != null; - } - - public boolean hasBusinessConnection() { - return this.businessConnection != null; - } - - public boolean hasBusinessMessage() { - return this.businessMessage != null; - } - - public boolean hasEditedBusinessMessage() { - return this.editedBusinessMessage != null; - } - - public boolean hasDeletedBusinessMessages() { - return this.businessMessagesDeleted != null; - } - - public boolean hasMessageReaction() { - return this.messageReaction != null; - } - - public boolean hasMessageReactionCount() { - return this.messageReactionCount != null; - } - - public boolean hasInlineQuery() { - return this.inlineQuery != null; - } - - public boolean hasChosenInlineResult() { - return this.chosenInlineResult != null; - } - - public boolean hasCallbackQuery() { - return this.callbackQuery != null; - } - - public boolean hasShippingQuery() { - return this.shippingQuery != null; - } - - public boolean hasPreCheckoutQuery() { - return this.preCheckoutQuery != null; - } - - public boolean hasPurchasedPaidMedia() { - return this.paidMediaPurchased != null; - } - - public boolean hasPoll() { - return this.poll != null; - } - - public boolean hasPollAnswer() { - return this.pollAnswer != null; - } - - public boolean hasMyChatMember() { - return this.myChatMember != null; - } - - public boolean hasChatMember() { - return this.chatMember != null; - } - - public boolean hasChatJoinRequest() { - return this.chatJoinRequest != null; - } - - public boolean hasChatBoost() { - return this.chatBoost != null; - } - - public boolean hasRemovedChatBoost() { - return this.chatBoostRemoved != null; - } - - public Optional getAnyText() { - if (hasMessage()) { - if (message.hasText()) return Optional.of(message.text()); - if (message.hasCaption()) return Optional.of(message.caption()); - } - return Optional.empty(); - } - -} - diff --git a/core/src/main/java/hdvtdev/telegram/objects/User.java b/core/src/main/java/hdvtdev/telegram/objects/User.java deleted file mode 100644 index c202248..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/User.java +++ /dev/null @@ -1,62 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record User( - @JsonProperty("id") long id, - @JsonProperty("is_bot") boolean isBot, - @JsonProperty("first_name") String firstName, - @JsonProperty("last_name") String lastName, - @JsonProperty("username") String username, - @JsonProperty("language_code") String languageCode, - @JsonProperty("is_premium") boolean isPremium, - @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu -) { - - public boolean hasLastName() { - return this.lastName != null; - } - - public boolean hasUsername() { - return this.username != null; - } - - public boolean hasLanguageCode() { - return this.languageCode != null; - } - - public record Bot( - @JsonProperty("id") long id, - @JsonProperty("is_bot") Boolean isBot, - @JsonProperty("first_name") String firstName, - @JsonProperty("last_name") String lastName, - @JsonProperty("username") String username, - @JsonProperty("language_code") String languageCode, - @JsonProperty("is_premium") boolean isPremium, - @JsonProperty("added_to_attachment_menu") boolean addedToAttachmentMenu, - @JsonProperty("can_join_groups") boolean canJoinGroups, - @JsonProperty("can_read_all_group_messages") boolean canReadAllGroupMessages, - @JsonProperty("supports_inline_queries") boolean supportsInlineQueries, - @JsonProperty("can_connect_to_business") boolean canConnectToBusiness, - @JsonProperty("has_main_web_app") boolean hasMainWebApp - ) { - - public boolean hasLastName() { - return this.lastName != null; - } - - public boolean hasUsername() { - return this.username != null; - } - - public boolean hasLanguageCode() { - return this.languageCode != null; - } - - - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java b/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java deleted file mode 100644 index 4fe05e1..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/UsersShared.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record UsersShared( - @JsonProperty("request_id") int requestId, - @JsonProperty("users") SharedUser[] users -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Venue.java b/core/src/main/java/hdvtdev/telegram/objects/Venue.java deleted file mode 100644 index df26408..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Venue.java +++ /dev/null @@ -1,18 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Venue( - @JsonProperty("location") Location location, - @JsonProperty("title") String title, - @JsonProperty("address") String address, - @JsonProperty("foursquare_id") String foursquareId, - @JsonProperty("foursquare_type") String foursquareType, - @JsonProperty("google_place_id") String googlePlaceId, - @JsonProperty("google_place_type") String googlePlaceType -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Video.java b/core/src/main/java/hdvtdev/telegram/objects/Video.java deleted file mode 100644 index 8ff8749..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Video.java +++ /dev/null @@ -1,22 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Video( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("width") int width, - @JsonProperty("height") int height, - @JsonProperty("duration") int duration, - @JsonProperty("thumbnail") PhotoSize thumbnail, - @JsonProperty("cover") PhotoSize[] cover, - @JsonProperty("start_timestamp") int startTimestamp, - @JsonProperty("file_name") String fileName, - @JsonProperty("mime_type") String mimeType, - @JsonProperty("file_size") long fileSize -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java deleted file mode 100644 index 4b44303..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/VideoChatEnded.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record VideoChatEnded(@JsonProperty("duration") long duration) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java deleted file mode 100644 index 915409f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/VideoChatParticipantsInvited.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record VideoChatParticipantsInvited(@JsonProperty("users") User[] users) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java deleted file mode 100644 index 681892f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/VideoChatScheduled.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record VideoChatScheduled(@JsonProperty("start_date") long startDate) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java b/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java deleted file mode 100644 index db138ef..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/VideoChatStarted.java +++ /dev/null @@ -1,9 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record VideoChatStarted() { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java b/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java deleted file mode 100644 index f328034..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/VideoNote.java +++ /dev/null @@ -1,17 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record VideoNote( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("length") long length, - @JsonProperty("duration") int duration, - @JsonProperty("thumbnail") PhotoSize thumbnail, - @JsonProperty("file_size") long fileSize -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/Voice.java b/core/src/main/java/hdvtdev/telegram/objects/Voice.java deleted file mode 100644 index 1ad4777..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/Voice.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record Voice( - @JsonProperty("file_id") String fileId, - @JsonProperty("file_unique_id") String fileUniqueId, - @JsonProperty("duration") int duration, - @JsonProperty("mime_type") String mimeType, - @JsonProperty("file_size") long fileSize -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java b/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java deleted file mode 100644 index 1b7e9e4..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/WebAppData.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record WebAppData(String data, @JsonProperty("button_text") String buttonText) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java b/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java deleted file mode 100644 index ada9c9d..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/WebAppInfo.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record WebAppInfo(@JsonProperty("url") String url) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java b/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java deleted file mode 100644 index 47b2777..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/WriteAccessAllowed.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record WriteAccessAllowed( - @JsonProperty("from_request") boolean fromRequest, - @JsonProperty("web_app_name") String webAppName, - @JsonProperty("from_attachment_menu") boolean fromAttachmentMenu -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java deleted file mode 100644 index 5d030d8..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommand.java +++ /dev/null @@ -1,13 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommand( - @JsonProperty("command") String name, - @JsonProperty("description") String description -) { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java deleted file mode 100644 index c1fad84..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScope.java +++ /dev/null @@ -1,22 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type" -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = BotCommandScopeDefault.class, name = "default"), - @JsonSubTypes.Type(value = BotCommandScopeAllPrivateChats.class, name = "all_private_chats"), - @JsonSubTypes.Type(value = BotCommandScopeAllGroupChats.class, name = "all_group_chats"), - @JsonSubTypes.Type(value = BotCommandScopeAllChatAdministrators.class, name = "all_chat_administrators"), - @JsonSubTypes.Type(value = BotCommandScopeChat.class, name = "chat"), - @JsonSubTypes.Type(value = BotCommandScopeChatAdministrators.class, name = "chat_administrators"), - @JsonSubTypes.Type(value = BotCommandScopeChatMember.class, name = "chat_member") -}) -public interface BotCommandScope { - String type(); -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java deleted file mode 100644 index dda2c07..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllChatAdministrators.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeAllChatAdministrators(@JsonProperty("type") String type) implements BotCommandScope { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java deleted file mode 100644 index 593fe3c..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllGroupChats.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeAllGroupChats(@JsonProperty("type") String type) implements BotCommandScope { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java deleted file mode 100644 index 4b1b44f..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeAllPrivateChats.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeAllPrivateChats(@JsonProperty("type") String type) implements BotCommandScope { -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java deleted file mode 100644 index 54cb0c7..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChat.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeChat(@JsonProperty("type") String type, - @JsonProperty("chat_id") String chatId) implements BotCommandScope { - public BotCommandScopeChat(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { - this(type, String.valueOf(chatId)); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java deleted file mode 100644 index 74a96d0..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatAdministrators.java +++ /dev/null @@ -1,14 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeChatAdministrators(@JsonProperty("type") String type, - @JsonProperty("chat_id") String chatId) implements BotCommandScope { - public BotCommandScopeChatAdministrators(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId) { - this(type, String.valueOf(chatId)); - } -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java deleted file mode 100644 index c89d343..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeChatMember.java +++ /dev/null @@ -1,27 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeChatMember( - @JsonProperty("type") String type, - @JsonProperty("chat_id") String chatId, - @JsonProperty("user_id") long userId -) implements BotCommandScope { - - public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") long userId) { - this(type, String.valueOf(chatId), userId); - } - - public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") long chatId, @JsonProperty("user_id") String userId) { - this(type, String.valueOf(chatId), Long.parseLong(userId)); - } - - public BotCommandScopeChatMember(@JsonProperty("type") String type, @JsonProperty("chat_id") String chatId, @JsonProperty("user_id") String userId) { - this(type, chatId, Long.parseLong(userId)); - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java b/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java deleted file mode 100644 index 817b3fe..0000000 --- a/core/src/main/java/hdvtdev/telegram/objects/bot/BotCommandScopeDefault.java +++ /dev/null @@ -1,10 +0,0 @@ -package hdvtdev.telegram.objects.bot; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public record BotCommandScopeDefault(@JsonProperty("type") String type) implements BotCommandScope { -} diff --git a/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java b/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java deleted file mode 100644 index 3bafd11..0000000 --- a/core/src/main/java/hdvtdev/telegram/util/ClassFinder.java +++ /dev/null @@ -1,136 +0,0 @@ -package hdvtdev.telegram.util; - -import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler; -import hdvtdev.telegram.annotations.handlers.TextMessageHandler; -import hdvtdev.telegram.objects.CallbackQuery; -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.Update; - -import java.io.File; -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; -import java.security.CodeSource; -import java.util.*; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -public abstract class ClassFinder { - - private static final Set> annotationsToSearch = Set.of(TextMessageHandler.class, CallbackQueryHandler.class); - private static final Set> methodsArgumentType = Set.of(Message.class, Update.class, CallbackQuery.class); - - private static ErrorHandler errorHandler; - - public static Map, Map> getClasses() { - - Map, Map> allMethods = new HashMap<>(); - annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); - - CodeSource codeSource = ClassFinder.class.getProtectionDomain().getCodeSource(); - if (codeSource != null) { - try { - String path = codeSource.getLocation().toURI().getPath(); - File file = new File(URLDecoder.decode(path, StandardCharsets.UTF_8)); - - if (file.isFile() && file.getName().endsWith(".jar")) { - processJar(file, allMethods); - } else if (file.isDirectory()) { - processDirectory(file, "", allMethods); - } - } catch (Exception e) { - return Map.of(); - } - } - - return Collections.unmodifiableMap(allMethods); - } - - private static void processDirectory(File directory, String packageName, Map, Map> methods) { - File[] files = directory.listFiles(); - if (files == null) return; - - for (File file : files) { - if (file.isDirectory()) { - processDirectory(file, packageName + file.getName() + ".", methods); - } else if (file.getName().endsWith(".class")) { - - String className = packageName + file.getName().replace(".class", ""); - loadClass(className, methods); - } - } - } - - private static void processJar(File jarFile, Map, Map> methods) { - try (JarFile jar = new JarFile(jarFile)) { - Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - if (entry.getName().endsWith(".class")) { - String className = entry.getName() - .replace("/", ".") - .replace(".class", ""); - - loadClass(className, methods); - } - } - } catch (IOException ignored) { - } - } - - public static Map, Map> localScan(Class cls) { - Map, Map> allMethods = new HashMap<>(); - annotationsToSearch.forEach(annotation -> allMethods.put(annotation, new HashMap<>())); - loadClass(cls.getName(), allMethods); - return allMethods; - } - - - private static void loadClass(String className, Map, Map> methods) { - try { - Class c = Class.forName(className); - - for (Method method : c.getDeclaredMethods()) { - - Class[] parameters = method.getParameterTypes(); - - if (parameters.length != 0 && !methodsArgumentType.contains(parameters[0])) { - continue; - } - - if (method.isAnnotationPresent(CallbackQueryHandler.class)) { - if (Modifier.isStatic(method.getModifiers())) { - for (String value : method.getAnnotation(CallbackQueryHandler.class).value()) { - methods.get(CallbackQueryHandler.class).put(value, new InvokeMethod(method, parameters[0])); - } - } else - System.err.println(method + " is annotated with @CallbackQueryHandler, but it is not static. For the annotation to work, the method must be static."); - } - - if (method.isAnnotationPresent(TextMessageHandler.class)) { - if (Modifier.isStatic(method.getModifiers())) { - for (String value : method.getAnnotation(TextMessageHandler.class).value()) { - methods.get(TextMessageHandler.class).put(value, new InvokeMethod(method, parameters[0])); - } - } else - System.err.println(method + " is annotated with @TextMessageHandler, but it is not static. For the annotation to work, the method must be static."); - } - - } - } catch (NoClassDefFoundError | UnsupportedClassVersionError | ClassNotFoundException e) { - if (errorHandler != null) errorHandler.onError(e); - } - } - - public void setErrorHandler(ErrorHandler errorHandler) { - ClassFinder.errorHandler = errorHandler; - } - - public interface ErrorHandler { - void onError(Throwable throwable); - } - -} diff --git a/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java b/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java deleted file mode 100644 index e30980a..0000000 --- a/core/src/main/java/hdvtdev/telegram/util/InvokeMethod.java +++ /dev/null @@ -1,7 +0,0 @@ -package hdvtdev.telegram.util; - -import java.lang.reflect.Method; - -public record InvokeMethod(Method method, Class parameterType) { - -} diff --git a/core/src/main/java/hdvtdev/telegram/util/ParseMode.java b/core/src/main/java/hdvtdev/telegram/util/ParseMode.java deleted file mode 100644 index 3837775..0000000 --- a/core/src/main/java/hdvtdev/telegram/util/ParseMode.java +++ /dev/null @@ -1,7 +0,0 @@ -package hdvtdev.telegram.util; - -public enum ParseMode { - MARKDOWN, - MARKDOWNV2, - HTML -} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/util/Util.java b/core/src/main/java/hdvtdev/telegram/util/Util.java deleted file mode 100644 index 457268e..0000000 --- a/core/src/main/java/hdvtdev/telegram/util/Util.java +++ /dev/null @@ -1,98 +0,0 @@ -package hdvtdev.telegram.util; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -public class Util { - - public static void pretty(Path filePath) { - try { - if (filePath.toString().contains("InlineKeyboard")) return; - List lines = Files.readAllLines(filePath); - HashSet linesSet = new HashSet<>(lines); - ArrayList res = new ArrayList<>(lines.size()); - - if (!linesSet.contains("import com.fasterxml.jackson.annotation.JsonProperty;")) - lines.add(2, "import com.fasterxml.jackson.annotation.JsonProperty;"); - boolean inRecord = false; - for (String line : lines) { - if (line.contains("@JsonProperty\\(.*?\\)")) { - res.add(line); - continue; - } - if (!line.contains("@") && !line.contains("class") && !line.contains("=")) { - if (line.contains("record")) { - String bufferLine = line; - if (bufferLine.replaceAll("[{}]", "").trim().endsWith(")")) { - if (bufferLine.contains("()")) { - res.add(line); - continue; - } - bufferLine = bufferLine.split("\\(", 2)[1]; - bufferLine = bufferLine.split("\\)", 2)[0]; - - if (bufferLine.contains(",")) { - for (String element : bufferLine.split(",")) { - element = element.strip(); - String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); - line = line.replace(element, ann); - } - } else { - String element = bufferLine.strip(); - if (element.isEmpty()) continue; - String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1], element); - line = line.replace(element, ann); - } - } else { - inRecord = true; - res.add(line); - continue; - } - } - if (inRecord) { - if (line.contains("{") && line.contains(")")) { - inRecord = false; - } else { - if (line.isEmpty() || line.contains("}")) { - res.add(line); - continue; - } - String element = line.strip(); - if (element.isEmpty()) continue; - String ann = String.format("@JsonProperty(\"%s\") %s", element.split(" ", 2)[1].replace(",", ""), element); - line = line.replace(element, ann); - } - } - - } - res.add(line); - } - BufferedWriter writer = new BufferedWriter(new FileWriter(filePath.toFile())); - for (String s : res) { - writer.write(s); - writer.newLine(); - } - writer.flush(); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void date() { - LocalDate today = LocalDate.now(); - DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; // формат ГГГГ-ММ-ДД - - String formattedDate = today.format(formatter); - System.out.println(formattedDate); - } - -} diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index 5b2ffe2..1b984fe 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -1,3 +1,23 @@ -module hdvtdev.telegram.core { +module core { + requires com.fasterxml.jackson.databind; + exports hdvtdev.telegram.core.exceptions; + exports hdvtdev.telegram.core.objects.command; + exports hdvtdev.telegram.core.annotaions; + exports hdvtdev.telegram.core.methods; exports hdvtdev.telegram.core; + exports hdvtdev.telegram.core.objects; + exports hdvtdev.telegram.core.objects.callback; + exports hdvtdev.telegram.core.objects.message; + exports hdvtdev.telegram.core.objects.media; + exports hdvtdev.telegram.core.objects.background; + exports hdvtdev.telegram.core.objects.business; + exports hdvtdev.telegram.core.objects.chat; + exports hdvtdev.telegram.core.objects.chatboost; + exports hdvtdev.telegram.core.objects.forum; + exports hdvtdev.telegram.core.objects.giveaway; + exports hdvtdev.telegram.core.objects.markup; + exports hdvtdev.telegram.core.objects.passport; + exports hdvtdev.telegram.core.objects.payment; + exports hdvtdev.telegram.core.objects.poll; + exports hdvtdev.telegram.core.objects.reaction; } \ No newline at end of file diff --git a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java index f186644..5c97f82 100644 --- a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java +++ b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java @@ -1,29 +1,27 @@ -package hdvtdev.telegram.longpolling; +package hdvtdev.telegram.longpolling.okhttp; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import hdvtdev.telegram.annotations.handlers.CallbackQueryHandler; -import hdvtdev.telegram.annotations.handlers.TextMessageHandler; -import hdvtdev.telegram.annotations.util.Jsonable; +import hdvtdev.telegram.core.InvokeMethod; import hdvtdev.telegram.core.TelegramBot; -import hdvtdev.telegram.exceptions.TelegramApiException; -import hdvtdev.telegram.exceptions.TelegramApiNetworkException; -import hdvtdev.telegram.exceptions.TelegramMethodParsingException; -import hdvtdev.telegram.methods.GetUpdates; -import hdvtdev.telegram.methods.TelegramApiMethod; -import hdvtdev.telegram.objects.CallbackQuery; -import hdvtdev.telegram.objects.Message; -import hdvtdev.telegram.objects.TelegramFile; -import hdvtdev.telegram.objects.Update; -import hdvtdev.telegram.util.ClassFinder; -import hdvtdev.telegram.util.InvokeMethod; +import hdvtdev.telegram.core.UpdateConsumer; +import hdvtdev.telegram.core.UserState; +import hdvtdev.telegram.core.annotaions.Jsonable; +import hdvtdev.telegram.core.exceptions.TelegramApiException; +import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException; +import hdvtdev.telegram.core.exceptions.TelegramMethodParsingException; +import hdvtdev.telegram.core.methods.GetUpdates; +import hdvtdev.telegram.core.methods.TelegramApiMethod; +import hdvtdev.telegram.core.methods.TelegramApiMethodBody; +import hdvtdev.telegram.core.objects.Update; +import hdvtdev.telegram.core.objects.callback.CallbackQuery; +import hdvtdev.telegram.core.objects.media.TelegramFile; +import hdvtdev.telegram.core.objects.message.Message; import okhttp3.*; -import org.jetbrains.annotations.NotNull; - import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -33,7 +31,6 @@ import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -121,12 +118,15 @@ public class OkHttpTelegramBot implements TelegramBot { userStateStorage = builder.userStateStorage; userState = builder.userState; if (builder.updateConsumer != null) setUpdateConsumer(builder.updateConsumer); - if (enableHandlers) { + /* + if (false) { Class updateConsumerClass = builder.updateConsumer == null ? UpdateConsumer.class : builder.updateConsumer.getClass(); Map, Map> handlers = builder.enableScan ? ClassFinder.getClasses() : ClassFinder.localScan(updateConsumerClass); this.messageHandlers = Collections.unmodifiableMap(handlers.get(TextMessageHandler.class)); this.callbackQueryHandlers = Collections.unmodifiableMap(handlers.get(CallbackQueryHandler.class)); } + + */ this.TELEGRAM_API_URL = "https://api.telegram.org/bot" + builder.token + "/"; this.TELEGRAM_FILE_API_URL = "https://api.telegram.org/file/bot" + builder.token + "/"; } @@ -227,9 +227,10 @@ public class OkHttpTelegramBot implements TelegramBot { this.thread.close(); } + @Override public T awaitExecute(TelegramApiMethod telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException { - RequestBody body = telegramApiMethod.getBody(); + TelegramApiMethodBody body = telegramApiMethod.getBody(); Request.Builder request = new Request.Builder() .url(TELEGRAM_API_URL + telegramApiMethod.getMethodName()); @@ -241,7 +242,11 @@ public class OkHttpTelegramBot implements TelegramBot { throw new TelegramMethodParsingException(e); } } - } else request.post(body); + } else { + FormBody.Builder requestBody = new FormBody.Builder(); + body.forEach(e -> requestBody.add(e.name(), e.value())); + request.post(requestBody.build()); + } try (Response response = client.newCall(request.build()).execute()) { String responseBody = Objects.requireNonNull(response.body()).string(); @@ -259,7 +264,6 @@ public class OkHttpTelegramBot implements TelegramBot { } - @NotNull private File getFile(TelegramFile telegramFile, Path targetDirectory) { try (Response response = client.newCall(new Request.Builder().url(TELEGRAM_FILE_API_URL + telegramFile.filePath()).build()).execute()) { ResponseBody responseBody = Objects.requireNonNull(response.body()); @@ -292,7 +296,7 @@ public class OkHttpTelegramBot implements TelegramBot { this.token = token; } - public Builder updateConsumer(Main.Upd updateConsumer) { + public Builder updateConsumer(UpdateConsumer updateConsumer) { this.updateConsumer = updateConsumer; return this; } diff --git a/longpolling-okhttp/src/main/java/module-info.java b/longpolling-okhttp/src/main/java/module-info.java index 46bf3f8..8834810 100644 --- a/longpolling-okhttp/src/main/java/module-info.java +++ b/longpolling-okhttp/src/main/java/module-info.java @@ -1,6 +1,7 @@ module longpolling.okhttp { - exports hdvtdev.telegram.longpolling; + exports hdvtdev.telegram.longpolling.okhttp; requires com.fasterxml.jackson.databind; + requires com.fasterxml.jackson.core; requires core; requires okhttp3; } diff --git a/test/src/main/java/Main.java b/test/src/main/java/Main.java index 1e936b3..c3a4d31 100644 --- a/test/src/main/java/Main.java +++ b/test/src/main/java/Main.java @@ -1,4 +1,27 @@ -package PACKAGE_NAME; +import hdvtdev.telegram.core.TelegramBot; +import hdvtdev.telegram.core.UpdateConsumer; +import hdvtdev.telegram.core.objects.Update; +import hdvtdev.telegram.longpolling.okhttp.OkHttpTelegramBot; + + +import java.util.List; public class Main { + + public static void main(String... a) { + + TelegramBot bot = new OkHttpTelegramBot.Builder(a[0]).enableHandlers(true).updateConsumer(new Upd()).build(); + + } + + public static final class Upd implements UpdateConsumer { + + @Override + public void getUpdates(List updates) { + + } + } + + + } From 5fe53b25399fca1465b277f6b1ede387a260234b Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Thu, 24 Apr 2025 20:59:49 +0300 Subject: [PATCH 4/6] some refactoring --- .idea/gradle.xml | 3 - build.gradle | 1 - core/build.gradle | 5 +- .../main/java/hdvtdev/telegram/core/Main.java | 0 .../hdvtdev/telegram/core/UpdateConsumer.java | 23 +++++- .../hdvtdev/telegram/core/UpdateHandler.java | 80 +++++++++++++++++++ .../message/MaybeInaccessibleMessage.java | 14 +++- .../MaybeInaccessibleMessageDeserializer.java | 16 ---- .../core/objects/message/Message.java | 2 + core/src/main/java/module-info.java | 2 + .../longpolling/okhttp/OkHttpTelegramBot.java | 4 +- .../src/main/java/module-info.java | 3 +- settings.gradle | 4 - test/build.gradle | 17 ---- test/src/main/java/Main.java | 27 ------- 15 files changed, 122 insertions(+), 79 deletions(-) delete mode 100644 core/src/main/java/hdvtdev/telegram/core/Main.java create mode 100644 core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java delete mode 100644 core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java delete mode 100644 test/build.gradle delete mode 100644 test/src/main/java/Main.java diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 7244181..f63ed0f 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -9,10 +9,7 @@ diff --git a/build.gradle b/build.gradle index a662c31..36534f4 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,6 @@ repositories { dependencies { implementation(project(":core")) implementation(project(":longpolling-okhttp")) - implementation(project(":test")) } tasks.register('fat', Jar) { diff --git a/core/build.gradle b/core/build.gradle index e472613..c816d58 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -5,6 +5,7 @@ plugins { group = 'com.github.hdvtdev' version = '1.0.0' + repositories { mavenCentral() } @@ -13,7 +14,3 @@ dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' } -jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} diff --git a/core/src/main/java/hdvtdev/telegram/core/Main.java b/core/src/main/java/hdvtdev/telegram/core/Main.java deleted file mode 100644 index e69de29..0000000 diff --git a/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java index 4bba6a6..6b96543 100644 --- a/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java +++ b/core/src/main/java/hdvtdev/telegram/core/UpdateConsumer.java @@ -1,11 +1,32 @@ package hdvtdev.telegram.core; +import hdvtdev.telegram.core.objects.ChosenInlineResult; +import hdvtdev.telegram.core.objects.InlineQuery; import hdvtdev.telegram.core.objects.Update; +import hdvtdev.telegram.core.objects.business.BusinessConnection; +import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted; +import hdvtdev.telegram.core.objects.callback.CallbackQuery; +import hdvtdev.telegram.core.objects.chat.ChatJoinRequest; +import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated; +import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased; +import hdvtdev.telegram.core.objects.message.Message; +import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated; +import hdvtdev.telegram.core.objects.message.MessageReactionUpdated; +import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery; +import hdvtdev.telegram.core.objects.payment.ShippingQuery; +import hdvtdev.telegram.core.objects.poll.Poll; +import hdvtdev.telegram.core.objects.poll.PollAnswer; import java.util.List; public interface UpdateConsumer { - void getUpdates(List updates); + + + void onUpdates(List updates); + + } diff --git a/core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java b/core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java new file mode 100644 index 0000000..00cf08c --- /dev/null +++ b/core/src/main/java/hdvtdev/telegram/core/UpdateHandler.java @@ -0,0 +1,80 @@ +package hdvtdev.telegram.core; + +import hdvtdev.telegram.core.objects.ChosenInlineResult; +import hdvtdev.telegram.core.objects.InlineQuery; +import hdvtdev.telegram.core.objects.Update; +import hdvtdev.telegram.core.objects.business.BusinessConnection; +import hdvtdev.telegram.core.objects.business.BusinessMessagesDeleted; +import hdvtdev.telegram.core.objects.callback.CallbackQuery; +import hdvtdev.telegram.core.objects.chat.ChatJoinRequest; +import hdvtdev.telegram.core.objects.chat.ChatMemberUpdated; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostRemoved; +import hdvtdev.telegram.core.objects.chatboost.ChatBoostUpdated; +import hdvtdev.telegram.core.objects.media.paidmedia.PaidMediaPurchased; +import hdvtdev.telegram.core.objects.message.Message; +import hdvtdev.telegram.core.objects.message.MessageReactionCountUpdated; +import hdvtdev.telegram.core.objects.message.MessageReactionUpdated; +import hdvtdev.telegram.core.objects.payment.PreCheckoutQuery; +import hdvtdev.telegram.core.objects.payment.ShippingQuery; +import hdvtdev.telegram.core.objects.poll.Poll; +import hdvtdev.telegram.core.objects.poll.PollAnswer; + +import java.util.List; + +public interface UpdateHandler extends UpdateConsumer { + + @Override + default void onUpdates(List updates) { + for (Update update : updates) { + if (update.hasMessage()) onMessage(update.message()); + if (update.hasEditedMessage()) onEditedMessage(update.editedMessage()); + if (update.hasChannelPost()) onChannelPost(update.channelPost()); + if (update.hasEditedChannelPost()) onEditedChannelPost(update.editedChannelPost()); + if (update.hasBusinessConnection()) onBusinessConnection(update.businessConnection()); + if (update.hasBusinessMessage()) onBusinessMessage(update.businessMessage()); + if (update.hasEditedBusinessMessage()) onEditedBusinessMessage(update.editedBusinessMessage()); + if (update.hasDeletedBusinessMessages()) onDeletedBusinessMessages(update.businessMessagesDeleted()); + if (update.hasMessageReaction()) onMessageReaction(update.messageReaction()); + if (update.hasMessageReactionCount()) onMessageReactionCount(update.messageReactionCount()); + if (update.hasInlineQuery()) onInlineQuery(update.inlineQuery()); + if (update.hasChosenInlineResult()) onChosenInlineResult(update.chosenInlineResult()); + if (update.hasCallbackQuery()) onCallbackQuery(update.callbackQuery()); + if (update.hasShippingQuery()) onShippingQuery(update.shippingQuery()); + if (update.hasPreCheckoutQuery()) onPreCheckoutQuery(update.preCheckoutQuery()); + if (update.hasPurchasedPaidMedia()) onPaidMediaPurchased(update.paidMediaPurchased()); + if (update.hasPoll()) onPoll(update.poll()); + if (update.hasPollAnswer()) onPollAnswer(update.pollAnswer()); + if (update.hasMyChatMember()) onMyChatMember(update.myChatMember()); + if (update.hasChatMember()) onChatMember(update.chatMember()); + if (update.hasChatJoinRequest()) onChatJoinRequest(update.chatJoinRequest()); + if (update.hasChatBoost()) onChatBoost(update.chatBoost()); + if (update.hasRemovedChatBoost()) onChatBoostRemoved(update.chatBoostRemoved()); + } + } + + default void onMessage(Message message) {} + default void onEditedMessage(Message message) {} + default void onChannelPost(Message message) {} + default void onEditedChannelPost(Message message) {} + default void onBusinessConnection(BusinessConnection connection) {} + default void onBusinessMessage(Message message) {} + default void onEditedBusinessMessage(Message message) {} + default void onDeletedBusinessMessages(BusinessMessagesDeleted deleted) {} + default void onMessageReaction(MessageReactionUpdated reaction) {} + default void onMessageReactionCount(MessageReactionCountUpdated count) {} + default void onInlineQuery(InlineQuery query) {} + default void onChosenInlineResult(ChosenInlineResult result) {} + default void onCallbackQuery(CallbackQuery callbackQuery) {} + default void onShippingQuery(ShippingQuery query) {} + default void onPreCheckoutQuery(PreCheckoutQuery query) {} + default void onPaidMediaPurchased(PaidMediaPurchased paidMedia) {} + default void onPoll(Poll poll) {} + default void onPollAnswer(PollAnswer answer) {} + default void onMyChatMember(ChatMemberUpdated member) {} + default void onChatMember(ChatMemberUpdated member) {} + default void onChatJoinRequest(ChatJoinRequest request) {} + default void onChatBoost(ChatBoostUpdated boost) {} + default void onChatBoostRemoved(ChatBoostRemoved removedBoost) {} + + +} diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java index 33e8733..6820944 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessage.java @@ -1,9 +1,19 @@ package hdvtdev.telegram.core.objects.message; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + import hdvtdev.telegram.core.objects.chat.Chat; -@JsonDeserialize(using = MaybeInaccessibleMessageDeserializer.class) +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "date", + defaultImpl = Message.class +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = InaccessibleMessage.class, name = "0") +}) public interface MaybeInaccessibleMessage { long chatId(); diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java deleted file mode 100644 index f02036c..0000000 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/MaybeInaccessibleMessageDeserializer.java +++ /dev/null @@ -1,16 +0,0 @@ -package hdvtdev.telegram.core.objects.message; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -import java.io.IOException; - -public class MaybeInaccessibleMessageDeserializer extends JsonDeserializer { - - @Override - public MaybeInaccessibleMessage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Message msg = p.getCodec().readValue(p, Message.class); - return msg.date() == 0 ? new InaccessibleMessage(msg.chat(), msg.messageId(), 0) : msg; - } -} \ No newline at end of file diff --git a/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java index 92e1e5a..476f236 100644 --- a/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java +++ b/core/src/main/java/hdvtdev/telegram/core/objects/message/Message.java @@ -3,6 +3,7 @@ package hdvtdev.telegram.core.objects.message; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; + import hdvtdev.telegram.core.objects.*; import hdvtdev.telegram.core.objects.chat.Chat; import hdvtdev.telegram.core.objects.chat.ChatBackground; @@ -290,4 +291,5 @@ public record Message( public long chatId() { return this.chat.id(); } + } diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index 1b984fe..ef0e284 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -9,6 +9,8 @@ module core { exports hdvtdev.telegram.core.objects.callback; exports hdvtdev.telegram.core.objects.message; exports hdvtdev.telegram.core.objects.media; + exports hdvtdev.telegram.core.objects.media.paidmedia; + exports hdvtdev.telegram.core.objects.media.video; exports hdvtdev.telegram.core.objects.background; exports hdvtdev.telegram.core.objects.business; exports hdvtdev.telegram.core.objects.chat; diff --git a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java index 5c97f82..61b7507 100644 --- a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java +++ b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java @@ -117,7 +117,6 @@ public class OkHttpTelegramBot implements TelegramBot { enableHandlers = builder.enableHandlers; userStateStorage = builder.userStateStorage; userState = builder.userState; - if (builder.updateConsumer != null) setUpdateConsumer(builder.updateConsumer); /* if (false) { Class updateConsumerClass = builder.updateConsumer == null ? UpdateConsumer.class : builder.updateConsumer.getClass(); @@ -129,6 +128,7 @@ public class OkHttpTelegramBot implements TelegramBot { */ this.TELEGRAM_API_URL = "https://api.telegram.org/bot" + builder.token + "/"; this.TELEGRAM_FILE_API_URL = "https://api.telegram.org/file/bot" + builder.token + "/"; + if (builder.updateConsumer != null) setUpdateConsumer(builder.updateConsumer); } /** @@ -195,7 +195,7 @@ public class OkHttpTelegramBot implements TelegramBot { }); } } - if (updateConsumer != null) CompletableFuture.runAsync(() -> updateConsumer.getUpdates(updates)); + if (updateConsumer != null) CompletableFuture.runAsync(() -> updateConsumer.onUpdates(updates)); } finally { lastUpdateId.set(updates.getLast().updateId()); if (!thread.isShutdown()) getUpdates(); diff --git a/longpolling-okhttp/src/main/java/module-info.java b/longpolling-okhttp/src/main/java/module-info.java index 8834810..e7df579 100644 --- a/longpolling-okhttp/src/main/java/module-info.java +++ b/longpolling-okhttp/src/main/java/module-info.java @@ -1,7 +1,6 @@ module longpolling.okhttp { exports hdvtdev.telegram.longpolling.okhttp; - requires com.fasterxml.jackson.databind; - requires com.fasterxml.jackson.core; requires core; requires okhttp3; + requires com.fasterxml.jackson.databind; } diff --git a/settings.gradle b/settings.gradle index 8c3e3e0..8dac7dc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,4 @@ rootProject.name = 'TeleJ' -include 'longpolling' include 'core' -include 'longpolling:longpolling-okhttp' -findProject(':longpolling:longpolling-okhttp')?.name = 'longpolling-okhttp' -include 'test' include 'longpolling-okhttp' diff --git a/test/build.gradle b/test/build.gradle deleted file mode 100644 index d4eb6b4..0000000 --- a/test/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -plugins { - id 'java' -} - -group = 'com.github.hdvtdev' -version = '1.0.0' - -repositories { - mavenCentral() -} - -dependencies { - implementation(project(":core")) - implementation(project(":longpolling-okhttp")) -} - - diff --git a/test/src/main/java/Main.java b/test/src/main/java/Main.java deleted file mode 100644 index c3a4d31..0000000 --- a/test/src/main/java/Main.java +++ /dev/null @@ -1,27 +0,0 @@ -import hdvtdev.telegram.core.TelegramBot; -import hdvtdev.telegram.core.UpdateConsumer; -import hdvtdev.telegram.core.objects.Update; -import hdvtdev.telegram.longpolling.okhttp.OkHttpTelegramBot; - - -import java.util.List; - -public class Main { - - public static void main(String... a) { - - TelegramBot bot = new OkHttpTelegramBot.Builder(a[0]).enableHandlers(true).updateConsumer(new Upd()).build(); - - } - - public static final class Upd implements UpdateConsumer { - - @Override - public void getUpdates(List updates) { - - } - } - - - -} From 97e93f7feb1c39e9d651af2520b1d9e785bd85ee Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Thu, 24 Apr 2025 21:57:53 +0300 Subject: [PATCH 5/6] some refactoring --- .../hdvtdev/telegram/core/TelegramBot.java | 2 + .../longpolling/okhttp/OkHttpTelegramBot.java | 106 ++++++++---------- 2 files changed, 46 insertions(+), 62 deletions(-) diff --git a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java index a78e4e5..fbad94d 100644 --- a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java +++ b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java @@ -19,6 +19,8 @@ public interface TelegramBot { File awaitDownloadFile(TelegramFile telegramFile, Path targetDirectory); + void shutdown(); + default CompletableFuture downloadFile(TelegramFile telegramFile, Path targetDirectory) throws TelegramApiException, TelegramApiNetworkException { return CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory)); } diff --git a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java index 61b7507..e65cb2a 100644 --- a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java +++ b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java @@ -42,7 +42,7 @@ public class OkHttpTelegramBot implements TelegramBot { private final String TELEGRAM_API_URL; private final String TELEGRAM_FILE_API_URL; - private final ObjectMapper json = new ObjectMapper(); + private final ObjectMapper json; static { try { @@ -86,27 +86,10 @@ public class OkHttpTelegramBot implements TelegramBot { } private UpdateConsumer updateConsumer; - private boolean enableHandlers = false; - private Map messageHandlers; - private Map callbackQueryHandlers; - - private UserState userState; - private Map userStateStorage; - - public UserState getUserState(String id) { - return userStateStorage.getOrDefault(id, userState); - } - - public void setUserState(String id, UserState userState) { - userStateStorage.put(id, userState); - } - - public boolean compareUserState(String id, UserState userState) { - return getUserState(id).equals(userState); - } public OkHttpTelegramBot(String token) { + this.json = new ObjectMapper(); this.TELEGRAM_API_URL = "https://api.telegram.org/bot" + token + "/"; this.TELEGRAM_FILE_API_URL = "https://api.telegram.org/file/bot" + token + "/"; } @@ -115,8 +98,7 @@ public class OkHttpTelegramBot implements TelegramBot { updateLimit = builder.updateLimit; updateTimeout = builder.updateTimeout; enableHandlers = builder.enableHandlers; - userStateStorage = builder.userStateStorage; - userState = builder.userState; + json = builder.objectMapper == null ? new ObjectMapper() : builder.objectMapper; /* if (false) { Class updateConsumerClass = builder.updateConsumer == null ? UpdateConsumer.class : builder.updateConsumer.getClass(); @@ -170,38 +152,44 @@ public class OkHttpTelegramBot implements TelegramBot { private void getUpdates() { List updates = List.of(awaitExecute(new GetUpdates(lastUpdateId.get() + 1, updateLimit, updateTimeout))); - System.out.println("UPDATE"); - if (!updates.isEmpty()) { - try { - if (enableHandlers) { - for (Update update : updates) { - CompletableFuture.runAsync(() -> { - if (update.hasMessage()) { - Message message = update.message(); - if (message.hasText() && !messageHandlers.isEmpty()) { - String key = message.text(); - invokeAnnotatedMethod(messageHandlers.containsKey("*") ? messageHandlers.get("*") : messageHandlers.get(key), update); - } - } - if (update.hasCallbackQuery()) { - CallbackQuery callbackQuery = update.callbackQuery(); - if (callbackQuery.hasMessage()) { - Message message = (Message) callbackQuery.message(); - if (message.hasText() && !callbackQueryHandlers.isEmpty()) { - invokeAnnotatedMethod(callbackQueryHandlers.containsKey("*") ? callbackQueryHandlers.get("*") : callbackQueryHandlers.get(message.text()), update); - } - } - } - }); - } - } + try { + if (!updates.isEmpty()) { if (updateConsumer != null) CompletableFuture.runAsync(() -> updateConsumer.onUpdates(updates)); - } finally { lastUpdateId.set(updates.getLast().updateId()); - if (!thread.isShutdown()) getUpdates(); + } + } finally { + if (!thread.isShutdown()) getUpdates(); + } + } + + private void handlers(List updates) { + //TODO + //FIXME + /* + if (enableHandlers) { + for (Update update : updates) { + CompletableFuture.runAsync(() -> { + if (update.hasMessage()) { + Message message = update.message(); + if (message.hasText() && !messageHandlers.isEmpty()) { + String key = message.text(); + invokeAnnotatedMethod(messageHandlers.containsKey("*") ? messageHandlers.get("*") : messageHandlers.get(key), update); + } + } + if (update.hasCallbackQuery()) { + CallbackQuery callbackQuery = update.callbackQuery(); + if (callbackQuery.hasMessage()) { + Message message = (Message) callbackQuery.message(); + if (message.hasText() && !callbackQueryHandlers.isEmpty()) { + invokeAnnotatedMethod(callbackQueryHandlers.containsKey("*") ? callbackQueryHandlers.get("*") : callbackQueryHandlers.get(message.text()), update); + } + } + } + }); } } + */ } private static void invokeAnnotatedMethod(InvokeMethod invokeMethod, Update update) { @@ -223,7 +211,8 @@ public class OkHttpTelegramBot implements TelegramBot { } } - public void shutdownUpdateConsumer() { + @Override + public void shutdown() { this.thread.close(); } @@ -281,36 +270,29 @@ public class OkHttpTelegramBot implements TelegramBot { return getFile(telegramFile, targetDirectory); } - public static final class Builder { private int updateLimit = 10; private int updateTimeout = 25; private boolean enableHandlers = false; private boolean enableScan = false; private final String token; - private Map userStateStorage; - private UserState userState; private UpdateConsumer updateConsumer; + private ObjectMapper objectMapper; public Builder(String token) { this.token = token; } + public Builder objectMapper(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + return this; + } + public Builder updateConsumer(UpdateConsumer updateConsumer) { this.updateConsumer = updateConsumer; return this; } - public Builder enableUserStateStorage(UserState defaultValue, Map userStateStorage) { - this.userState = defaultValue; - this.userStateStorage = userStateStorage; - return this; - } - - public Builder enableUserStateStorage(UserState defaultValue) { - return enableUserStateStorage(defaultValue, new ConcurrentHashMap<>()); - } - public Builder updateLimit(int updateLimit) { this.updateLimit = updateLimit; return this; From 66d2172f51037de2c0e910a7791ce6e2052a0347 Mon Sep 17 00:00:00 2001 From: hdvtdev Date: Thu, 24 Apr 2025 23:14:43 +0300 Subject: [PATCH 6/6] some refactoring --- .../hdvtdev/telegram/core/TelegramBot.java | 18 +++- .../core/methods/TelegramApiMethodBody.java | 8 +- .../longpolling/okhttp/OkHttpTelegramBot.java | 82 ++----------------- 3 files changed, 26 insertions(+), 82 deletions(-) diff --git a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java index fbad94d..9085f3c 100644 --- a/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java +++ b/core/src/main/java/hdvtdev/telegram/core/TelegramBot.java @@ -21,12 +21,22 @@ public interface TelegramBot { void shutdown(); - default CompletableFuture downloadFile(TelegramFile telegramFile, Path targetDirectory) throws TelegramApiException, TelegramApiNetworkException { - return CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory)); + default CompletableFuture downloadFile(TelegramFile telegramFile, Path targetDirectory) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory)); + completableFuture.exceptionally(e -> { + e.printStackTrace(); + return null; + }); + return completableFuture; } - default CompletableFuture execute(TelegramApiMethod telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException { - return CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod)); + default CompletableFuture execute(TelegramApiMethod telegramApiMethod) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod)); + completableFuture.exceptionally(e -> { + e.printStackTrace(); + return null; + }); + return completableFuture; } default int getPing() throws TelegramApiNetworkException { diff --git a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java index 4b8da57..804eea5 100644 --- a/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java +++ b/core/src/main/java/hdvtdev/telegram/core/methods/TelegramApiMethodBody.java @@ -19,8 +19,12 @@ public final class TelegramApiMethodBody { if (value != null) this.elements.add(new Element(name, value)); } - public void forEach(Consumer action) { - this.elements.forEach(action); + public int size() { + return this.elements.size(); + } + + public Element get(int i) { + return this.elements.get(i); } public record Element(String name, String value) { diff --git a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java index e65cb2a..bfba11b 100644 --- a/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java +++ b/longpolling-okhttp/src/main/java/hdvtdev/telegram/longpolling/okhttp/OkHttpTelegramBot.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import hdvtdev.telegram.core.InvokeMethod; import hdvtdev.telegram.core.TelegramBot; import hdvtdev.telegram.core.UpdateConsumer; -import hdvtdev.telegram.core.UserState; import hdvtdev.telegram.core.annotaions.Jsonable; import hdvtdev.telegram.core.exceptions.TelegramApiException; import hdvtdev.telegram.core.exceptions.TelegramApiNetworkException; @@ -16,9 +15,7 @@ import hdvtdev.telegram.core.methods.GetUpdates; import hdvtdev.telegram.core.methods.TelegramApiMethod; import hdvtdev.telegram.core.methods.TelegramApiMethodBody; import hdvtdev.telegram.core.objects.Update; -import hdvtdev.telegram.core.objects.callback.CallbackQuery; import hdvtdev.telegram.core.objects.media.TelegramFile; -import hdvtdev.telegram.core.objects.message.Message; import okhttp3.*; @@ -32,7 +29,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; @@ -113,37 +109,17 @@ public class OkHttpTelegramBot implements TelegramBot { if (builder.updateConsumer != null) setUpdateConsumer(builder.updateConsumer); } - /** - * Enables the default long polling update consumer for handlers. - *

- * This method is effective only if {@link #enableHandlers} is{@code true}, - * otherwise, it just marks updates as read/processed without invoking any handlers. - *

- *


-     * Equivalent to: setUpdateConsumer(null);
-     * 
- * @throws IllegalStateException if an {@code UpdateConsumer} is already defined - * @see #setUpdateConsumer(UpdateConsumer) - * @see #enableHandlers - * @since 0.0.1 - */ - public void enableDefaultUpdateConsumer() throws IllegalStateException { - setUpdateConsumer(null); - } - /** * Enables a long polling update consumer. If {@link #enableHandlers} is {@code true}, * the specified handlers will be invoked for each received update. * * @param updateConsumer class that implements {@code UpdateConsumer} * @throws IllegalStateException if an {@code UpdateConsumer} is already defined - * @see #enableDefaultUpdateConsumer() * @see #enableHandlers * @since 0.0.1 */ - public void setUpdateConsumer(UpdateConsumer updateConsumer) throws IllegalStateException { - if (thread != null) - throw new IllegalStateException("Update Consumer is already defined. You must first stop the previous"); + private void setUpdateConsumer(UpdateConsumer updateConsumer) throws IllegalStateException { + if (thread != null) throw new IllegalStateException("Update Consumer is already defined. You must first stop the previous"); this.updateConsumer = updateConsumer; this.lastUpdateId = new AtomicLong(0); thread = Executors.newSingleThreadExecutor(); @@ -162,55 +138,6 @@ public class OkHttpTelegramBot implements TelegramBot { } } - private void handlers(List updates) { - //TODO - //FIXME - /* - if (enableHandlers) { - for (Update update : updates) { - CompletableFuture.runAsync(() -> { - if (update.hasMessage()) { - Message message = update.message(); - if (message.hasText() && !messageHandlers.isEmpty()) { - String key = message.text(); - invokeAnnotatedMethod(messageHandlers.containsKey("*") ? messageHandlers.get("*") : messageHandlers.get(key), update); - } - } - if (update.hasCallbackQuery()) { - CallbackQuery callbackQuery = update.callbackQuery(); - if (callbackQuery.hasMessage()) { - Message message = (Message) callbackQuery.message(); - if (message.hasText() && !callbackQueryHandlers.isEmpty()) { - invokeAnnotatedMethod(callbackQueryHandlers.containsKey("*") ? callbackQueryHandlers.get("*") : callbackQueryHandlers.get(message.text()), update); - } - } - } - }); - } - } - - */ - } - - private static void invokeAnnotatedMethod(InvokeMethod invokeMethod, Update update) { - - if (invokeMethod != null) { - Method method = invokeMethod.method(); - method.setAccessible(true); - try { - switch (invokeMethod.parameterType().getSimpleName()) { - case "Message" -> method.invoke(null, update.message()); - case "Update" -> method.invoke(null, update); - case "CallbackQuery" -> method.invoke(null, update.callbackQuery()); - default -> method.invoke(null); - } - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - } - @Override public void shutdown() { this.thread.close(); @@ -233,7 +160,10 @@ public class OkHttpTelegramBot implements TelegramBot { } } else { FormBody.Builder requestBody = new FormBody.Builder(); - body.forEach(e -> requestBody.add(e.name(), e.value())); + for (int i = 0; i < body.size(); i++) { + TelegramApiMethodBody.Element e = body.get(i); + requestBody.add(e.name(), e.value()); + } request.post(requestBody.build()); }