From 1e040bea4d52eca705a9538afa0a164d8c770bf0 Mon Sep 17 00:00:00 2001 From: ruben Date: Tue, 8 Nov 2022 18:33:50 +0000 Subject: [PATCH] Api version 6.3 --- README.md | 8 +- TelegramBots.wiki/Getting-Started.md | 4 +- TelegramBots.wiki/abilities/Simple-Example.md | 4 +- pom.xml | 16 +-- telegrambots-abilities/README.md | 4 +- telegrambots-abilities/pom.xml | 4 +- telegrambots-chat-session-bot/README.md | 4 +- telegrambots-chat-session-bot/pom.xml | 6 +- telegrambots-extensions/README.md | 4 +- telegrambots-extensions/pom.xml | 4 +- telegrambots-meta/pom.xml | 2 +- .../meta/api/methods/CopyMessage.java | 7 ++ .../meta/api/methods/ForwardMessage.java | 7 ++ .../api/methods/forum/CloseForumTopic.java | 80 ++++++++++++++ .../api/methods/forum/CreateForumTopic.java | 103 ++++++++++++++++++ .../api/methods/forum/DeleteForumTopic.java | 80 ++++++++++++++ .../api/methods/forum/EditForumTopic.java | 102 +++++++++++++++++ .../forum/GetForumTopicIconStickers.java | 45 ++++++++ .../api/methods/forum/ReopenForumTopic.java | 81 ++++++++++++++ .../forum/UnpinAllForumTopicMessages.java | 80 ++++++++++++++ .../PromoteChatMember.java | 7 ++ .../groupadministration/SetChatTitle.java | 2 +- .../methods/invoices/CreateInvoiceLink.java | 15 +-- .../api/methods/invoices/SendInvoice.java | 13 ++- .../meta/api/methods/polls/SendPoll.java | 7 ++ .../meta/api/methods/send/SendAnimation.java | 6 + .../meta/api/methods/send/SendAudio.java | 6 + .../meta/api/methods/send/SendContact.java | 7 ++ .../meta/api/methods/send/SendDice.java | 7 ++ .../meta/api/methods/send/SendDocument.java | 6 + .../meta/api/methods/send/SendGame.java | 8 ++ .../meta/api/methods/send/SendLocation.java | 8 ++ .../meta/api/methods/send/SendMediaGroup.java | 12 +- .../meta/api/methods/send/SendMessage.java | 7 ++ .../meta/api/methods/send/SendPhoto.java | 6 + .../meta/api/methods/send/SendSticker.java | 6 + .../meta/api/methods/send/SendVenue.java | 7 ++ .../meta/api/methods/send/SendVideo.java | 6 + .../meta/api/methods/send/SendVideoNote.java | 6 + .../meta/api/methods/send/SendVoice.java | 6 + .../updatingmessages/DeleteMessage.java | 1 + .../telegrambots/meta/api/objects/Chat.java | 28 +++++ .../meta/api/objects/Message.java | 61 ++++++++++- .../adminrights/ChatAdministratorRights.java | 8 +- .../chatmember/ChatMemberAdministrator.java | 7 ++ .../chatmember/ChatMemberRestricted.java | 6 + .../meta/api/objects/forum/ForumTopic.java | 51 +++++++++ .../api/objects/forum/ForumTopicClosed.java | 24 ++++ .../api/objects/forum/ForumTopicCreated.java | 47 ++++++++ .../api/objects/forum/ForumTopicReopened.java | 24 ++++ .../invoices/CreateInvoiceLinkTest.java | 19 ++++ telegrambots-spring-boot-starter/README.md | 4 +- telegrambots-spring-boot-starter/pom.xml | 17 ++- telegrambots/pom.xml | 4 +- .../telegrambots/bots/DefaultAbsSender.java | 27 +++++ 55 files changed, 1062 insertions(+), 59 deletions(-) create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/GetForumTopicIconStickers.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopic.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicClosed.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicCreated.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicReopened.java diff --git a/README.md b/README.md index 63ac4288..79b7b0be 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.1.0 + 6.3.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambots:6.1.0' + implementation 'org.telegram:telegrambots:6.3.0' ``` - 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.1.0) - 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.1.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) In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`. diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index bc3011e1..0257760b 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.1.0 + 6.3.0 ``` * With **Gradle**: ```gradle - implementation 'org.telegram:telegrambots:6.1.0' + implementation 'org.telegram:telegrambots:6.3.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 6d48f310..c39bc3aa 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.1.0 + 6.3.0 ``` * **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.1.0' + implementation 'org.telegram:telegrambots-abilities:6.3.0' ``` * [JitPack](https://jitpack.io/#rubenlagus/TelegramBots) diff --git a/pom.xml b/pom.xml index cc549c0b..a51bed26 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 6.1.0 + 6.3.0 telegrambots @@ -67,13 +67,13 @@ ${java.version} ${java.version} - 5.8.2 - 4.6.1 - 4.6.1 - 2.13.2 - 2.13.2.2 - 20220320 - 1.7.36 + 5.9.1 + 4.8.1 + 4.8.1 + 2.14.0 + 2.14.0 + 20220924 + 2.0.3 2.1.1 1.18.24 31.1-jre diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index f24b712f..9fc97ce7 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,14 +18,14 @@ Usage org.telegram telegrambots-abilities - 6.1.0 + 6.3.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.1.0' + implementation 'org.telegram:telegrambots-abilities:6.3.0' ``` **JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1) diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index 47c9f4f8..e654ea3a 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambots-abilities @@ -84,7 +84,7 @@ org.telegram telegrambots - 6.1.0 + 6.3.0 org.apache.commons diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md index 6cc435af..0b183a2b 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.1.0 + 6.3.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-chat-session-bot:6.1.0' + implementation 'org.telegram:telegrambots-chat-session-bot:6.3.0' ``` Motivation diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index c66c1d8d..eea4233b 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambots-chat-session-bot @@ -76,7 +76,7 @@ UTF-8 UTF-8 - 1.9.1 + 1.10.0 @@ -84,7 +84,7 @@ org.telegram telegrambots - 6.1.0 + 6.3.0 diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index 866362f4..b81fdad7 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.1.0 + 6.3.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambotsextensions:6.1.0' + implementation 'org.telegram:telegrambotsextensions:6.3.0' ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index 21103c16..ef32737c 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambotsextensions @@ -75,7 +75,7 @@ org.telegram telegrambots - 6.1.0 + 6.3.0 diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 501ee0c6..1d22e0fa 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambots-meta diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java index bb6b7711..7a1c6a13 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java @@ -42,6 +42,7 @@ public class CopyMessage extends BotApiMethod { public static final String PATH = "copyMessage"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String FROMCHATID_FIELD = "from_chat_id"; private static final String MESSAGEID_FIELD = "message_id"; private static final String CAPTION_FIELD = "caption"; @@ -56,6 +57,12 @@ public class CopyMessage extends BotApiMethod { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(FROMCHATID_FIELD) @NonNull private String fromChatId; ///< Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java index 204b5d83..19848fe2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java @@ -34,6 +34,7 @@ public class ForwardMessage extends BotApiMethodMessage { public static final String PATH = "forwardmessage"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String FROMCHATID_FIELD = "from_chat_id"; private static final String MESSAGEID_FIELD = "message_id"; private static final String DISABLENOTIFICATION_FIELD = "disable_notification"; @@ -42,6 +43,12 @@ public class ForwardMessage extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(FROMCHATID_FIELD) @NonNull private String fromChatId; ///< Unique identifier for the chat where the original message was sent — User or GroupChat id diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java new file mode 100644 index 00000000..b7fa583d --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.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.3 + * Use this method to close an open topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must have + * the can_manage_topics administrator rights, unless it is the creator of the topic. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class CloseForumTopic extends BotApiMethodBoolean { + public static final String PATH = "closeForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Unique identifier for the target message thread of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + @NonNull + private Integer messageThreadId; + + @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 (messageThreadId <= 0) { + throw new TelegramApiValidationException("Message Thread Id can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class CloseForumTopicBuilder { + + @Tolerate + public CloseForumTopicBuilder 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/CreateForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java new file mode 100644 index 00000000..6173f6d0 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java @@ -0,0 +1,103 @@ +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.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.forum.ForumTopic; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.3 + * Use this method to create a 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 information about the created topic as a ForumTopic object. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@RequiredArgsConstructor +@AllArgsConstructor +@Builder +public class CreateForumTopic extends BotApiMethod { + public static final String PATH = "createForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String NAME_FIELD = "name"; + private static final String ICONCOLOR_FIELD = "icon_color"; + private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Topic name, 1-128 characters + */ + @JsonProperty(NAME_FIELD) + @NonNull + private String name; + /** + * Optional. + * Color of the topic icon in RGB format. Currently, + * must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F + */ + @JsonProperty(ICONCOLOR_FIELD) + private Integer iconColor; + /** + * Optional. + * Unique identifier of the custom emoji shown as the topic icon. + * Use getForumTopicIconStickers to get all allowed custom emoji identifiers + */ + @JsonProperty(ICONCUSTOMEMOJIID_FIELD) + private String iconCustomEmojiId; + + @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; + } + + @Override + public ForumTopic deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, ForumTopic.class); + } + + public static class CreateForumTopicBuilder { + + @Tolerate + public CreateForumTopicBuilder 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/DeleteForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java new file mode 100644 index 00000000..d926bc5e --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.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.3 + * Use this method to delete a forum topic along with all its messages in a + * forum supergroup chat. The bot must be an administrator in the chat + * for this to work and must have the can_delete_messages administrator rights. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DeleteForumTopic extends BotApiMethodBoolean { + public static final String PATH = "deleteForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Unique identifier for the target message thread of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + @NonNull + private Integer messageThreadId; + + @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 (messageThreadId <= 0) { + throw new TelegramApiValidationException("Message Thread Id can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class DeleteForumTopicBuilder { + + @Tolerate + public DeleteForumTopicBuilder 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 new file mode 100644 index 00000000..0a08be37 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java @@ -0,0 +1,102 @@ +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.3 + * Use this method to edit name and icon of a 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, unless it is the creator of the topic. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class EditForumTopic extends BotApiMethodBoolean { + public static final String PATH = "editForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + private static final String NAME_FIELD = "name"; + private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Unique identifier for the target message thread of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + @NonNull + private Integer messageThreadId; + /** + * Topic name, 1-128 characters + */ + @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 + */ + @JsonProperty(ICONCUSTOMEMOJIID_FIELD) + @NonNull + private String iconCustomEmojiId; + + @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); + } + if (messageThreadId <= 0) { + throw new TelegramApiValidationException("Message Thread Id can't be empty", this); + } + if (iconCustomEmojiId.isEmpty()) { + throw new TelegramApiValidationException("Icon Custom Emoji Id can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class EditForumTopicBuilder { + + @Tolerate + public EditForumTopicBuilder 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/GetForumTopicIconStickers.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/GetForumTopicIconStickers.java new file mode 100644 index 00000000..71556d0a --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/GetForumTopicIconStickers.java @@ -0,0 +1,45 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.methods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.stickers.Sticker; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import java.util.ArrayList; + +/** + * @author Ruben Bermudez + * @version 6.3 + * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. + * Returns an Array of Sticker objects. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@Builder +public class GetForumTopicIconStickers extends BotApiMethod> { + private static final String PATH = "getForumTopicIconStickers"; + + @Override + public void validate() throws TelegramApiValidationException { + + } + + @Override + public String getMethod() { + return PATH; + } + + @Override + public ArrayList deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponseArray(answer, Sticker.class); + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java new file mode 100644 index 00000000..3b762c37 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java @@ -0,0 +1,81 @@ +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.3 + * Use this method to reopen a closed topic in a forum supergroup chat. + * The bot must be an administrator in the chat for this to work and must + * have the can_manage_topics administrator rights, + * unless it is the creator of the topic. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ReopenForumTopic extends BotApiMethodBoolean { + public static final String PATH = "reopenForumTopic"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Unique identifier for the target message thread of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + @NonNull + private Integer messageThreadId; + + @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 (messageThreadId <= 0) { + throw new TelegramApiValidationException("Message Thread Id can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class ReopenForumTopicBuilder { + + @Tolerate + public ReopenForumTopicBuilder 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/UnpinAllForumTopicMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java new file mode 100644 index 00000000..1275e9cd --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.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.3 + * Use this method to clear the list of pinned messages in a forum topic. + * The bot must be an administrator in the chat for this to work and must + * have the can_pin_messages administrator right in the supergroup. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class UnpinAllForumTopicMessages extends BotApiMethodBoolean { + public static final String PATH = "unpinAllForumTopicMessages"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHATID_FIELD) + @NonNull + private String chatId; + /** + * Unique identifier for the target message thread of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + @NonNull + private Integer messageThreadId; + + @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 (messageThreadId <= 0) { + throw new TelegramApiValidationException("Message Thread Id can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class UnpinAllForumTopicMessagesBuilder { + + @Tolerate + public UnpinAllForumTopicMessagesBuilder 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/PromoteChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java index 866b91a0..b7986a9f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java @@ -46,6 +46,7 @@ public class PromoteChatMember extends BotApiMethodBoolean { private static final String ISANONYMOUS_FIELD = "is_anonymous"; private static final String CANMANAGECHAT_FIELD = "can_manage_chat"; private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats"; + private static final String CANMANAGETOPICS_FIELD = "can_manage_topics"; @JsonProperty(CHATID_FIELD) @NonNull @@ -87,6 +88,12 @@ public class PromoteChatMember extends BotApiMethodBoolean { */ @JsonProperty(CANMANAGEVIDEOCHATS_FIELD) private Boolean canManageVideoChats; + /** + * Optional. + * True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only + */ + @JsonProperty(CANMANAGETOPICS_FIELD) + private Boolean canManageTopics; @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java index 0e9b9d60..759ead41 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java @@ -40,7 +40,7 @@ public class SetChatTitle extends BotApiMethodBoolean { private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername) @JsonProperty(TITLE_FIELD) @NonNull - private String title; ///< Required. New chat title, 1-255 characters + private String title; ///< Required. New chat title, 1-128 characters @Tolerate public void setChatId(@NonNull Long chatId) { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java index f81035b5..0c63c4a9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.invoices; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.base.Strings; import lombok.AllArgsConstructor; import lombok.Builder; @@ -14,20 +13,17 @@ import lombok.Setter; import lombok.Singular; import lombok.ToString; import org.telegram.telegrambots.meta.api.methods.BotApiMethod; -import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage; -import org.telegram.telegrambots.meta.api.objects.ApiResponse; -import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; -import java.io.IOException; import java.util.List; /** * @author Ruben Bermudez * @version 6.1 - * Use this method to create a link for an invoice. On success, the created link is returned. + * Use this method to create a link for an invoice. + * Retruns the created invoice link as String on success */ @EqualsAndHashCode(callSuper = false) @Getter @@ -37,7 +33,7 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor @Builder -public class CreateInvoiceLink extends BotApiMethodMessage { +public class CreateInvoiceLink extends BotApiMethod { public static final String PATH = "createInvoiceLink"; public static final String TITLE_FIELD = "title"; @@ -164,4 +160,9 @@ public class CreateInvoiceLink extends BotApiMethodMessage { throw new TelegramApiValidationException("No more that 4 suggested tips allowed", this); } } + + @Override + public String deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, String.class); + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java index 48757a3c..ce7421ad 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.invoices; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.base.Strings; import lombok.AllArgsConstructor; import lombok.Builder; @@ -14,16 +13,11 @@ import lombok.Setter; import lombok.Singular; import lombok.ToString; import lombok.experimental.Tolerate; -import org.telegram.telegrambots.meta.api.methods.BotApiMethod; import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage; -import org.telegram.telegrambots.meta.api.objects.ApiResponse; -import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice; import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup; -import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; -import java.io.IOException; import java.util.List; /** @@ -43,6 +37,7 @@ public class SendInvoice extends BotApiMethodMessage { public static final String PATH = "sendinvoice"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String TITLE_FIELD = "title"; private static final String DESCRIPTION_FIELD = "description"; private static final String PAYLOAD_FIELD = "payload"; @@ -73,6 +68,12 @@ public class SendInvoice extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(TITLE_FIELD) @NonNull private String title; ///< Product name diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java index c69d2021..207a02d7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java @@ -40,6 +40,7 @@ public class SendPoll extends BotApiMethodMessage { public static final String PATH = "sendPoll"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String QUESTION_FIELD = "question"; private static final String OPTIONS_FIELD = "options"; private static final String ISANONYMOUS_FIELD = "is_anonymous"; @@ -65,6 +66,12 @@ public class SendPoll extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(QUESTION_FIELD) @NonNull private String question; ///< Poll question, 1-300 characters 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 da436765..29f86c59 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 @@ -41,6 +41,7 @@ public class SendAnimation extends PartialBotApiMethod { public static final String PATH = "sendAnimation"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String ANIMATION_FIELD = "animation"; public static final String DURATION_FIELD = "duration"; public static final String WIDTH_FIELD = "width"; @@ -62,6 +63,11 @@ public class SendAnimation extends PartialBotApiMethod { * Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation * from the Internet, or upload a new animation using multipart/form-data. */ + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile animation; private Integer duration; ///< Optional. Duration of sent animation in seconds diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java index f31689f3..bee6f1d5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java @@ -43,6 +43,7 @@ public class SendAudio extends PartialBotApiMethod { public static final String DURATION_FIELD = "duration"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String AUDIO_FIELD = "audio"; public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; @@ -58,6 +59,11 @@ public class SendAudio extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers or Url to upload it private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java index eadb646f..ea2725ec 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java @@ -33,6 +33,7 @@ public class SendContact extends BotApiMethodMessage { public static final String PATH = "sendContact"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String PHONE_NUMBER_FIELD = "phone_number"; private static final String FIRST_NAME_FIELD = "first_name"; private static final String LAST_NAME_FIELD = "last_name"; @@ -46,6 +47,12 @@ public class SendContact extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(PHONE_NUMBER_FIELD) @NonNull private String phoneNumber; ///< User's phone number diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java index ab01579b..1d6c37bd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java @@ -38,6 +38,7 @@ public class SendDice extends BotApiMethodMessage { public static final String PATH = "sendDice"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String EMOJI_FIELD = "emoji"; private static final String DISABLENOTIFICATION_FIELD = "disable_notification"; private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; @@ -51,6 +52,12 @@ public class SendDice extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; /** * Optional. * diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java index 1349bf3c..75e4a4f0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java @@ -38,6 +38,7 @@ public class SendDocument extends PartialBotApiMethod { public static final String PATH = "senddocument"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String DOCUMENT_FIELD = "document"; public static final String CAPTION_FIELD = "caption"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; @@ -52,6 +53,11 @@ public class SendDocument extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers or Url to upload it private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java index 9f85d396..2b4a942f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java @@ -49,6 +49,8 @@ public class SendGame extends BotApiMethodMessage { public static final String PATH = "sendGame"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + private static final String GAMESHORTNAME_FIELD = "game_short_name"; private static final String DISABLENOTIFICATION_FIELD = "disable_notification"; private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; @@ -59,6 +61,12 @@ public class SendGame extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(GAMESHORTNAME_FIELD) @NonNull private String gameShortName; ///< Short name of the game diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java index d2673e53..16b1d8d4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java @@ -32,6 +32,8 @@ public class SendLocation extends BotApiMethodMessage { public static final String PATH = "sendlocation"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + private static final String LATITUDE_FIELD = "latitude"; private static final String LONGITUDE_FIELD = "longitude"; private static final String DISABLENOTIFICATION_FIELD = "disable_notification"; @@ -47,6 +49,12 @@ public class SendLocation extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(LATITUDE_FIELD) @NonNull private Double latitude; ///< Latitude of location diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java index f8fe3f1a..b262ca77 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -44,23 +43,24 @@ public class SendMediaGroup extends PartialBotApiMethod> { public static final String PATH = "sendMediaGroup"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String MEDIA_FIELD = "media"; public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply"; public static final String PROTECTCONTENT_FIELD = "protect_content"; - @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername) - @JsonProperty(MEDIA_FIELD) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private List medias; ///< A JSON-serialized array describing photos and videos to be sent, must include 2–10 items - @JsonProperty(REPLYTOMESSAGEID_FIELD) private Integer replyToMessageId; ///< Optional. If the messages are a reply, ID of the original message - @JsonProperty(DISABLENOTIFICATION_FIELD) private Boolean disableNotification; ///< Optional. Sends the messages silently. Users will receive a notification with no sound. - @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD) 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 diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java index a62e8f41..74c3ace2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java @@ -38,6 +38,7 @@ public class SendMessage extends BotApiMethodMessage { public static final String PATH = "sendmessage"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String TEXT_FIELD = "text"; private static final String PARSEMODE_FIELD = "parse_mode"; private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview"; @@ -51,6 +52,12 @@ public class SendMessage extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(TEXT_FIELD) @NonNull private String text; ///< Text of the message to be sent 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 752f7f2c..dbb3a6e8 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 @@ -39,6 +39,7 @@ public class SendPhoto extends PartialBotApiMethod { public static final String PATH = "sendphoto"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String PHOTO_FIELD = "photo"; public static final String CAPTION_FIELD = "caption"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; @@ -51,6 +52,11 @@ public class SendPhoto extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers or URL to upload it private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id). diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java index 91d1c741..85adf9ad 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java @@ -35,6 +35,7 @@ public class SendSticker extends PartialBotApiMethod { public static final String PATH = "sendsticker"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String STICKER_FIELD = "sticker"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; @@ -44,6 +45,11 @@ public class SendSticker extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers or URL to upload it private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java index e9a39364..0926657e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java @@ -33,6 +33,7 @@ public class SendVenue extends BotApiMethodMessage { public static final String PATH = "sendVenue"; private static final String CHATID_FIELD = "chat_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String LATITUDE_FIELD = "latitude"; private static final String LONGITUDE_FIELD = "longitude"; private static final String TITLE_FIELD = "title"; @@ -50,6 +51,12 @@ public class SendVenue extends BotApiMethodMessage { @JsonProperty(CHATID_FIELD) @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; @JsonProperty(LATITUDE_FIELD) @NonNull private Double latitude; ///< Latitude of venue location 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 ab13b851..bfd9d850 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 @@ -39,6 +39,7 @@ public class SendVideo extends PartialBotApiMethod { public static final String PATH = "sendvideo"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String VIDEO_FIELD = "video"; public static final String DURATION_FIELD = "duration"; public static final String CAPTION_FIELD = "caption"; @@ -56,6 +57,11 @@ public class SendVideo extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers or URL to upload it private Integer duration; ///< Optional. Duration of sent video in seconds diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java index 673ce3b4..43e0a5b7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java @@ -36,6 +36,7 @@ public class SendVideoNote extends PartialBotApiMethod { public static final String PATH = "sendvideonote"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String VIDEONOTE_FIELD = "video_note"; public static final String DURATION_FIELD = "duration"; public static final String LENGTH_FIELD = "length"; @@ -48,6 +49,11 @@ public class SendVideoNote extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile videoNote; ///< Videonote to send. file_id as String to resend a video that is already on the Telegram servers. private Integer duration; ///< Optional. Duration of sent video in seconds diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java index b36f72d7..7c64ff1f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java @@ -40,6 +40,7 @@ public class SendVoice extends PartialBotApiMethod { public static final String PATH = "sendvoice"; public static final String CHATID_FIELD = "chat_id"; + public static final String MESSAGETHREADID_FIELD = "message_thread_id"; public static final String VOICE_FIELD = "voice"; public static final String DISABLENOTIFICATION_FIELD = "disable_notification"; public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id"; @@ -53,6 +54,11 @@ public class SendVoice extends PartialBotApiMethod { @NonNull private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels) + /** + * Unique identifier for the target message thread (topic) of the forum; + * for forum supergroups only + */ + private Integer messageThreadId; @NonNull private InputFile voice; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data. private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java index 14de303a..ee611efe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java @@ -24,6 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; * - Bots granted can_post_messages permissions can delete outgoing messages in channels. * - If the bot is an administrator of a group, it can delete any message there. * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. + * - Service messages about a supergroup, channel, or forum topic creation can't be deleted * Returns True on success. */ @EqualsAndHashCode(callSuper = false) 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 15eca28b..113f6c04 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 @@ -12,6 +12,8 @@ import lombok.Setter; import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; +import java.util.List; + /** * This object represents a Telegram chat with an user or a group * @author Ruben Bermudez @@ -50,6 +52,9 @@ public class Chat implements BotApiObject { private static final String JOINTOSENDMESSAGES_FIELD = "join_to_send_messages"; private static final String JOINBYREQUEST_FIELD = "join_by_request"; private static final String HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD = "has_restricted_voice_and_video_messages"; + 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 USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; @@ -208,6 +213,29 @@ public class Chat implements BotApiObject { @JsonProperty(HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD) private Boolean hasRestrictedVoiceAndVideoMessages; + /** + * Optional. + * True, if the supergroup chat is a forum (has topics enabled) + */ + @JsonProperty(ISFORUM_FIELD) + private Boolean isForum; + + /** + * Optional. + * If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. + * Returned only in getChat. + */ + @JsonProperty(ACTIVEUSERNAMES_FIELD) + private List activeUsernames; + + /** + * Optional. + * Custom emoji identifier of emoji status of the other party in a private chat. + * Returned only in getChat. + */ + @JsonProperty(EMOJISTATUSCUSTOMEMOJIID_FIELD) + private String emojiStatusCustomEmojiId; + @JsonIgnore public Boolean isGroupChat() { return GROUPCHATTYPE.equals(type); 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 87108a89..efde20c3 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 @@ -9,6 +9,9 @@ import lombok.NoArgsConstructor; import lombok.Setter; 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.ForumTopicReopened; 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; @@ -39,6 +42,7 @@ import java.util.List; @AllArgsConstructor public class Message implements BotApiObject { private static final String MESSAGEID_FIELD = "message_id"; + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; private static final String FROM_FIELD = "from"; private static final String DATE_FIELD = "date"; private static final String CHAT_FIELD = "chat"; @@ -97,12 +101,23 @@ public class Message implements BotApiObject { private static final String VIDEOCHATSTARTED_FIELD = "video_chat_started"; private static final String VIDEOCHATENDED_FIELD = "video_chat_ended"; private static final String VIDEOCHATPARTICIPANTSINVITED_FIELD = "video_chat_participants_invited"; + private static final String ISTOPICMESSAGE_FIELD = "is_topic_message"; + private static final String FORUMTOPICCREATED_FIELD = "forum_topic_created"; + private static final String FORUMTOPICCLOSED_FIELD = "forum_topic_closed"; + private static final String FORUMTOPICREOPENED_FIELD = "forum_topic_reopened"; /** * Integer Unique message identifier */ @JsonProperty(MESSAGEID_FIELD) private Integer messageId; + /** + * Optional. + * Unique identifier of a message thread or a forum topic to which the message belongs; + * for supergroups only + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; /** * Optional. * Sender, can be empty for messages sent to channels @@ -463,7 +478,31 @@ public class Message implements BotApiObject { * Service message: video chat scheduled */ @JsonProperty(VIDEOCHATSCHEDULED_FIELD) - private VideoChatScheduled videoChatScheduled; + private VideoChatScheduled videoChatScheduled; + /** + * Optional. + * True, if the message is sent to a forum topic + */ + @JsonProperty(ISTOPICMESSAGE_FIELD) + private Boolean isTopicMessage; + /** + * Optional. + * Service message: forum topic created + */ + @JsonProperty(FORUMTOPICCREATED_FIELD) + private ForumTopicCreated forumTopicCreated; + /** + * Optional. + * Service message: forum topic closed + */ + @JsonProperty(FORUMTOPICCLOSED_FIELD) + private ForumTopicClosed forumTopicClosed; + /** + * Optional. + * Service message: forum topic reopened + */ + @JsonProperty(FORUMTOPICREOPENED_FIELD) + private ForumTopicReopened forumTopicReopened; public List getEntities() { if (entities != null) { @@ -489,6 +528,11 @@ public class Message implements BotApiObject { return sticker != null; } + @JsonIgnore + public boolean isTopicMessage() { + return isTopicMessage != null && isTopicMessage; + } + @JsonIgnore public boolean isGroupMessage() { return chat.isGroupChat(); @@ -656,4 +700,19 @@ public class Message implements BotApiObject { private boolean hasVideoChatParticipantsInvited() { return videoChatParticipantsInvited != null; } + + @JsonIgnore + private boolean hasForumTopicCreated() { + return forumTopicCreated != null; + } + + @JsonIgnore + private boolean hasForumTopicClosed() { + return forumTopicClosed != null; + } + + @JsonIgnore + private boolean hasForumTopicReopened() { + return forumTopicReopened != null; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java index d55c841f..a01c1162 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java @@ -29,6 +29,7 @@ public class ChatAdministratorRights implements BotApiObject { private static final String CANPOSTMESSAGES_FIELD = "can_post_messages"; private static final String CANEDITMESSAGES_FIELD = "can_edit_messages"; private static final String CANPINMESSAGES_FIELD = "can_pin_messages"; + private static final String CANMANAGETOPICS_FIELD = "can_manage_topics"; /** * True, if the user's presence in the chat is hidden @@ -93,5 +94,10 @@ public class ChatAdministratorRights implements BotApiObject { */ @JsonProperty(CANPINMESSAGES_FIELD) private Boolean canPinMessages; - + /** + * Optional. + * True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only + */ + @JsonProperty(CANMANAGETOPICS_FIELD) + private Boolean canManageTopics; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java index be599344..fa4eb64b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java @@ -43,6 +43,7 @@ public class ChatMemberAdministrator implements ChatMember { private static final String CANINVITEUSERS_FIELD = "can_invite_users"; private static final String CANPINMESSAGES_FIELD = "can_pin_messages"; private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats"; + private static final String CANMANAGETOPICS_FIELD = "can_manage_topics"; /** * The member's status in the chat, always “administrator” @@ -124,4 +125,10 @@ public class ChatMemberAdministrator implements ChatMember { */ @JsonProperty(CANMANAGEVIDEOCHATS_FIELD) private Boolean canManageVideoChats; + /** + * Optional. + * True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only + */ + @JsonProperty(CANMANAGETOPICS_FIELD) + private Boolean canManageTopics; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java index b98ae180..4d190885 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java @@ -40,6 +40,7 @@ public class ChatMemberRestricted implements ChatMember { private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages"; private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews"; private static final String UNTILDATE_FIELD = "until_date"; + private static final String CANMANAGETOPICS_FIELD = "can_manage_topics"; /** * The member's status in the chat, always “restricted” @@ -101,4 +102,9 @@ public class ChatMemberRestricted implements ChatMember { */ @JsonProperty(UNTILDATE_FIELD) private Integer untilDate; + /** + * True, if the user is allowed to create forum topics + */ + @JsonProperty(CANMANAGETOPICS_FIELD) + private Boolean canManageTopics; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopic.java new file mode 100644 index 00000000..6f346dce --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopic.java @@ -0,0 +1,51 @@ +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 forum topic. + * @author Ruben Bermudez + * @version 6.3 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ForumTopic implements BotApiObject { + private static final String MESSAGETHREADID_FIELD = "message_thread_id"; + private static final String NAME_FIELD = "name"; + private static final String ICONCOLOR_FIELD = "icon_color"; + private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id"; + + /** + * Unique identifier of the forum topic + */ + @JsonProperty(MESSAGETHREADID_FIELD) + private Integer messageThreadId; + /** + * Name of the topic + */ + @JsonProperty(NAME_FIELD) + private String name; + /** + * Color of the topic icon in RGB format + */ + @JsonProperty(ICONCOLOR_FIELD) + private Integer iconColor; + /** + * Optional. + * Unique identifier of the custom emoji shown as the topic icon + */ + @JsonProperty(ICONCUSTOMEMOJIID_FIELD) + private String iconCustomEmojiId; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicClosed.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicClosed.java new file mode 100644 index 00000000..f40d968c --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicClosed.java @@ -0,0 +1,24 @@ +package org.telegram.telegrambots.meta.api.objects.forum; + +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 a forum topic closed in the chat. + * Currently holds no information. + * @author Ruben Bermudez + * @version 6.3 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +public class ForumTopicClosed implements BotApiObject { + +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicCreated.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicCreated.java new file mode 100644 index 00000000..21f9d0e7 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicCreated.java @@ -0,0 +1,47 @@ +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 a new forum topic created in the chat. + * @author Ruben Bermudez + * @version 6.1 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ForumTopicCreated implements BotApiObject { + private static final String NAME_FIELD = "name"; + private static final String ICONCOLOR_FIELD = "icon_color"; + private static final String ICONCUSTOMEMOJIID_FIELD = "icon_custom_emoji_id"; + + + /** + * Name of the topic + */ + @JsonProperty(NAME_FIELD) + private String name; + /** + * Color of the topic icon in RGB format + */ + @JsonProperty(ICONCOLOR_FIELD) + private Integer iconColor; + /** + * Optional. + * Unique identifier of the custom emoji shown as the topic icon + */ + @JsonProperty(ICONCUSTOMEMOJIID_FIELD) + private String iconCustomEmojiId; + +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicReopened.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicReopened.java new file mode 100644 index 00000000..2c8b2b9b --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/forum/ForumTopicReopened.java @@ -0,0 +1,24 @@ +package org.telegram.telegrambots.meta.api.objects.forum; + +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 a forum topic reopened in the chat. + * Currently holds no information. + * @author Ruben Bermudez + * @version 6.3 + */ +@SuppressWarnings("WeakerAccess") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +public class ForumTopicReopened implements BotApiObject { + +} diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLinkTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLinkTest.java index a6e30111..4ca0abdf 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLinkTest.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLinkTest.java @@ -2,6 +2,7 @@ package org.telegram.telegrambots.meta.api.methods.invoices; import org.junit.jupiter.api.Test; import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; import java.util.ArrayList; @@ -11,6 +12,7 @@ import java.util.Collections; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Ruben Bermudez @@ -111,6 +113,23 @@ public class CreateInvoiceLinkTest { assertEquals("No more that 4 suggested tips allowed", thrown.getMessage()); } + @Test + public void testCreateInvoiceLinkDeserializeValidResponse(){ + String responseText = "{\n" + + " \"ok\": true,\n" + + " \"result\": \"https://t.me/testlink\" \n" + + "}"; + + CreateInvoiceLink createInvoiceLink = createSendInvoiceObject(); + + try { + String link = createInvoiceLink.deserializeResponse(responseText); + assertEquals("https://t.me/testlink",link); + } catch (TelegramApiRequestException e) { + fail(e.getMessage()); + } + } + private CreateInvoiceLink createSendInvoiceObject() { return CreateInvoiceLink.builder() .title("Title") diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md index a8f959fb..a1b03f6b 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.1.0 + 6.3.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-spring-boot-starter:6.1.0' + implementation 'org.telegram:telegrambots-spring-boot-starter:6.3.0' ``` Motivation diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index d4a7d732..1b739352 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambots-spring-boot-starter @@ -70,8 +70,8 @@ UTF-8 UTF-8 - 6.1.0 - 2.7.0 + 6.3.0 + 2.7.5 1.6 1.6.13 @@ -110,7 +110,18 @@ spring-boot-starter-test ${spring-boot.version} test + + + org.junit.jupiter + junit-jupiter-engine + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 3505efe3..e9e82d8a 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 6.1.0 + 6.3.0 telegrambots @@ -91,7 +91,7 @@ org.telegram telegrambots-meta - 6.1.0 + 6.3.0 org.projectlombok 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 eca30757..90243603 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java @@ -167,6 +167,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendDocument.getReplyToMessageId() != null) { builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendDocument.getMessageThreadId() != null) { + builder.addTextBody(SendDocument.MESSAGETHREADID_FIELD, sendDocument.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendDocument.getCaption() != null) { builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getParseMode() != null) { @@ -225,6 +228,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendPhoto.getReplyToMessageId() != null) { builder.addTextBody(SendPhoto.REPLYTOMESSAGEID_FIELD, sendPhoto.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendPhoto.getMessageThreadId() != null) { + builder.addTextBody(SendPhoto.MESSAGETHREADID_FIELD, sendPhoto.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendPhoto.getCaption() != null) { builder.addTextBody(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendPhoto.getParseMode() != null) { @@ -273,6 +279,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendVideo.getReplyToMessageId() != null) { builder.addTextBody(SendVideo.REPLYTOMESSAGEID_FIELD, sendVideo.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendVideo.getMessageThreadId() != null) { + builder.addTextBody(SendVideo.MESSAGETHREADID_FIELD, sendVideo.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendVideo.getCaption() != null) { builder.addTextBody(SendVideo.CAPTION_FIELD, sendVideo.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendVideo.getParseMode() != null) { @@ -338,6 +347,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendVideoNote.getReplyToMessageId() != null) { builder.addTextBody(SendVideoNote.REPLYTOMESSAGEID_FIELD, sendVideoNote.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendVideoNote.getMessageThreadId() != null) { + builder.addTextBody(SendVideoNote.MESSAGETHREADID_FIELD, sendVideoNote.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendVideoNote.getDuration() != null) { builder.addTextBody(SendVideoNote.DURATION_FIELD, sendVideoNote.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); } @@ -388,6 +400,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendSticker.getReplyToMessageId() != null) { builder.addTextBody(SendSticker.REPLYTOMESSAGEID_FIELD, sendSticker.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendSticker.getMessageThreadId() != null) { + builder.addTextBody(SendSticker.MESSAGETHREADID_FIELD, sendSticker.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendSticker.getDisableNotification() != null) { builder.addTextBody(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } @@ -431,6 +446,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendAudio.getReplyToMessageId() != null) { builder.addTextBody(SendAudio.REPLYTOMESSAGEID_FIELD, sendAudio.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendAudio.getMessageThreadId() != null) { + builder.addTextBody(SendAudio.MESSAGETHREADID_FIELD, sendAudio.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendAudio.getPerformer() != null) { builder.addTextBody(SendAudio.PERFOMER_FIELD, sendAudio.getPerformer(), TEXT_PLAIN_CONTENT_TYPE); } @@ -499,6 +517,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendVoice.getReplyToMessageId() != null) { builder.addTextBody(SendVoice.REPLYTOMESSAGEID_FIELD, sendVoice.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendVoice.getMessageThreadId() != null) { + builder.addTextBody(SendVoice.MESSAGETHREADID_FIELD, sendVoice.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendVoice.getDisableNotification() != null) { builder.addTextBody(SendVoice.DISABLENOTIFICATION_FIELD, sendVoice.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } @@ -581,6 +602,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendMediaGroup.getReplyToMessageId() != null) { builder.addTextBody(SendMediaGroup.REPLYTOMESSAGEID_FIELD, sendMediaGroup.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendMediaGroup.getMessageThreadId() != null) { + builder.addTextBody(SendMediaGroup.MESSAGETHREADID_FIELD, sendMediaGroup.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendMediaGroup.getAllowSendingWithoutReply() != null) { builder.addTextBody(SendMediaGroup.ALLOWSENDINGWITHOUTREPLY_FIELD, sendMediaGroup.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE); } @@ -762,6 +786,9 @@ public abstract class DefaultAbsSender extends AbsSender { if (sendAnimation.getReplyToMessageId() != null) { builder.addTextBody(SendAnimation.REPLYTOMESSAGEID_FIELD, sendAnimation.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } + if (sendAnimation.getMessageThreadId() != null) { + builder.addTextBody(SendAnimation.MESSAGETHREADID_FIELD, sendAnimation.getMessageThreadId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } if (sendAnimation.getDisableNotification() != null) { builder.addTextBody(SendAnimation.DISABLENOTIFICATION_FIELD, sendAnimation.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); }