From bea63d4aaf41f59b47049456b32c64b868dc9354 Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Sat, 31 Dec 2022 02:18:03 +0100 Subject: [PATCH] Api Version 6.4 --- .../methods/forum/CloseGeneralForumTopic.java | 69 ++++++++++++++++ .../api/methods/forum/EditForumTopic.java | 18 +++-- .../methods/forum/EditGeneralForumTopic.java | 80 +++++++++++++++++++ .../methods/forum/HideGeneralForumTopic.java | 70 ++++++++++++++++ .../forum/ReopenGeneralForumTopic.java | 70 ++++++++++++++++ .../forum/UnhideGeneralForumTopic.java | 69 ++++++++++++++++ .../groupadministration/GetChatMember.java | 1 + .../meta/api/methods/send/SendAnimation.java | 6 ++ .../meta/api/methods/send/SendChatAction.java | 7 ++ .../meta/api/methods/send/SendPhoto.java | 7 +- .../meta/api/methods/send/SendVideo.java | 6 ++ .../telegrambots/meta/api/objects/Chat.java | 17 ++++ .../meta/api/objects/Message.java | 38 +++++++++ .../meta/api/objects/WriteAccessAllowed.java | 22 +++++ .../api/objects/forum/ForumTopicEdited.java | 42 ++++++++++ .../forum/GeneralForumTopicHidden.java | 23 ++++++ .../forum/GeneralForumTopicUnhidden.java | 23 ++++++ .../objects/media/InputMediaAnimation.java | 12 ++- .../api/objects/media/InputMediaPhoto.java | 15 +++- .../api/objects/media/InputMediaVideo.java | 13 ++- .../serialization/InputMediaSerializer.java | 12 +++ .../replykeyboard/ReplyKeyboardMarkup.java | 9 ++- .../telegrambots/bots/DefaultAbsSender.java | 9 +++ 23 files changed, 626 insertions(+), 12 deletions(-) create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicEdited.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicHidden.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicUnhidden.java diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java new file mode 100644 index 00000000..57ae59b5 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java @@ -0,0 +1,69 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.4 + * 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 True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class CloseGeneralForumTopic extends BotApiMethodBoolean { + public static final String PATH = "closeGeneralForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class CloseGeneralForumTopicBuilder { + + @Tolerate + public CloseGeneralForumTopicBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java index 0a08be37..d1c18042 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java @@ -51,18 +51,20 @@ public class EditForumTopic extends BotApiMethodBoolean { @NonNull private Integer messageThreadId; /** - * Topic name, 1-128 characters + * Optional. + * New topic name, 0-128 characters. + * If not specified or empty, the current name of the topic will be kept */ @JsonProperty(NAME_FIELD) - @NonNull private String name; /** * Optional. - * Unique identifier of the custom emoji shown as the topic icon. - * Use getForumTopicIconStickers to get all allowed custom emoji identifiers + * New unique identifier of the custom emoji shown as the topic icon. + * Use getForumTopicIconStickers to get all allowed custom emoji identifiers. + * Pass an empty string to remove the icon. + * If not specified, the current icon will be kept */ @JsonProperty(ICONCUSTOMEMOJIID_FIELD) - @NonNull private String iconCustomEmojiId; @Tolerate @@ -75,8 +77,10 @@ public class EditForumTopic extends BotApiMethodBoolean { if (chatId.isEmpty()) { throw new TelegramApiValidationException("ChatId can't be empty", this); } - if (name.isEmpty() || name.length() > 128) { - throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this); + if (name != null && !name.isEmpty()) { + if (name.length() > 128) { + throw new TelegramApiValidationException("Name must be less than 128 characters", this); + } } if (messageThreadId <= 0) { throw new TelegramApiValidationException("Message Thread Id can't be empty", this); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java new file mode 100644 index 00000000..7a830846 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java @@ -0,0 +1,80 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.4 + * Use this method to edit the name of the 'General' topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class EditGeneralForumTopic extends BotApiMethodBoolean { + public static final String PATH = "editGeneralForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String NAME_FIELD = "name"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Optional. + * New topic name, 1-128 characters + */ + @JsonProperty(NAME_FIELD) + @NonNull + private String name; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + if (name.isEmpty() || name.length() > 128) { + throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class EditGeneralForumTopicBuilder { + + @Tolerate + public EditGeneralForumTopicBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java new file mode 100644 index 00000000..6a7506fd --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java @@ -0,0 +1,70 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.4 + * Use this method to hide the '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 topic will be automatically closed if it was open. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class HideGeneralForumTopic extends BotApiMethodBoolean { + public static final String PATH = "hideGeneralForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class HideGeneralForumTopicBuilder { + + @Tolerate + public HideGeneralForumTopicBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java new file mode 100644 index 00000000..00962027 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java @@ -0,0 +1,70 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.4 + * Use this method to reopen a closed '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 topic will be automatically unhidden if it was hidden. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ReopenGeneralForumTopic extends BotApiMethodBoolean { + public static final String PATH = "reopenGeneralForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class ReopenGeneralForumTopicBuilder { + + @Tolerate + public ReopenGeneralForumTopicBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java new file mode 100644 index 00000000..5cde1ef2 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java @@ -0,0 +1,69 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.4 + * Use this method to unhide the '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 True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class UnhideGeneralForumTopic extends BotApiMethodBoolean { + public static final String PATH = "unhideGeneralForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class UnhideGeneralForumTopicBuilder { + + @Tolerate + public UnhideGeneralForumTopicBuilder 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/GetChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java index 283884ce..ff1cea72 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java @@ -19,6 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; * @author Ruben Bermudez * @version 1.0 * Use this method to get information about a member of a chat. + * The method is guaranteed to work only if the bot is an administrator in the chat. * Returns a ChatMember object on success. */ @EqualsAndHashCode(callSuper = false) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java index 29f86c59..6e636a82 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java @@ -55,6 +55,7 @@ public class SendAnimation extends PartialBotApiMethod { public static final String CAPTION_ENTITIES_FIELD = "caption_entities"; public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply"; public static final String PROTECTCONTENT_FIELD = "protect_content"; + public static final String HASSPOILER_FIELD = "has_spoiler"; @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) @@ -91,6 +92,11 @@ public class SendAnimation extends PartialBotApiMethod { private List captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving + /** + * Optional. + * Pass True if the animation must be covered with a spoiler animation + */ + private Boolean hasSpoiler; @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java index 592044db..ffdb4420 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java @@ -35,6 +35,7 @@ public class SendChatAction extends BotApiMethodBoolean { public static final String CHATID_FIELD = "chat_id"; private static final String ACTION_FIELD = "action"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; @JsonProperty(CHATID_FIELD) @NonNull @@ -54,6 +55,12 @@ public class SendChatAction extends BotApiMethodBoolean { @JsonProperty(ACTION_FIELD) @NonNull private String action; + /** + * Optional + * Unique identifier for the target message thread; supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java index dbb3a6e8..9ac59020 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java @@ -49,6 +49,7 @@ public class SendPhoto extends PartialBotApiMethod { public static final String CAPTION_ENTITIES_FIELD = "caption_entities"; public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply"; public static final String PROTECTCONTENT_FIELD = "protect_content"; + public static final String HASSPOILER_FIELD = "has_spoiler"; @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) @@ -68,7 +69,11 @@ public class SendPhoto extends PartialBotApiMethod { private List captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving - + /** + * Optional. + * Pass True if the photo must be covered with a spoiler animation + */ + private Boolean hasSpoiler; @Tolerate public void setChatId(@NonNull Long chatId) { this.chatId = chatId.toString(); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java index bfd9d850..bb830cd2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java @@ -54,6 +54,7 @@ public class SendVideo extends PartialBotApiMethod { public static final String CAPTION_ENTITIES_FIELD = "caption_entities"; public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply"; public static final String PROTECTCONTENT_FIELD = "protect_content"; + public static final String HASSPOILER_FIELD = "has_spoiler"; @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) @@ -86,6 +87,11 @@ public class SendVideo extends PartialBotApiMethod { private List captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving + /** + * Optional. + * Pass True if the video must be covered with a spoiler animation + */ + private Boolean hasSpoiler; @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java index 113f6c04..307abad6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java @@ -55,6 +55,8 @@ public class Chat implements BotApiObject { private static final String ISFORUM_FIELD = "is_forum"; private static final String ACTIVEUSERNAMES_FIELD = "active_usernames"; private static final String EMOJISTATUSCUSTOMEMOJIID_FIELD = "emoji_status_custom_emoji_id"; + private static final String HASAGGRESSIVEANTISPAMENABLED_FIELD = "has_aggressive_anti_spam_enabled"; + private static final String HASHIDDENMEMBERS_FIELD = "has_hidden_members"; private static final String USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; @@ -235,6 +237,21 @@ public class Chat implements BotApiObject { */ @JsonProperty(EMOJISTATUSCUSTOMEMOJIID_FIELD) private String emojiStatusCustomEmojiId; + /** + * Optional. + * True, if aggressive anti-spam checks are enabled in the supergroup. + * The field is only available to chat administrators. + * Returned only in getChat. + */ + @JsonProperty(HASAGGRESSIVEANTISPAMENABLED_FIELD) + private Boolean hasAggressiveAntiSpamEnabled; + /** + * Optional. + * True, if non-administrators can only get the list of bots and administrators in the chat. + * Returned only in getChat. + */ + @JsonProperty(HASHIDDENMEMBERS_FIELD) + private Boolean hasHiddenMembers; @JsonIgnore public Boolean isGroupChat() { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java index efde20c3..7356cfe5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java @@ -11,7 +11,10 @@ import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicClosed; import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicCreated; +import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicEdited; import org.telegram.telegrambots.meta.api.objects.forum.ForumTopicReopened; +import org.telegram.telegrambots.meta.api.objects.forum.GeneralForumTopicHidden; +import org.telegram.telegrambots.meta.api.objects.forum.GeneralForumTopicUnhidden; import org.telegram.telegrambots.meta.api.objects.games.Animation; import org.telegram.telegrambots.meta.api.objects.games.Game; import org.telegram.telegrambots.meta.api.objects.passport.PassportData; @@ -105,6 +108,11 @@ public class Message implements BotApiObject { 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"; /** * Integer Unique message identifier @@ -503,6 +511,36 @@ public class Message implements BotApiObject { */ @JsonProperty(FORUMTOPICREOPENED_FIELD) private ForumTopicReopened forumTopicReopened; + /** + * Optional. + * Service message: forum topic edited + */ + @JsonProperty(FORUMTOPICEDITED_FIELD) + private ForumTopicEdited forumTopicEdited; + /** + * Optional. + * Service message: General forum topic hidden + */ + @JsonProperty(GENERALFORUMTOPICHIDDEN_FIELD) + private GeneralForumTopicHidden generalForumTopicHidden; + /** + * Optional. + * Service message: General forum topic unhidden + */ + @JsonProperty(GENERALFORUMTOPICUNHIDDEN_FIELD) + private GeneralForumTopicUnhidden generalForumTopicUnhidden; + /** + * Optional. + * Service message: the user allowed the bot added to the attachment menu to write messages + */ + @JsonProperty(WRITEACCESSALLOWED_FIELD) + private WriteAccessAllowed writeAccessAllowed; + /** + * Optional. + * True, if the message media is covered by a spoiler animation + */ + @JsonProperty(HASMEDIASPOILER_FIELD) + private Boolean hasMediaSpoiler; public List getEntities() { if (entities != null) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java new file mode 100644 index 00000000..9c835e96 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java @@ -0,0 +1,22 @@ +package org.telegram.telegrambots.meta.api.objects; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +/** + * This object represents a service message about a user allowing a bot added to the attachment menu to write messages. + * Currently holds no information. + * @author Ruben Bermudez + * @version 6.4 + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +public class WriteAccessAllowed implements BotApiObject { +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicEdited.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicEdited.java new file mode 100644 index 00000000..baf16c55 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicEdited.java @@ -0,0 +1,42 @@ +package org.telegram.telegrambots.meta.api.objects.forum; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +/** + * This object represents a service message about an edited forum topic. + * @author Ruben Bermudez + * @version 6.4 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ForumTopicEdited implements BotApiObject { + private static final String NAME_FIELD = "name"; + private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id"; + + + /** + * Optional. + * New name of the topic, if it was edited + */ + @JsonProperty(NAME_FIELD) + private String name; + /** + * Optional. + * New identifier of the custom emoji shown as the topic icon, if it was edited; + * an empty string if the icon was removed + */ + @JsonProperty(ICONCUSTOMEMOJIID_FIELD) + private String iconCustomEmojiId; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicHidden.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicHidden.java new file mode 100644 index 00000000..0045e41d --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicHidden.java @@ -0,0 +1,23 @@ +package org.telegram.telegrambots.meta.api.objects.forum; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +/** + * This object represents a service message about General forum topic hidden in the chat. + * Currently holds no information. + * @author Ruben Bermudez + * @version 6.4 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +public class GeneralForumTopicHidden implements BotApiObject { +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicUnhidden.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicUnhidden.java new file mode 100644 index 00000000..fe6f55a0 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/GeneralForumTopicUnhidden.java @@ -0,0 +1,23 @@ +package org.telegram.telegrambots.meta.api.objects.forum; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +/** + * This object represents a service message about General forum topic hidden in the chat. + * Currently holds no information. + * @author Ruben Bermudez + * @version 6.4 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +public class GeneralForumTopicUnhidden implements BotApiObject { +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java index 0e1e0fef..e9f76c98 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java @@ -35,6 +35,7 @@ public class InputMediaAnimation extends InputMedia { public static final String HEIGHT_FIELD = "height"; public static final String DURATION_FIELD = "duration"; public static final String THUMB_FIELD = "thumb"; + public static final String HASSPOILER_FIELD = "has_spoiler"; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Optional. Animation width @@ -50,6 +51,12 @@ public class InputMediaAnimation extends InputMedia { * if the thumbnail was uploaded using multipart/form-data under . */ private InputFile thumb; + /** + * Optional. + * Pass True if the animation must be covered with a spoiler animation + */ + @JsonProperty(HASSPOILER_FIELD) + private Boolean hasSpoiler; public InputMediaAnimation() { super(); @@ -60,12 +67,15 @@ public class InputMediaAnimation extends InputMedia { } @Builder - public InputMediaAnimation(@NonNull String media, String caption, String parseMode, List entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, Integer width, Integer height, Integer duration, InputFile thumb) { + public InputMediaAnimation(@NonNull String media, String caption, String parseMode, List entities, + boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, + Integer width, Integer height, Integer duration, InputFile thumb, Boolean hasSpoiler) { super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream); this.width = width; this.height = height; this.duration = duration; this.thumb = thumb; + this.hasSpoiler = hasSpoiler; } @Override diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaPhoto.java index b94bce1d..8ef62a64 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaPhoto.java @@ -1,5 +1,6 @@ package org.telegram.telegrambots.meta.api.objects.media; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -29,6 +30,15 @@ import java.util.List; public class InputMediaPhoto extends InputMedia { private static final String TYPE = "photo"; + public static final String HASSPOILER_FIELD = "has_spoiler"; + + /** + * Optional. + * Pass True if the photo must be covered with a spoiler animation + */ + @JsonProperty(HASSPOILER_FIELD) + private Boolean hasSpoiler; + public InputMediaPhoto() { super(); } @@ -38,8 +48,11 @@ public class InputMediaPhoto extends InputMedia { } @Builder - public InputMediaPhoto(@NonNull String media, String caption, String parseMode, List entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream) { + public InputMediaPhoto(@NonNull String media, String caption, String parseMode, List entities, + boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, + Boolean hasSpoiler) { super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream); + this.hasSpoiler = hasSpoiler; } @Override diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java index 4b35730d..b7ddc040 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java @@ -36,6 +36,7 @@ public class InputMediaVideo extends InputMedia { public static final String DURATION_FIELD = "duration"; public static final String SUPPORTSSTREAMING_FIELD = "supports_streaming"; public static final String THUMB_FIELD = "thumb"; + public static final String HASSPOILER_FIELD = "has_spoiler"; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Optional. Video width @@ -54,6 +55,12 @@ public class InputMediaVideo extends InputMedia { */ @JsonProperty(THUMB_FIELD) private InputFile thumb; + /** + * Optional. + * Pass True if the video must be covered with a spoiler animation + */ + @JsonProperty(HASSPOILER_FIELD) + private Boolean hasSpoiler; public InputMediaVideo() { } @@ -63,13 +70,17 @@ public class InputMediaVideo extends InputMedia { } @Builder - public InputMediaVideo(@NonNull String media, String caption, String parseMode, List entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, Integer width, Integer height, Integer duration, Boolean supportsStreaming, InputFile thumb) { + public InputMediaVideo(@NonNull String media, String caption, String parseMode, List entities, + boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, + Integer width, Integer height, Integer duration, Boolean supportsStreaming, InputFile thumb, + Boolean hasSpoiler) { super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream); this.width = width; this.height = height; this.duration = duration; this.supportsStreaming = supportsStreaming; this.thumb = thumb; + this.hasSpoiler = hasSpoiler; } @Override diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java index 4826450f..c3f5319b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java @@ -9,6 +9,7 @@ import org.telegram.telegrambots.meta.api.objects.media.InputMedia; import org.telegram.telegrambots.meta.api.objects.media.InputMediaAnimation; import org.telegram.telegrambots.meta.api.objects.media.InputMediaAudio; import org.telegram.telegrambots.meta.api.objects.media.InputMediaDocument; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaPhoto; import org.telegram.telegrambots.meta.api.objects.media.InputMediaVideo; import java.io.IOException; @@ -67,11 +68,19 @@ public class InputMediaSerializer extends JsonSerializer { if (animation.getWidth() != null) { gen.writeNumberField(InputMediaAnimation.WIDTH_FIELD, animation.getWidth()); } + if (animation.getHasSpoiler() != null) { + gen.writeBooleanField(InputMediaAnimation.HASSPOILER_FIELD, animation.getHasSpoiler()); + } } else if (value instanceof InputMediaDocument) { InputMediaDocument document = (InputMediaDocument) value; if (document.getThumb() != null) { gen.writeStringField(InputMediaDocument.THUMB_FIELD, document.getThumb().getAttachName()); } + } else if (value instanceof InputMediaPhoto) { + InputMediaPhoto photo = (InputMediaPhoto) value; + if (photo.getHasSpoiler() != null) { + gen.writeBooleanField(InputMediaPhoto.HASSPOILER_FIELD, photo.getHasSpoiler()); + } } else if (value instanceof InputMediaVideo) { InputMediaVideo video = (InputMediaVideo) value; if (video.getThumb() != null) { @@ -89,6 +98,9 @@ public class InputMediaSerializer extends JsonSerializer { if (video.getSupportsStreaming() != null) { gen.writeBooleanField(InputMediaVideo.SUPPORTSSTREAMING_FIELD, video.getSupportsStreaming()); } + if (video.getHasSpoiler() != null) { + gen.writeBooleanField(InputMediaVideo.HASSPOILER_FIELD, video.getHasSpoiler()); + } } gen.writeEndObject(); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java index dd8aa69e..6155f729 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java @@ -38,6 +38,7 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard { private static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard"; private static final String SELECTIVE_FIELD = "selective"; private static final String INPUTFIELDPLACEHOLDER_FIELD = "input_field_placeholder"; + private static final String ISPERSISTENT_FIELD = "is_persistent"; @JsonProperty(KEYBOARD_FIELD) @NonNull @@ -62,7 +63,13 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard { */ @JsonProperty(INPUTFIELDPLACEHOLDER_FIELD) private String inputFieldPlaceholder; - + /** + * Optional. + * Requests clients to always show the keyboard when the regular keyboard is hidden. + * Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. + */ + @JsonProperty(ISPERSISTENT_FIELD) + private Boolean isPersistent; @Override public void validate() throws TelegramApiValidationException { if (keyboard == null) { diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java index 90243603..0a7c24bf 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java @@ -249,6 +249,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendPhoto.getCaptionEntities() != null) { builder.addTextBody(SendPhoto.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendPhoto.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE); } + if (sendPhoto.getHasSpoiler() != null) { + builder.addTextBody(SendPhoto.HASSPOILER_FIELD, objectMapper.writeValueAsString(sendPhoto.getHasSpoiler()), TEXT_PLAIN_CONTENT_TYPE); + } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -316,6 +319,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendVideo.getCaptionEntities() != null) { builder.addTextBody(SendVideo.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendVideo.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE); } + if (sendVideo.getHasSpoiler() != null) { + builder.addTextBody(SendVideo.HASSPOILER_FIELD, objectMapper.writeValueAsString(sendVideo.getHasSpoiler()), TEXT_PLAIN_CONTENT_TYPE); + } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -821,6 +827,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendAnimation.getCaptionEntities() != null) { builder.addTextBody(SendAnimation.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendAnimation.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE); } + if (sendAnimation.getHasSpoiler() != null) { + builder.addTextBody(SendAnimation.HASSPOILER_FIELD, objectMapper.writeValueAsString(sendAnimation.getHasSpoiler()), TEXT_PLAIN_CONTENT_TYPE); + } HttpEntity multipart = builder.build(); httppost.setEntity(multipart);