From 95c2a597e14024448eb968fd3f99812d86298e82 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 29 Nov 2022 18:31:37 +0000 Subject: [PATCH 1/4] Fixing wrong JsonProperty name for StickerSet --- .../telegrambots/meta/api/objects/stickers/StickerSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java index a7cb85f2..b8d39ac5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java @@ -36,7 +36,7 @@ public class StickerSet implements BotApiObject { /** * Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji” */ - @JsonProperty(STICKERS_FIELD) + @JsonProperty(STICKERTYPE_FIELD) private String stickerType; /** * Sticker set name From 490756c79e923d6784defce96c2b0b9f8c6aba24 Mon Sep 17 00:00:00 2001 From: Robin Syl Date: Sun, 25 Sep 2022 13:55:06 +0200 Subject: [PATCH 2/4] Remove dependency on org.json:json --- pom.xml | 6 ------ .../telegram/abilitybots/api/objects/Stats.java | 1 - telegrambots-meta/pom.xml | 4 ---- .../exceptions/TelegramApiRequestException.java | 16 +--------------- telegrambots/pom.xml | 4 ---- .../updatesreceivers/DefaultBotSession.java | 11 +++-------- .../telegram/telegrambots/util/WebhookUtils.java | 9 +++++---- 7 files changed, 9 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index a51bed26..9652f12a 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,6 @@ 4.8.1 2.14.0 2.14.0 - 20220924 2.0.3 2.1.1 1.18.24 @@ -135,11 +134,6 @@ slf4j-api ${slf4j.version} - - org.json - json - ${json.version} - jakarta.annotation diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Stats.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Stats.java index 43b6b350..9abc4819 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Stats.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Stats.java @@ -3,7 +3,6 @@ package org.telegram.abilitybots.api.objects; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.MoreObjects; -import org.json.JSONPropertyIgnore; import java.io.Serializable; import java.util.Objects; diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 1d22e0fa..092982c1 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -90,10 +90,6 @@ com.google.guava guava - - org.json - json - org.projectlombok lombok diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java index d2f69e60..8add108b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java @@ -18,7 +18,6 @@ package org.telegram.telegrambots.meta.exceptions; import com.fasterxml.jackson.databind.ObjectMapper; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.objects.ApiResponse; @@ -48,20 +47,7 @@ public class TelegramApiRequestException extends TelegramApiException { super(message); } - public TelegramApiRequestException(String message, JSONObject object) { - super(message); - apiResponse = object.getString(ERRORDESCRIPTIONFIELD); - errorCode = object.getInt(ERRORCODEFIELD); - if (object.has(PARAMETERSFIELD)) { - try { - parameters = OBJECT_MAPPER.readValue(object.getJSONObject(PARAMETERSFIELD).toString(), ResponseParameters.class); - } catch (IOException e) { - log.error(e.getLocalizedMessage(), e); - } - } - } - - public TelegramApiRequestException(String message, ApiResponse response) { + public TelegramApiRequestException(String message, ApiResponse response) { super(message); apiResponse = response.getErrorDescription(); errorCode = response.getErrorCode(); diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index e9e82d8a..3744592a 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -152,10 +152,6 @@ - - org.json - json - org.apache.httpcomponents httpclient diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java index fec34b3e..6848f391 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultBotSession.java @@ -8,7 +8,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.telegram.telegrambots.bots.DefaultBotOptions; @@ -256,13 +255,9 @@ public class DefaultBotSession implements BotSession { lock.wait(500); } } else { - try { - List updates = request.deserializeResponse(responseContent); - backOff.reset(); - return updates; - } catch (JSONException e) { - log.error("Error deserializing update: " + responseContent, e); - } + List updates = request.deserializeResponse(responseContent); + backOff.reset(); + return updates; } } catch (SocketException | InvalidObjectException | TelegramApiRequestException e) { log.error(e.getLocalizedMessage(), e); diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java b/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java index 3f26566f..2a95601d 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java @@ -1,5 +1,7 @@ package org.telegram.telegrambots.util; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; @@ -9,8 +11,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import org.json.JSONArray; -import org.json.JSONException; import org.telegram.telegrambots.Constants; import org.telegram.telegrambots.bots.DefaultAbsSender; import org.telegram.telegrambots.bots.DefaultBotOptions; @@ -29,6 +29,7 @@ import static org.telegram.telegrambots.Constants.SOCKET_TIMEOUT; public final class WebhookUtils { private static final ContentType TEXT_PLAIN_CONTENT_TYPE = ContentType.create("text/plain", StandardCharsets.UTF_8); + private static final ObjectMapper objectMapper = new ObjectMapper(); private WebhookUtils() { @@ -66,7 +67,7 @@ public final class WebhookUtils { builder.addTextBody(SetWebhook.MAXCONNECTIONS_FIELD, setWebhook.getMaxConnections().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (setWebhook.getAllowedUpdates() != null) { - builder.addTextBody(SetWebhook.ALLOWEDUPDATES_FIELD, new JSONArray(setWebhook.getAllowedUpdates()).toString(), TEXT_PLAIN_CONTENT_TYPE); + builder.addTextBody(SetWebhook.ALLOWEDUPDATES_FIELD, objectMapper.writeValueAsString(setWebhook.getAllowedUpdates()), TEXT_PLAIN_CONTENT_TYPE); } if (setWebhook.getIpAddress() != null) { builder.addTextBody(SetWebhook.IPADDRESS_FIELD, setWebhook.getIpAddress(), TEXT_PLAIN_CONTENT_TYPE); @@ -95,7 +96,7 @@ public final class WebhookUtils { throw new TelegramApiRequestException("Error setting webhook:" + responseContent); } } - } catch (JSONException e) { + } catch (JsonProcessingException e) { throw new TelegramApiRequestException("Error deserializing setWebhook method response", e); } catch (IOException e) { throw new TelegramApiRequestException("Error executing setWebook method", e); From bea63d4aaf41f59b47049456b32c64b868dc9354 Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Sat, 31 Dec 2022 02:18:03 +0100 Subject: [PATCH 3/4] 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); From 7c7ba29283c32f6dc6b3b680d4fd84d86fcb873e Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Mon, 2 Jan 2023 19:02:45 +0100 Subject: [PATCH 4/4] Api Version 6.4 --- README.md | 8 ++++---- TelegramBots.wiki/Changelog.md | 4 ++++ TelegramBots.wiki/Getting-Started.md | 4 ++-- TelegramBots.wiki/abilities/Simple-Example.md | 4 ++-- pom.xml | 2 +- telegrambots-abilities/README.md | 4 ++-- telegrambots-abilities/pom.xml | 4 ++-- telegrambots-chat-session-bot/README.md | 4 ++-- telegrambots-chat-session-bot/pom.xml | 4 ++-- telegrambots-extensions/README.md | 4 ++-- telegrambots-extensions/pom.xml | 4 ++-- telegrambots-meta/pom.xml | 2 +- telegrambots-spring-boot-starter/README.md | 4 ++-- telegrambots-spring-boot-starter/pom.xml | 4 ++-- telegrambots/pom.xml | 4 ++-- 15 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 79b7b0be..6d9be4c4 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,18 @@ Just import add the library to your project with one of these options: org.telegram telegrambots - 6.3.0 + 6.4.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambots:6.3.0' + implementation 'org.telegram:telegrambots:6.4.0' ``` - 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.3.0) - 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.3.0) + 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.4.0) + 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.4.0) In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`. diff --git a/TelegramBots.wiki/Changelog.md b/TelegramBots.wiki/Changelog.md index a2d8800e..138f2352 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,3 +1,7 @@ +### 6.4.0 ### +1. Update Api version [6.4](https://core.telegram.org/bots/api-changelog#december-30-2022) +2. Bug fixing: #1159 + ### 6.3.0 ### 1. Update Api version [6.3](https://core.telegram.org/bots/api-changelog#November-5-2022) 2. Bug fixing: #1116 diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index 0257760b..6f19de41 100644 --- a/TelegramBots.wiki/Getting-Started.md +++ b/TelegramBots.wiki/Getting-Started.md @@ -11,13 +11,13 @@ First you need to acquire the library and add it to your project. There are seve org.telegram telegrambots - 6.3.0 + 6.4.0 ``` * With **Gradle**: ```gradle - implementation 'org.telegram:telegrambots:6.3.0' + implementation 'org.telegram:telegrambots:6.4.0' ``` 2. Don't like the **Maven Central Repository**? It can also be grabbed from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots). diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md index c39bc3aa..87cf3d8f 100644 --- a/TelegramBots.wiki/abilities/Simple-Example.md +++ b/TelegramBots.wiki/abilities/Simple-Example.md @@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies. org.telegram telegrambots-abilities - 6.3.0 + 6.4.0 ``` * **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.3.0' + implementation 'org.telegram:telegrambots-abilities:6.4.0' ``` * [JitPack](https://jitpack.io/#rubenlagus/TelegramBots) diff --git a/pom.xml b/pom.xml index 9652f12a..ef19c086 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 6.3.0 + 6.4.0 telegrambots diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index 9fc97ce7..a9e1cfca 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,14 +18,14 @@ Usage org.telegram telegrambots-abilities - 6.3.0 + 6.4.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.3.0' + implementation 'org.telegram:telegrambots-abilities:6.4.0' ``` **JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1) diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index e654ea3a..ae02b2e2 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambots-abilities @@ -84,7 +84,7 @@ org.telegram telegrambots - 6.3.0 + 6.4.0 org.apache.commons diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md index 0b183a2b..45dd93ed 100644 --- a/telegrambots-chat-session-bot/README.md +++ b/telegrambots-chat-session-bot/README.md @@ -15,14 +15,14 @@ Usage org.telegram telegrambots-chat-session-bot - 6.3.0 + 6.4.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-chat-session-bot:6.3.0' + implementation 'org.telegram:telegrambots-chat-session-bot:6.4.0' ``` Motivation diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index eea4233b..7bc8a742 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambots-chat-session-bot @@ -84,7 +84,7 @@ org.telegram telegrambots - 6.3.0 + 6.4.0 diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index b81fdad7..cec60de3 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 telegrambotsextensions - 6.3.0 + 6.4.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambotsextensions:6.3.0' + implementation 'org.telegram:telegrambotsextensions:6.4.0' ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index ef32737c..ba68eca5 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambotsextensions @@ -75,7 +75,7 @@ org.telegram telegrambots - 6.3.0 + 6.4.0 diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 092982c1..426db1b6 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambots-meta diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md index a1b03f6b..a6e25263 100644 --- a/telegrambots-spring-boot-starter/README.md +++ b/telegrambots-spring-boot-starter/README.md @@ -18,14 +18,14 @@ Usage org.telegram telegrambots-spring-boot-starter - 6.3.0 + 6.4.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-spring-boot-starter:6.3.0' + implementation 'org.telegram:telegrambots-spring-boot-starter:6.4.0' ``` Motivation diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index 1b739352..28d95491 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambots-spring-boot-starter @@ -70,7 +70,7 @@ UTF-8 UTF-8 - 6.3.0 + 6.4.0 2.7.5 1.6 diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 3744592a..48a199ae 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.3.0 + 6.4.0 telegrambots @@ -91,7 +91,7 @@ org.telegram telegrambots-meta - 6.3.0 + 6.4.0 org.projectlombok