From 5fc7d889749b12ddf54afa3380eecae1e43debef Mon Sep 17 00:00:00 2001 From: ruben Date: Sun, 18 Aug 2024 15:03:35 +0100 Subject: [PATCH] Api Version 7.9 --- pom.xml | 2 +- telegrambots-abilities/pom.xml | 6 +- telegrambots-client/pom.xml | 2 +- .../client/okhttp/OkHttpTelegramClient.java | 1 + telegrambots-extensions/README.md | 4 +- telegrambots-extensions/pom.xml | 6 +- telegrambots-longpolling/pom.xml | 2 +- telegrambots-meta/pom.xml | 2 +- .../CreateChatSubscriptionInviteLink.java | 113 ++++++++++ .../EditChatSubscriptionInviteLink.java | 100 +++++++++ .../methods/reactions/SetMessageReaction.java | 7 +- .../meta/api/methods/send/SendPaidMedia.java | 10 +- .../objects/chatmember/ChatMemberMember.java | 11 + .../meta/api/objects/message/Message.java | 196 +++++++++--------- .../TransactionPartnerUser.java | 10 + .../api/objects/reactions/ReactionType.java | 6 +- .../objects/reactions/ReactionTypePaid.java | 48 +++++ .../pom.xml | 4 +- .../pom.xml | 4 +- telegrambots-test-reports/pom.xml | 2 +- telegrambots-webhook/pom.xml | 2 +- 21 files changed, 420 insertions(+), 118 deletions(-) create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java diff --git a/pom.xml b/pom.xml index eb089b550..9e997107b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 7.8.0 + 7.9.0 telegrambots-meta diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index 816179e70..d54dec036 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-abilities @@ -104,12 +104,12 @@ org.telegram telegrambots-webhook - 7.8.0 + 7.9.0 org.telegram telegrambots-longpolling - 7.8.0 + 7.9.0 diff --git a/telegrambots-client/pom.xml b/telegrambots-client/pom.xml index 8a134ebd2..0259ff47f 100644 --- a/telegrambots-client/pom.xml +++ b/telegrambots-client/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 Telegram Bots Client diff --git a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java index eb596f4fc..71b02a4f6 100644 --- a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java +++ b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java @@ -261,6 +261,7 @@ public CompletableFuture> executeAsync(SendPaidMedia sendPaidMedia .addPart(SendPaidMedia.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendPaidMedia.getShowCaptionAboveMedia()) .addPart(SendPaidMedia.DISABLE_NOTIFICATION_FIELD, sendPaidMedia.getDisableNotification()) .addPart(SendPaidMedia.PROTECT_CONTENT_FIELD, sendPaidMedia.getProtectContent()) + .addPart(SendPaidMedia.BUSINESS_CONNECTION_ID_FIELD, sendPaidMedia.getBusinessConnectionId()) .addJsonPart(SendPaidMedia.CAPTION_ENTITIES_FIELD, sendPaidMedia.getCaptionEntities()) .addJsonPart(SendPaidMedia.REPLY_MARKUP_FIELD, sendPaidMedia.getReplyMarkup()) .addJsonPart(SendPaidMedia.REPLY_PARAMETERS_FIELD, sendPaidMedia.getReplyParameters()); diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index bd3c50039..6f012ad2a 100644 --- a/telegrambots-extensions/README.md +++ b/telegrambots-extensions/README.md @@ -16,12 +16,12 @@ Just import add the library to your project with one of these options: org.telegram telegrambots-extensions - 7.8.0 + 7.9.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambots-extensions:7.8.0' + implementation 'org.telegram:telegrambots-extensions:7.9.0' ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index 44e8fa0e6..7cc02a2e3 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-extensions @@ -89,12 +89,12 @@ org.telegram telegrambots-webhook - 7.8.0 + 7.9.0 org.telegram telegrambots-longpolling - 7.8.0 + 7.9.0 diff --git a/telegrambots-longpolling/pom.xml b/telegrambots-longpolling/pom.xml index 03e8171b9..754eed621 100644 --- a/telegrambots-longpolling/pom.xml +++ b/telegrambots-longpolling/pom.xml @@ -6,7 +6,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-longpolling diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 662a7a298..e2cd0cad9 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-meta diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java new file mode 100644 index 000000000..54be02c7b --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java @@ -0,0 +1,113 @@ +package org.telegram.telegrambots.meta.api.methods.groupadministration; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.experimental.Tolerate; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.ChatInviteLink; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 7.9 + * + * Use this method to create a subscription invite link for a channel chat. + * Returns the new invite link as a ChatInviteLink object. + * + * @apiNote The bot must have can_invite_users administrator rights. + * @apiNote The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@RequiredArgsConstructor +@SuperBuilder +@Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateChatSubscriptionInviteLink extends BotApiMethod { + public static final String PATH = "createChatSubscriptionInviteLink"; + + private static final String CHAT_ID_FIELD = "chat_id"; + private static final String SUBSCRIPTION_PERIOD_FIELD = "subscription_period"; + private static final String SUBSCRIPTION_PRICE_FIELD = "subscription_price"; + private static final String NAME_FIELD = "name"; + + /** + * Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) + */ + @JsonProperty(CHAT_ID_FIELD) + @NonNull + private String chatId; + /** + * The number of seconds the subscription will be active for before the next payment. + * Currently, it must always be 2592000 (30 days). + */ + @JsonProperty(SUBSCRIPTION_PERIOD_FIELD) + @NonNull + @Builder.Default + private Integer subscriptionPeriod = 2592000; + /** + * The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + */ + @JsonProperty(SUBSCRIPTION_PRICE_FIELD) + @NonNull + private Integer subscriptionPrice; + /** + * Optional + * Invite link name; 0-32 characters + */ + @JsonProperty(NAME_FIELD) + private String name; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public String getMethod() { + return PATH; + } + + @Override + public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, ChatInviteLink.class); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + if (name != null && name.length() > 32) { + throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this); + } + if (subscriptionPeriod != 2592000) { + throw new TelegramApiValidationException("SubscriptionPeriod must be 2592000", this); + } + if (subscriptionPrice < 1 || subscriptionPrice > 2500) { + throw new TelegramApiValidationException("SubscriptionPrice must be between 1 and 2500", this); + } + } + + public static abstract class CreateChatSubscriptionInviteLinkBuilder> extends BotApiMethodBuilder { + @Tolerate + public CreateChatSubscriptionInviteLinkBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java new file mode 100644 index 000000000..3f62d27d1 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java @@ -0,0 +1,100 @@ +package org.telegram.telegrambots.meta.api.methods.groupadministration; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.experimental.Tolerate; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.ChatInviteLink; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 7.9 + * + * Use this method to edit a subscription invite link created by the bot. + * Returns the edited invite link as a ChatInviteLink object. + * + * @apiNote The bot must have can_invite_users administrator rights. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@RequiredArgsConstructor +@SuperBuilder +@Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) +public class EditChatSubscriptionInviteLink extends BotApiMethod { + public static final String PATH = "editChatSubscriptionInviteLink"; + + private static final String CHAT_ID_FIELD = "chat_id"; + private static final String INVITE_LINK_FIELD = "invite_link"; + private static final String NAME_FIELD = "name"; + + /** + * Unique identifier for the target chat or username of the target channel (in the format @channelusername) + */ + @JsonProperty(CHAT_ID_FIELD) + @NonNull + private String chatId; + /** + * The number of seconds the subscription will be active for before the next payment. + * Currently, it must always be 2592000 (30 days). + */ + @JsonProperty(INVITE_LINK_FIELD) + @NonNull + private String inviteLink; + /** + * Optional + * Invite link name; 0-32 characters + */ + @JsonProperty(NAME_FIELD) + private String name; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public String getMethod() { + return PATH; + } + + @Override + public ChatInviteLink deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, ChatInviteLink.class); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + if (name != null && name.length() > 32) { + throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this); + } + if (inviteLink.isEmpty()) { + throw new TelegramApiValidationException("InviteLink must not be empty", this); + } + } + + public static abstract class EditChatSubscriptionInviteLinkBuilder> extends BotApiMethodBuilder { + @Tolerate + public EditChatSubscriptionInviteLinkBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java index b70ec45b3..ebc6b4ed7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java @@ -28,6 +28,8 @@ * In albums, bots must react to the first message. * * Returns True on success. + * + * @apiNote Bots can't use paid reactions */ @SuppressWarnings("unused") @EqualsAndHashCode(callSuper = false) @@ -64,6 +66,7 @@ public class SetMessageReaction extends BotApiMethodBoolean { * New list of reaction types to set on the message. * Currently, as non-premium users, bots can set up to one reaction per message. * A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. + * @apiNote Paid reactions can't be used by bots. */ @JsonProperty(REACTION_FIELD) private List reactionTypes; @@ -74,7 +77,6 @@ public class SetMessageReaction extends BotApiMethodBoolean { @JsonProperty(IS_BIG_FIELD) private Boolean isBig; - @Tolerate public void setChatId(@NonNull Long chatId) { this.chatId = chatId.toString(); @@ -92,6 +94,9 @@ public void validate() throws TelegramApiValidationException { } if (reactionTypes != null) { for (ReactionType reactionType : reactionTypes) { + if (ReactionType.PAID_TYPE.equals(reactionType.getType())) { + throw new TelegramApiValidationException("ReactionType can't be paid", this); + } reactionType.validate(); } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java index 8d3fba183..14cecc628 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java @@ -53,9 +53,12 @@ public class SendPaidMedia extends PartialBotApiMethod> { public static final String PROTECT_CONTENT_FIELD = "protect_content"; public static final String REPLY_PARAMETERS_FIELD = "reply_parameters"; public static final String REPLY_MARKUP_FIELD = "reply_markup"; + public static final String BUSINESS_CONNECTION_ID_FIELD = "business_connection_id"; /** - * Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * Unique identifier for the target chat or username of the target channel (in the format @channelusername). + * If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. + * Otherwise, they will be credited to the bot's balance. */ @NonNull private String chatId; @@ -111,6 +114,11 @@ public class SendPaidMedia extends PartialBotApiMethod> { * instructions to remove a reply keyboard or to force a reply from the user */ private ReplyKeyboard replyMarkup; + /** + * Optional + * Unique identifier of the business connection on behalf of which the message will be sent + */ + private String businessConnectionId; @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java index 7ae6cadf4..8b97fa8c1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java @@ -6,6 +6,8 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; import lombok.experimental.SuperBuilder; @@ -23,6 +25,7 @@ @Setter @ToString @NoArgsConstructor +@RequiredArgsConstructor @AllArgsConstructor @SuperBuilder @Jacksonized @@ -32,6 +35,7 @@ public class ChatMemberMember implements ChatMember { private static final String STATUS_FIELD = "status"; private static final String USER_FIELD = "user"; + private static final String UNTIL_DATE_FIELD = "until_date"; /** * The member's status in the chat, always “member” @@ -42,5 +46,12 @@ public class ChatMemberMember implements ChatMember { * Information about the user */ @JsonProperty(USER_FIELD) + @NonNull private User user; + /** + * Optional. + * Date when the user's subscription will expire; Unix time + */ + @JsonProperty(UNTIL_DATE_FIELD) + private Integer untilDate; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java index 73d048319..f78c16014 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java @@ -82,17 +82,17 @@ @Jacksonized @JsonIgnoreProperties(ignoreUnknown = true) public class Message implements MaybeInaccessibleMessage { - private static final String MESSAGEID_FIELD = "message_id"; - private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + private static final String MESSAGE_ID_FIELD = "message_id"; + private static final String MESSAGE_THREAD_ID_FIELD = "message_thread_id"; private static final String FROM_FIELD = "from"; private static final String DATE_FIELD = "date"; private static final String CHAT_FIELD = "chat"; - private static final String FORWARDFROM_FIELD = "forward_from"; - private static final String FORWARDFROMCHAT_FIELD = "forward_from_chat"; - private static final String FORWARDDATE_FIELD = "forward_date"; + private static final String FORWARD_FROM_FIELD = "forward_from"; + private static final String FORWARD_FROM_CHAT_FIELD = "forward_from_chat"; + private static final String FORWARD_DATE_FIELD = "forward_date"; private static final String TEXT_FIELD = "text"; private static final String ENTITIES_FIELD = "entities"; - private static final String CAPTIONENTITIES_FIELD = "caption_entities"; + private static final String CAPTION_ENTITIES_FIELD = "caption_entities"; private static final String AUDIO_FIELD = "audio"; private static final String DOCUMENT_FIELD = "document"; private static final String PHOTO_FIELD = "photo"; @@ -103,58 +103,57 @@ public class Message implements MaybeInaccessibleMessage { private static final String VENUE_FIELD = "venue"; private static final String ANIMATION_FIELD = "animation"; private static final String PINNED_MESSAGE_FIELD = "pinned_message"; - private static final String NEWCHATMEMBERS_FIELD = "new_chat_members"; - private static final String LEFTCHATMEMBER_FIELD = "left_chat_member"; - private static final String NEWCHATTITLE_FIELD = "new_chat_title"; - private static final String NEWCHATPHOTO_FIELD = "new_chat_photo"; - private static final String DELETECHATPHOTO_FIELD = "delete_chat_photo"; - private static final String GROUPCHATCREATED_FIELD = "group_chat_created"; + private static final String NEW_CHAT_MEMBERS_FIELD = "new_chat_members"; + private static final String LEFT_CHAT_MEMBER_FIELD = "left_chat_member"; + private static final String NEW_CHAT_TITLE_FIELD = "new_chat_title"; + private static final String NEW_CHAT_PHOTO_FIELD = "new_chat_photo"; + private static final String DELETE_CHAT_PHOTO_FIELD = "delete_chat_photo"; + private static final String GROUP_CHAT_CREATED_FIELD = "group_chat_created"; private static final String REPLY_TO_MESSAGE_FIELD = "reply_to_message"; private static final String VOICE_FIELD = "voice"; private static final String CAPTION_FIELD = "caption"; - private static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created"; - private static final String CHANNELCHATCREATED_FIELD = "channel_chat_created"; - private static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id"; - private static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id"; - private static final String EDITDATE_FIELD = "edit_date"; + private static final String SUPER_GROUP_CREATED_FIELD = "supergroup_chat_created"; + private static final String CHANNEL_CHAT_CREATED_FIELD = "channel_chat_created"; + private static final String MIGRATE_TO_CHAT_FIELD = "migrate_to_chat_id"; + private static final String MIGRATE_FROM_CHAT_FIELD = "migrate_from_chat_id"; + private static final String EDIT_DATE_FIELD = "edit_date"; private static final String GAME_FIELD = "game"; - private static final String FORWARDFROMMESSAGEID_FIELD = "forward_from_message_id"; + private static final String FORWARD_FROM_MESSAGE_ID_FIELD = "forward_from_message_id"; private static final String INVOICE_FIELD = "invoice"; private static final String SUCCESSFUL_PAYMENT_FIELD = "successful_payment"; private static final String VIDEO_NOTE_FIELD = "video_note"; - private static final String AUTHORSIGNATURE_FIELD = "author_signature"; - private static final String FORWARDSIGNATURE_FIELD = "forward_signature"; - private static final String MEDIAGROUPID_FIELD = "media_group_id"; - private static final String CONNECTEDWEBSITE_FIELD = "connected_website"; - private static final String PASSPORTDATA_FIELD = "passport_data"; - private static final String FORWARDSENDERNAME_FIELD = "forward_sender_name"; + private static final String AUTHOR_SIGNATURE_FIELD = "author_signature"; + private static final String FORWARD_SIGNATURE_FIELD = "forward_signature"; + private static final String MEDIA_GROUP_ID_FIELD = "media_group_id"; + private static final String CONNECTED_WEBSITE_FIELD = "connected_website"; + private static final String PASSPORT_DATA_FIELD = "passport_data"; + private static final String FORWARD_SENDER_NAME_FIELD = "forward_sender_name"; private static final String POLL_FIELD = "poll"; private static final String REPLY_MARKUP_FIELD = "reply_markup"; private static final String DICE_FIELD = "dice"; - private static final String VIABOT_FIELD = "via_bot"; - private static final String SENDERCHAT_FIELD = "sender_chat"; - private static final String PROXIMITYALERTTRIGGERED_FIELD = "proximity_alert_triggered"; - private static final String MESSAGEAUTODELETETIMERCHANGED_FIELD = "message_auto_delete_timer_changed"; - private static final String ISAUTOMATICFORWARD_FIELD = "is_automatic_forward"; - private static final String HASPROTECTEDCONTENT_FIELD = "has_protected_content"; - private static final String WEBAPPDATA_FIELD = "web_app_data"; - private static final String VIDEOCHATSCHEDULED_FIELD = "video_chat_scheduled"; - private static final String VIDEOCHATSTARTED_FIELD = "video_chat_started"; - private static final String VIDEOCHATENDED_FIELD = "video_chat_ended"; - private static final String VIDEOCHATPARTICIPANTSINVITED_FIELD = "video_chat_participants_invited"; - private static final String ISTOPICMESSAGE_FIELD = "is_topic_message"; - private static final String FORUMTOPICCREATED_FIELD = "forum_topic_created"; - private static final String FORUMTOPICCLOSED_FIELD = "forum_topic_closed"; - private static final String FORUMTOPICREOPENED_FIELD = "forum_topic_reopened"; - private static final String FORUMTOPICEDITED_FIELD = "forum_topic_edited"; - private static final String GENERALFORUMTOPICHIDDEN_FIELD = "general_forum_topic_hidden"; - private static final String GENERALFORUMTOPICUNHIDDEN_FIELD = "general_forum_topic_unhidden"; - private static final String WRITEACCESSALLOWED_FIELD = "write_access_allowed"; - private static final String HASMEDIASPOILER_FIELD = "has_media_spoiler"; - private static final String USERSHARED_FIELD = "user_shared"; - private static final String CHATSHARED_FIELD = "chat_shared"; - private static final String STORY_FIELD = "story"; + private static final String VIA_BOT_FIELD = "via_bot"; + private static final String SENDER_CHAT_FIELD = "sender_chat"; + private static final String PROXIMITY_ALERT_TRIGGERED_FIELD = "proximity_alert_triggered"; + private static final String MESSAGE_AUTO_DELETE_TIMER_CHANGED_FIELD = "message_auto_delete_timer_changed"; + private static final String IS_AUTOMATIC_FORWARD_FIELD = "is_automatic_forward"; + private static final String HAS_PROTECTED_CONTENT_FIELD = "has_protected_content"; + private static final String WEB_APP_DATA_FIELD = "web_app_data"; + private static final String VIDEO_CHAT_SCHEDULED_FIELD = "video_chat_scheduled"; + private static final String VIDEO_CHAT_STARTED_FIELD = "video_chat_started"; + private static final String VIDEO_CHAT_ENDED_FIELD = "video_chat_ended"; + private static final String VIDEO_CHAT_PARTICIPANTS_INVITED_FIELD = "video_chat_participants_invited"; + private static final String IS_TOPIC_MESSAGE_FIELD = "is_topic_message"; + private static final String FORUM_TOPIC_CREATED_FIELD = "forum_topic_created"; + private static final String FORUM_TOPIC_CLOSED_FIELD = "forum_topic_closed"; + private static final String FORUM_TOPIC_REOPENED_FIELD = "forum_topic_reopened"; + private static final String FORUM_TOPIC_EDITED_FIELD = "forum_topic_edited"; + private static final String GENERAL_FORUM_TOPIC_HIDDEN_FIELD = "general_forum_topic_hidden"; + private static final String GENERAL_FORUM_TOPIC_UNHIDDEN_FIELD = "general_forum_topic_unhidden"; private static final String WRITE_ACCESS_ALLOWED_FIELD = "write_access_allowed"; + private static final String HAS_MEDIA_SPOILER_FIELD = "has_media_spoiler"; + private static final String USER_SHARED_FIELD = "user_shared"; + private static final String CHAT_SHARED_FIELD = "chat_shared"; + private static final String STORY_FIELD = "story"; private static final String EXTERNAL_REPLY_FIELD = "external_reply"; private static final String FORWARD_ORIGIN_FIELD = "forward_origin"; private static final String LINK_PREVIEW_OPTIONS_FIELD = "link_preview_options"; @@ -179,18 +178,19 @@ public class Message implements MaybeInaccessibleMessage { /** * Integer Unique message identifier */ - @JsonProperty(MESSAGEID_FIELD) + @JsonProperty(MESSAGE_ID_FIELD) private Integer messageId; /** * Optional. * Unique identifier of a message thread or a forum topic to which the message belongs; * for supergroups only */ - @JsonProperty(MESSAGETHREADID_FIELD) + @JsonProperty(MESSAGE_THREAD_ID_FIELD) private Integer messageThreadId; /** * Optional. - * Sender, can be empty for messages sent to channels + * Sender of the message; may be empty for messages sent to channels. + * For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats */ @JsonProperty(FROM_FIELD) private User from; @@ -208,19 +208,19 @@ public class Message implements MaybeInaccessibleMessage { * Optional. * For forwarded messages, sender of the original message */ - @JsonProperty(FORWARDFROM_FIELD) + @JsonProperty(FORWARD_FROM_FIELD) private User forwardFrom; /** * Optional. * For messages forwarded from channels or from anonymous administrators, information about the original sender chat */ - @JsonProperty(FORWARDFROMCHAT_FIELD) + @JsonProperty(FORWARD_FROM_CHAT_FIELD) private Chat forwardFromChat; /** * Optional. * For forwarded messages, date the original message was sent */ - @JsonProperty(FORWARDDATE_FIELD) + @JsonProperty(FORWARD_DATE_FIELD) private Integer forwardDate; /** * Optional. @@ -240,7 +240,7 @@ public class Message implements MaybeInaccessibleMessage { * For messages with a caption, special entities like usernames, * URLs, bot commands, etc. that appear in the caption */ - @JsonProperty(CAPTIONENTITIES_FIELD) + @JsonProperty(CAPTION_ENTITIES_FIELD) private List captionEntities; /** * Optional. @@ -307,37 +307,37 @@ public class Message implements MaybeInaccessibleMessage { * Optional. * New members were added to the group or supergroup, information about them (the bot itself may be one of these members) */ - @JsonProperty(NEWCHATMEMBERS_FIELD) + @JsonProperty(NEW_CHAT_MEMBERS_FIELD) private List newChatMembers; /** * Optional. * A member was removed from the group, information about them (this member may be bot itself) */ - @JsonProperty(LEFTCHATMEMBER_FIELD) + @JsonProperty(LEFT_CHAT_MEMBER_FIELD) private User leftChatMember; /** * Optional. * A chat title was changed to this value */ - @JsonProperty(NEWCHATTITLE_FIELD) + @JsonProperty(NEW_CHAT_TITLE_FIELD) private String newChatTitle; /** * Optional. * A chat photo was change to this value */ - @JsonProperty(NEWCHATPHOTO_FIELD) + @JsonProperty(NEW_CHAT_PHOTO_FIELD) private List newChatPhoto; /** * Optional. * Informs that the chat photo was deleted */ - @JsonProperty(DELETECHATPHOTO_FIELD) + @JsonProperty(DELETE_CHAT_PHOTO_FIELD) private Boolean deleteChatPhoto; /** * Optional. * Informs that the group has been created */ - @JsonProperty(GROUPCHATCREATED_FIELD) + @JsonProperty(GROUP_CHAT_CREATED_FIELD) private Boolean groupchatCreated; /** * Optional. @@ -365,7 +365,7 @@ public class Message implements MaybeInaccessibleMessage { * It can only be found in reply_to_message * if someone replies to a very first message in a directly created supergroup. */ - @JsonProperty(SUPERGROUPCREATED_FIELD) + @JsonProperty(SUPER_GROUP_CREATED_FIELD) private Boolean superGroupCreated; /** * Optional. Service message: the channel has been created. @@ -374,7 +374,7 @@ public class Message implements MaybeInaccessibleMessage { * It can only be found in reply_to_message if someone * replies to a very first message in a channel. */ - @JsonProperty(CHANNELCHATCREATED_FIELD) + @JsonProperty(CHANNEL_CHAT_CREATED_FIELD) private Boolean channelChatCreated; /** * Optional. The group has been migrated to a supergroup with the specified identifier. @@ -383,7 +383,7 @@ public class Message implements MaybeInaccessibleMessage { * But it smaller than 52 bits, so a signed 64 bit integer or double-precision * float type are safe for storing this identifier. */ - @JsonProperty(MIGRATETOCHAT_FIELD) + @JsonProperty(MIGRATE_TO_CHAT_FIELD) private Long migrateToChatId; /** * Optional. The supergroup has been migrated from a group with the specified identifier. @@ -392,13 +392,13 @@ public class Message implements MaybeInaccessibleMessage { * But it smaller than 52 bits, so a signed 64 bit integer or double-precision * float type are safe for storing this identifier. */ - @JsonProperty(MIGRATEFROMCHAT_FIELD) + @JsonProperty(MIGRATE_FROM_CHAT_FIELD) private Long migrateFromChatId; /** * Optional. * Date the message was last edited in Unix time */ - @JsonProperty(EDITDATE_FIELD) + @JsonProperty(EDIT_DATE_FIELD) private Integer editDate; /** * Optional. @@ -410,7 +410,7 @@ public class Message implements MaybeInaccessibleMessage { * Optional. * For forwarded channel posts, identifier of the original message in the channel */ - @JsonProperty(FORWARDFROMMESSAGEID_FIELD) + @JsonProperty(FORWARD_FROM_MESSAGE_ID_FIELD) private Integer forwardFromMessageId; /** * Optional. @@ -434,37 +434,37 @@ public class Message implements MaybeInaccessibleMessage { * Optional. * Signature of the post author for messages in channels, or the custom title of an anonymous group administrator */ - @JsonProperty(AUTHORSIGNATURE_FIELD) + @JsonProperty(AUTHOR_SIGNATURE_FIELD) private String authorSignature; /** * Optional. * Post author signature for messages forwarded from channel chats */ - @JsonProperty(FORWARDSIGNATURE_FIELD) + @JsonProperty(FORWARD_SIGNATURE_FIELD) private String forwardSignature; /** * Optional. * The unique identifier of a media message group this message belongs to */ - @JsonProperty(MEDIAGROUPID_FIELD) + @JsonProperty(MEDIA_GROUP_ID_FIELD) private String mediaGroupId; /** * Optional. * The domain name of the website on which the user has logged in */ - @JsonProperty(CONNECTEDWEBSITE_FIELD) + @JsonProperty(CONNECTED_WEBSITE_FIELD) private String connectedWebsite; /** * Optional. * Telegram Passport data */ - @JsonProperty(PASSPORTDATA_FIELD) + @JsonProperty(PASSPORT_DATA_FIELD) private PassportData passportData; /** * Optional. * Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages. */ - @JsonProperty(FORWARDSENDERNAME_FIELD) + @JsonProperty(FORWARD_SENDER_NAME_FIELD) private String forwardSenderName; /** * Optional. @@ -489,137 +489,139 @@ public class Message implements MaybeInaccessibleMessage { * Optional. * Bot through which the message was sent */ - @JsonProperty(VIABOT_FIELD) + @JsonProperty(VIA_BOT_FIELD) private User viaBot; /** * Optional. - * Sender of the message, sent on behalf of a chat. The channel itself for channel messages. - * The supergroup itself for messages from anonymous group administrators. - * The linked channel for messages automatically forwarded to the discussion group + * Sender of the message when sent on behalf of a chat. + * For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel + * for messages automatically forwarded to the channel's discussion group. + * For backward compatibility, if the message was sent on behalf of a chat, + * the field from contains a fake sender user in non-channel chats. */ - @JsonProperty(SENDERCHAT_FIELD) + @JsonProperty(SENDER_CHAT_FIELD) private Chat senderChat; /** * Optional. * Service message. * A user in the chat triggered another user's proximity alert while sharing Live Location. */ - @JsonProperty(PROXIMITYALERTTRIGGERED_FIELD) + @JsonProperty(PROXIMITY_ALERT_TRIGGERED_FIELD) private ProximityAlertTriggered proximityAlertTriggered; /** * Optional. * Service message: auto-delete timer settings changed in the chat */ - @JsonProperty(MESSAGEAUTODELETETIMERCHANGED_FIELD) + @JsonProperty(MESSAGE_AUTO_DELETE_TIMER_CHANGED_FIELD) private MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged; /** * Optional. * True, if the message is a channel post that was automatically forwarded to the connected discussion group */ - @JsonProperty(ISAUTOMATICFORWARD_FIELD) + @JsonProperty(IS_AUTOMATIC_FORWARD_FIELD) private Boolean isAutomaticForward; /** * Optional. * True, if the message can't be forwarded */ - @JsonProperty(HASPROTECTEDCONTENT_FIELD) + @JsonProperty(HAS_PROTECTED_CONTENT_FIELD) private Boolean hasProtectedContent; /** * Optional. * Service message: data sent by a web app */ - @JsonProperty(WEBAPPDATA_FIELD) + @JsonProperty(WEB_APP_DATA_FIELD) private WebAppData webAppData; /** * Optional. * Service message: video chat started */ - @JsonProperty(VIDEOCHATSTARTED_FIELD) + @JsonProperty(VIDEO_CHAT_STARTED_FIELD) private VideoChatStarted videoChatStarted; /** * Optional. * Service message: video chat ended */ - @JsonProperty(VIDEOCHATENDED_FIELD) + @JsonProperty(VIDEO_CHAT_ENDED_FIELD) private VideoChatEnded videoChatEnded; /** * Optional. * Service message: new participants invited to a video chat */ - @JsonProperty(VIDEOCHATPARTICIPANTSINVITED_FIELD) + @JsonProperty(VIDEO_CHAT_PARTICIPANTS_INVITED_FIELD) private VideoChatParticipantsInvited videoChatParticipantsInvited; /** * Optional. * Service message: video chat scheduled */ - @JsonProperty(VIDEOCHATSCHEDULED_FIELD) + @JsonProperty(VIDEO_CHAT_SCHEDULED_FIELD) private VideoChatScheduled videoChatScheduled; /** * Optional. * True, if the message is sent to a forum topic */ - @JsonProperty(ISTOPICMESSAGE_FIELD) + @JsonProperty(IS_TOPIC_MESSAGE_FIELD) private Boolean isTopicMessage; /** * Optional. * Service message: forum topic created */ - @JsonProperty(FORUMTOPICCREATED_FIELD) + @JsonProperty(FORUM_TOPIC_CREATED_FIELD) private ForumTopicCreated forumTopicCreated; /** * Optional. * Service message: forum topic closed */ - @JsonProperty(FORUMTOPICCLOSED_FIELD) + @JsonProperty(FORUM_TOPIC_CLOSED_FIELD) private ForumTopicClosed forumTopicClosed; /** * Optional. * Service message: forum topic reopened */ - @JsonProperty(FORUMTOPICREOPENED_FIELD) + @JsonProperty(FORUM_TOPIC_REOPENED_FIELD) private ForumTopicReopened forumTopicReopened; /** * Optional. * Service message: forum topic edited */ - @JsonProperty(FORUMTOPICEDITED_FIELD) + @JsonProperty(FORUM_TOPIC_EDITED_FIELD) private ForumTopicEdited forumTopicEdited; /** * Optional. * Service message: General forum topic hidden */ - @JsonProperty(GENERALFORUMTOPICHIDDEN_FIELD) + @JsonProperty(GENERAL_FORUM_TOPIC_HIDDEN_FIELD) private GeneralForumTopicHidden generalForumTopicHidden; /** * Optional. * Service message: General forum topic unhidden */ - @JsonProperty(GENERALFORUMTOPICUNHIDDEN_FIELD) + @JsonProperty(GENERAL_FORUM_TOPIC_UNHIDDEN_FIELD) private GeneralForumTopicUnhidden generalForumTopicUnhidden; /** * Optional. * Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, * launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess */ - @JsonProperty(WRITEACCESSALLOWED_FIELD) + @JsonProperty(WRITE_ACCESS_ALLOWED_FIELD) private WriteAccessAllowed writeAccessAllowed; /** * Optional. * True, if the message media is covered by a spoiler animation */ - @JsonProperty(HASMEDIASPOILER_FIELD) + @JsonProperty(HAS_MEDIA_SPOILER_FIELD) private Boolean hasMediaSpoiler; /** * Optional. * Service message: a user was shared with the bot */ - @JsonProperty(USERSHARED_FIELD) + @JsonProperty(USER_SHARED_FIELD) private UserShared userShared; /** * Optional. * Service message: a chat was shared with the bot */ - @JsonProperty(CHATSHARED_FIELD) + @JsonProperty(CHAT_SHARED_FIELD) private ChatShared chatShared; /** * Optional. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java index 6876c9fef..cb56dcb40 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java @@ -11,6 +11,9 @@ import lombok.experimental.SuperBuilder; import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.api.objects.payments.paidmedia.PaidMedia; + +import java.util.List; /** * @author Ruben Bermudez @@ -31,6 +34,7 @@ public class TransactionPartnerUser implements TransactionPartner { private static final String TYPE_FIELD = "type"; private static final String USER_FIELD = "user"; private static final String INVOICE_PAYLOAD_FIELD = "invoice_payload"; + private static final String PAID_MEDIA_FIELD = "paid_media"; /** * Type of the transaction partner, always “user” @@ -49,4 +53,10 @@ public class TransactionPartnerUser implements TransactionPartner { */ @JsonProperty(INVOICE_PAYLOAD_FIELD) private String invoicePayload; + /** + * Optional. + * Information about the paid media bought by the user + */ + @JsonProperty(PAID_MEDIA_FIELD) + private List paidMedia; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionType.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionType.java index 01af8d47d..dca07fee4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionType.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionType.java @@ -18,9 +18,13 @@ ) @JsonSubTypes({ @JsonSubTypes.Type(value = ReactionTypeEmoji.class, name = ReactionType.EMOJI_TYPE), - @JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = ReactionType.CUSTOM_EMOJI_TYPE) + @JsonSubTypes.Type(value = ReactionTypeCustomEmoji.class, name = ReactionType.CUSTOM_EMOJI_TYPE), + @JsonSubTypes.Type(value = ReactionTypePaid.class, name = ReactionType.PAID_TYPE) }) public interface ReactionType extends Validable, BotApiObject { String EMOJI_TYPE = "emoji"; String CUSTOM_EMOJI_TYPE = "custom_emoji"; + String PAID_TYPE = "paid"; + + String getType(); } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java new file mode 100644 index 000000000..f32c4060e --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java @@ -0,0 +1,48 @@ +package org.telegram.telegrambots.meta.api.objects.reactions; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 7.0 + * The reaction is paid. + */ + +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@SuperBuilder +@Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) +public class ReactionTypePaid implements ReactionType { + private static final String TYPE_FIELD = "type"; + + /** + * Type of the reaction, always “paid” + */ + @JsonProperty(TYPE_FIELD) + @NonNull + @Builder.Default + private String type = ReactionType.PAID_TYPE; + + + @Override + public void validate() throws TelegramApiValidationException { + if (!ReactionType.PAID_TYPE.equals(type)) { + throw new TelegramApiValidationException("Type must be \"paid\"", this); + } + } +} diff --git a/telegrambots-springboot-longpolling-starter/pom.xml b/telegrambots-springboot-longpolling-starter/pom.xml index e79d50fa6..1dc45919d 100644 --- a/telegrambots-springboot-longpolling-starter/pom.xml +++ b/telegrambots-springboot-longpolling-starter/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-springboot-longpolling-starter @@ -71,7 +71,7 @@ UTF-8 UTF-8 - 7.8.0 + 7.9.0 3.2.3 diff --git a/telegrambots-springboot-webhook-starter/pom.xml b/telegrambots-springboot-webhook-starter/pom.xml index 252978750..854d4191a 100644 --- a/telegrambots-springboot-webhook-starter/pom.xml +++ b/telegrambots-springboot-webhook-starter/pom.xml @@ -6,7 +6,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-springboot-webhook-starter @@ -71,7 +71,7 @@ UTF-8 UTF-8 - 7.8.0 + 7.9.0 3.2.3 2.17.2 diff --git a/telegrambots-test-reports/pom.xml b/telegrambots-test-reports/pom.xml index fbf44a101..87211d5ac 100644 --- a/telegrambots-test-reports/pom.xml +++ b/telegrambots-test-reports/pom.xml @@ -6,7 +6,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-test-reports diff --git a/telegrambots-webhook/pom.xml b/telegrambots-webhook/pom.xml index cf9784fe7..865ae1875 100644 --- a/telegrambots-webhook/pom.xml +++ b/telegrambots-webhook/pom.xml @@ -6,7 +6,7 @@ org.telegram Bots - 7.8.0 + 7.9.0 telegrambots-webhook