From 6b1cea5e82f6a1f828968075855120d30d64e376 Mon Sep 17 00:00:00 2001 From: rubenlagus Date: Tue, 31 Dec 2019 03:36:57 +0100 Subject: [PATCH] Update version 4.5 --- Bots.ipr | 30 ++-- README.md | 8 +- TelegramBots.wiki/Changelog.md | 4 + TelegramBots.wiki/Getting-Started.md | 4 +- TelegramBots.wiki/abilities/Simple-Example.md | 2 +- pom.xml | 2 +- telegrambots-abilities/README.md | 8 +- telegrambots-abilities/pom.xml | 4 +- telegrambots-chat-session-bot/README.md | 2 +- telegrambots-chat-session-bot/pom.xml | 4 +- telegrambots-extensions/README.md | 4 +- telegrambots-extensions/pom.xml | 4 +- telegrambots-meta/pom.xml | 2 +- .../SetChatAdministratorCustomTitle.java | 129 ++++++++++++++++++ .../telegrambots/meta/api/objects/Audio.java | 15 +- .../telegrambots/meta/api/objects/Chat.java | 14 +- .../meta/api/objects/ChatMember.java | 27 +++- .../meta/api/objects/Document.java | 15 +- .../telegrambots/meta/api/objects/File.java | 33 +++-- .../meta/api/objects/MessageEntity.java | 7 +- .../meta/api/objects/PhotoSize.java | 15 +- .../telegrambots/meta/api/objects/Video.java | 15 +- .../meta/api/objects/VideoNote.java | 14 +- .../telegrambots/meta/api/objects/Voice.java | 15 +- .../meta/api/objects/games/Animation.java | 15 +- .../api/objects/passport/PassportFile.java | 14 +- .../meta/api/objects/stickers/Sticker.java | 15 +- telegrambots-spring-boot-starter/pom.xml | 4 +- telegrambots/pom.xml | 4 +- 29 files changed, 351 insertions(+), 78 deletions(-) create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java diff --git a/Bots.ipr b/Bots.ipr index 33b4badd..0a14adb7 100644 --- a/Bots.ipr +++ b/Bots.ipr @@ -22,10 +22,10 @@ - - - + + + @@ -1456,37 +1456,37 @@ - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/README.md b/README.md index d66ba1f3..6c954a52 100644 --- a/README.md +++ b/README.md @@ -27,16 +27,16 @@ Just import add the library to your project with one of these options: org.telegram telegrambots - 4.4.0.2 + 4.5 ``` ```gradle - compile "org.telegram:telegrambots:4.4.0.2" + compile "org.telegram:telegrambots:4.5" ``` - 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.4.0.2) - 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.4.0.2) + 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.5) + 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.5) 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 e568d16a..a294d0f3 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,3 +1,7 @@ +### 4.5 ### +1. Update Api version [4.5](https://core.telegram.org/bots/api-changelog#december-31-2019) +2. Fixes: #710 + ### 4.4.0.2 ### 1. Use SLF4J 2. Support case-insensitive usernames diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index 64a63865..ac075e5b 100644 --- a/TelegramBots.wiki/Getting-Started.md +++ b/TelegramBots.wiki/Getting-Started.md @@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss org.telegram telegrambots - 4.4.0.2 + 4.5 ``` * With **Gradle**: ```groovy - compile group: 'org.telegram', name: 'telegrambots', version: '4.4.0.2' + compile group: 'org.telegram', name: 'telegrambots', version: '4.5' ``` 2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots). diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md index f541cd66..2cf4c06a 100644 --- a/TelegramBots.wiki/abilities/Simple-Example.md +++ b/TelegramBots.wiki/abilities/Simple-Example.md @@ -9,7 +9,7 @@ As with any Java project, you will need to set your dependencies. org.telegram telegrambots-abilities - 4.4.0.2 + 4.5 ``` * **Gradle** diff --git a/pom.xml b/pom.xml index fb6636f4..4aee1c51 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 4.4.0.2 + 4.5 telegrambots diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index d4d1401a..75c65d08 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,19 +18,19 @@ Usage org.telegram telegrambots-abilities - 4.4.0.2 + 4.5 ``` **Gradle** ```gradle - compile "org.telegram:telegrambots-abilities:4.4.0.2" + compile "org.telegram:telegrambots-abilities:4.5" ``` -**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.4.0.2) +**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.5) -**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.4.0.2) +**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.5) Motivation ---------- diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index 20599cad..e2c33793 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambots-abilities @@ -85,7 +85,7 @@ org.telegram telegrambots - 4.4.0.2 + 4.5 org.apache.commons diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md index 095f2bc9..614ed46f 100644 --- a/telegrambots-chat-session-bot/README.md +++ b/telegrambots-chat-session-bot/README.md @@ -15,7 +15,7 @@ Usage org.telegram telegrambots-chat-session-bot - 4.4.0.2 + 4.5 ``` diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index fef0e5d2..78faae63 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambots-chat-session-bot @@ -84,7 +84,7 @@ org.telegram telegrambots - 4.4.0.2 + 4.5 diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index 72abbcf3..e3019b98 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 - 4.4.0.2 + 4.5 ``` 2. Using Gradle: ```gradle - compile "org.telegram:telegrambotsextensions:4.4.0.2" + compile "org.telegram:telegrambotsextensions:4.5" ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index 8c346d7e..c6763c24 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambotsextensions @@ -75,7 +75,7 @@ org.telegram telegrambots - 4.4.0.2 + 4.5 diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index a6167035..757818dd 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambots-meta diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java new file mode 100644 index 00000000..c88a3d54 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java @@ -0,0 +1,129 @@ +package org.telegram.telegrambots.meta.api.methods.groupadministration; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import org.telegram.telegrambots.meta.api.methods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.ApiResponse; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import java.io.IOException; +import java.util.Objects; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * @author Ruben Bermudez + * @version 4.5 + * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. + * Returns True on success. + */ +public class SetChatAdministratorCustomTitle extends BotApiMethod { + public static final String PATH = "setChatAdministratorCustomTitle"; + + private static final String CHATID_FIELD = "chat_id"; + private static final String USERID_FIELD = "user_id"; + private static final String CUSTOMTITLE_FIELD = "custom_title"; + + @JsonProperty(CHATID_FIELD) + private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername) + @JsonProperty(USERID_FIELD) + private Integer userId; ///< Unique identifier of the target user + @JsonProperty(CUSTOMTITLE_FIELD) + private String customTitle; ///< New custom title for the administrator; 0-16 characters, emoji are not allowed + + public SetChatAdministratorCustomTitle() { + super(); + } + + public SetChatAdministratorCustomTitle(String chatId, Integer userId, String customTitle) { + super(); + this.chatId = checkNotNull(chatId); + this.userId = checkNotNull(userId); + this.customTitle = checkNotNull(customTitle); + } + + public SetChatAdministratorCustomTitle(Long chatId, Integer userId, String customTitle) { + super(); + this.chatId = checkNotNull(chatId).toString(); + this.userId = checkNotNull(userId); + this.customTitle = checkNotNull(customTitle); + } + + public String getChatId() { + return chatId; + } + + public SetChatAdministratorCustomTitle setChatId(String chatId) { + this.chatId = chatId; + return this; + } + + public SetChatAdministratorCustomTitle setChatId(Long chatId) { + Objects.requireNonNull(chatId); + this.chatId = chatId.toString(); + return this; + } + + public Integer getUserId() { + return userId; + } + + public SetChatAdministratorCustomTitle setUserId(Integer userId) { + checkNotNull(userId); + this.userId = userId; + return this; + } + + public String getCustomTitle() { + return customTitle; + } + + public SetChatAdministratorCustomTitle setCustomTitle(String customTitle) { + checkNotNull(customTitle); + this.customTitle = customTitle; + return this; + } + + @Override + public String getMethod() { + return PATH; + } + + @Override + public Boolean deserializeResponse(String answer) throws TelegramApiRequestException { + try { + ApiResponse result = OBJECT_MAPPER.readValue(answer, + new TypeReference>(){}); + if (result.getOk()) { + return result.getResult(); + } else { + throw new TelegramApiRequestException("Error setting chat description", result); + } + } catch (IOException e) { + throw new TelegramApiRequestException("Unable to deserialize response", e); + } + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId == null || chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + if (userId == null || userId == 0) { + throw new TelegramApiValidationException("UserId can't be empty", this); + } + if (customTitle == null) { + throw new TelegramApiValidationException("CustomTitle can't be null", this); + } + } + + @Override + public String toString() { + return "SetChatDescription{" + + "chatId='" + chatId + '\'' + + "userId='" + userId + '\'' + + ", customTitle='" + customTitle + '\'' + + '}'; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java index 4bfd326e..62280fb7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -12,6 +11,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; public class Audio implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String DURATION_FIELD = "duration"; private static final String MIMETYPE_FIELD = "mime_type"; private static final String FILESIZE_FIELD = "file_size"; @@ -20,7 +20,13 @@ public class Audio implements BotApiObject { private static final String THUMB_FIELD = "thumb"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(DURATION_FIELD) private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender @JsonProperty(MIMETYPE_FIELD) @@ -66,6 +72,10 @@ public class Audio implements BotApiObject { return thumb; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Audio{" + @@ -76,6 +86,7 @@ public class Audio implements BotApiObject { ", title='" + title + '\'' + ", performer='" + performer + '\'' + ", thumb=" + thumb + + ", fileUniqueId=" + fileUniqueId + '}'; } } 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 b543e3a0..2fedbf9c 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 @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -26,6 +25,7 @@ public class Chat implements BotApiObject { private static final String STICKERSETNAME_FIELD = "sticker_set_name"; private static final String CANSETSTICKERSET_FIELD = "can_set_sticker_set"; private static final String PERMISSIONS_FIELD = "permissions"; + private static final String SLOWMODEDELAY_FIELD = "slow_mode_delay"; private static final String USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; @@ -75,6 +75,13 @@ public class Chat implements BotApiObject { private Boolean canSetStickerSet; ///< Optional. True, if the bot can change group the sticker set. Returned only in getChat. @JsonProperty(PERMISSIONS_FIELD) private ChatPermissions permissions; ///< Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. + /** + * Optional. + * For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. + * Returned only in getChat. + */ + @JsonProperty(SLOWMODEDELAY_FIELD) + private Integer slowModeDelay; public Chat() { super(); @@ -152,6 +159,10 @@ public class Chat implements BotApiObject { return canSetStickerSet; } + public Integer getSlowModeDelay() { + return slowModeDelay; + } + @Override public String toString() { return "Chat{" + @@ -169,6 +180,7 @@ public class Chat implements BotApiObject { ", stickerSetName='" + stickerSetName + '\'' + ", canSetStickerSet=" + canSetStickerSet + ", permissions=" + permissions + + ", slowModeDelay=" + slowModeDelay + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMember.java index 2afcf800..3ab0c240 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMember.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import java.time.Instant; @@ -21,7 +20,7 @@ public class ChatMember implements BotApiObject { private static final String CANEDITMESSAGES_FIELD = "can_edit_messages"; private static final String CANDELETEMESSAGES_FIELD = "can_delete_messages"; private static final String CANINVITEUSERS_FIELD = "can_invite_users"; - private static final String CANRESTRICTUSERS_FIELD = "can_restrict_users"; + private static final String CANRESTRICTMEMBERS_FIELD = "can_restrict_members"; private static final String CANPINMESSAGES_FIELD = "can_pin_messages"; private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members"; private static final String CANSENDMESSAGES_FIELD = "can_send_messages"; @@ -30,6 +29,7 @@ public class ChatMember implements BotApiObject { private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews"; private static final String CAN_SEND_POLLS_FIELD = "can_send_polls"; private static final String ISMEMBER_FIELD = "is_member"; + private static final String CUSTOMTITLE_FIELD = "custom_title"; @JsonProperty(USER_FIELD) private User user; ///< Information about the user @@ -49,8 +49,8 @@ public class ChatMember implements BotApiObject { private Boolean canDeleteMessages; ///< Optional. Administrators only. True, if the administrator can delete messages of other users @JsonProperty(CANINVITEUSERS_FIELD) private Boolean canInviteUsers; ///< Optional. Administrators and restricted only. True, if the administrator can invite new users to the chat - @JsonProperty(CANRESTRICTUSERS_FIELD) - private Boolean canRestrictUsers; ///< Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members + @JsonProperty(CANRESTRICTMEMBERS_FIELD) + private Boolean canRestrictMembers; ///< Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members @JsonProperty(CANPINMESSAGES_FIELD) private Boolean canPinMessages; ///< Optional. Administrators and restricted only. True, if the administrator can pin messages, groups and supergroups only @JsonProperty(CANPROMOTEMEMBERS_FIELD) @@ -67,6 +67,8 @@ public class ChatMember implements BotApiObject { private Boolean canSendPolls; ///< Optional. Restricted only. True, if the user is allowed to send polls. @JsonProperty(ISMEMBER_FIELD) private Boolean isMemberField; ///< True, if the user is a member of the chat at the moment of the request. For example, it can be false for the chat creator or for a restricted user. + @JsonProperty(CUSTOMTITLE_FIELD) + private String customTitle; ///< Optional. Owner and administrators only. Custom title for this user public ChatMember() { super(); @@ -115,8 +117,16 @@ public class ChatMember implements BotApiObject { return canInviteUsers; } + public Boolean getCanRestrictMembers() { + return canRestrictMembers; + } + + /** + * @deprecated Use {{@link #getCanRestrictMembers()}} + */ + @Deprecated public Boolean getCanRestrictUsers() { - return canRestrictUsers; + return canRestrictMembers; } public Boolean getCanPinMessages() { @@ -151,6 +161,10 @@ public class ChatMember implements BotApiObject { return isMemberField; } + public String getCustomTitle() { + return customTitle; + } + @Override public String toString() { return "ChatMember{" + @@ -163,7 +177,7 @@ public class ChatMember implements BotApiObject { ", canEditMessages=" + canEditMessages + ", canDeleteMessages=" + canDeleteMessages + ", canInviteUsers=" + canInviteUsers + - ", canRestrictUsers=" + canRestrictUsers + + ", canRestrictMembers=" + canRestrictMembers + ", canPinMessages=" + canPinMessages + ", canPromoteMembers=" + canPromoteMembers + ", canSendMessages=" + canSendMessages + @@ -172,6 +186,7 @@ public class ChatMember implements BotApiObject { ", canAddWebPagePreviews=" + canAddWebPagePreviews + ", canSendPolls=" + canSendPolls + ", isMemberField=" + isMemberField + + ", customTitle=" + customTitle + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java index 46a2e7a9..ff342b8c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -14,13 +13,20 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; public class Document implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String THUMB_FIELD = "thumb"; private static final String FILENAME_FIELD = "file_name"; private static final String MIMETYPE_FIELD = "mime_type"; private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(THUMB_FIELD) private PhotoSize thumb; ///< Document thumbnail as defined by sender @JsonProperty(FILENAME_FIELD) @@ -54,6 +60,10 @@ public class Document implements BotApiObject { return fileSize; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Document{" + @@ -62,6 +72,7 @@ public class Document implements BotApiObject { ", fileName='" + fileName + '\'' + ", mimeType='" + mimeType + '\'' + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/File.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/File.java index c9991f1c..24e00386 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/File.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/File.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import java.security.InvalidParameterException; @@ -14,12 +13,19 @@ import java.text.MessageFormat; * @date 24 of June of 2015 */ public class File implements BotApiObject { - private static final String FILE_ID = "file_id"; + private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String FILE_SIZE_FIELD = "file_size"; private static final String FILE_PATH_FIELD = "file_path"; - @JsonProperty(FILE_ID) - private String fileId; ///< Unique identifier for this file + @JsonProperty(FILEID_FIELD) + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(FILE_SIZE_FIELD) private Integer fileSize; ///< Optional. File size, if known @JsonProperty(FILE_PATH_FIELD) @@ -41,13 +47,8 @@ public class File implements BotApiObject { return filePath; } - @Override - public String toString() { - return "File{" + - "fileId='" + fileId + '\'' + - ", fileSize=" + fileSize + - ", filePath='" + filePath + '\'' + - '}'; + public String getFileUniqueId() { + return fileUniqueId; } public String getFileUrl(String botToken) { @@ -60,4 +61,14 @@ public class File implements BotApiObject { } return MessageFormat.format("https://api.telegram.org/file/bot{0}/{1}", botToken, filePath); } + + @Override + public String toString() { + return "File{" + + "fileId='" + fileId + '\'' + + ", fileSize=" + fileSize + + ", filePath='" + filePath + '\'' + + ", fileUniqueId=" + fileUniqueId + + '}'; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java index 9629a5de..c26ba89f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java @@ -2,7 +2,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -31,8 +30,10 @@ public class MessageEntity implements BotApiObject { * italic (italic text), * code (monowidth string), * pre (monowidth block), - * text_link (for clickable text URLs) - * text_mention (for users without usernames) + * text_link (for clickable text URLs), + * text_mention (for users without usernames), + * underline, + * strikethrough */ @JsonProperty(TYPE_FIELD) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java index bdf8cbec..d097d524 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -13,13 +12,20 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; public class PhotoSize implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String WIDTH_FIELD = "width"; private static final String HEIGHT_FIELD = "height"; private static final String FILESIZE_FIELD = "file_size"; private static final String FILEPATH_FIELD = "file_path"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Photo width @JsonProperty(HEIGHT_FIELD) @@ -57,6 +63,10 @@ public class PhotoSize implements BotApiObject { return filePath != null && !filePath.isEmpty(); } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "PhotoSize{" + @@ -64,6 +74,7 @@ public class PhotoSize implements BotApiObject { ", width=" + width + ", height=" + height + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java index e6d6cb0e..78467f0d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -13,6 +12,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; public class Video implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String WIDTH_FIELD = "width"; private static final String HEIGHT_FIELD = "height"; private static final String DURATION_FIELD = "duration"; @@ -21,7 +21,13 @@ public class Video implements BotApiObject { private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Video width as defined by sender @JsonProperty(HEIGHT_FIELD) @@ -67,6 +73,10 @@ public class Video implements BotApiObject { return fileSize; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Video{" + @@ -77,6 +87,7 @@ public class Video implements BotApiObject { ", thumb=" + thumb + ", mimeType='" + mimeType + '\'' + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java index 365da3fd..53698020 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java @@ -11,13 +11,20 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; */ public class VideoNote implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String LENGTH_FIELD = "length"; private static final String DURATION_FIELD = "duration"; private static final String THUMB_FIELD = "thumb"; private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(LENGTH_FIELD) private Integer length; ///< Video width and height as defined by sender @JsonProperty(DURATION_FIELD) @@ -51,6 +58,10 @@ public class VideoNote implements BotApiObject { return fileSize; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "VideoNote{" + @@ -59,6 +70,7 @@ public class VideoNote implements BotApiObject { ", duration=" + duration + ", thumb=" + thumb + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java index 977a684e..4025d8ef 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** @@ -12,12 +11,19 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; */ public class Voice implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String DURATION_FIELD = "duration"; private static final String MIMETYPE_FIELD = "mime_type"; private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(DURATION_FIELD) private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender @JsonProperty(MIMETYPE_FIELD) @@ -45,6 +51,10 @@ public class Voice implements BotApiObject { return fileSize; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Voice{" + @@ -52,6 +62,7 @@ public class Voice implements BotApiObject { ", duration=" + duration + ", mimeType='" + mimeType + '\'' + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java index c88d07a3..75d2d76e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java @@ -17,7 +17,6 @@ package org.telegram.telegrambots.meta.api.objects.games; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -28,6 +27,7 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize; */ public class Animation implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String WIDTH_FIELD = "width"; private static final String HEIGHT_FIELD = "height"; private static final String DURATION_FIELD = "duration"; @@ -37,7 +37,13 @@ public class Animation implements BotApiObject { private static final String FILESIZE_FIELD = "file_size"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique file identifier + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Video width as defined by sender @JsonProperty(HEIGHT_FIELD) @@ -89,6 +95,10 @@ public class Animation implements BotApiObject { return duration; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Animation{" + @@ -100,6 +110,7 @@ public class Animation implements BotApiObject { ", fileName='" + fileName + '\'' + ", mimetype='" + mimetype + '\'' + ", fileSize=" + fileSize + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/PassportFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/PassportFile.java index 9c80d9b7..73a2f6fe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/PassportFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/PassportFile.java @@ -11,11 +11,18 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; */ public class PassportFile implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String FILESIZE_FIELD = "file_size"; private static final String FILEDATE_FIELD = "file_date"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(FILESIZE_FIELD) private Integer fileSize; ///< File size @JsonProperty(FILEDATE_FIELD) @@ -42,12 +49,17 @@ public class PassportFile implements BotApiObject { return fileDate; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "PassportFile{" + "fileId='" + fileId + '\'' + ", fileSize=" + fileSize + ", fileDate=" + fileDate + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java index ea243e43..f0e21f1c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects.stickers; import com.fasterxml.jackson.annotation.JsonProperty; - import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -13,6 +12,7 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize; public class Sticker implements BotApiObject { private static final String FILEID_FIELD = "file_id"; + private static final String FILEUNIQUEID_FIELD = "file_unique_id"; private static final String WIDTH_FIELD = "width"; private static final String HEIGHT_FIELD = "height"; private static final String THUMB_FIELD = "thumb"; @@ -23,7 +23,13 @@ public class Sticker implements BotApiObject { private static final String ISANIMATED_FIELD = "is_animated"; @JsonProperty(FILEID_FIELD) - private String fileId; ///< Unique identifier for this file + private String fileId; ///< Identifier for this file, which can be used to download or reuse the file + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. + * Can't be used to download or reuse the file. + */ + @JsonProperty(FILEUNIQUEID_FIELD) + private String fileUniqueId; @JsonProperty(WIDTH_FIELD) private Integer width; ///< Sticker width @JsonProperty(HEIGHT_FIELD) @@ -81,6 +87,10 @@ public class Sticker implements BotApiObject { return isAnimated; } + public String getFileUniqueId() { + return fileUniqueId; + } + @Override public String toString() { return "Sticker{" + @@ -93,6 +103,7 @@ public class Sticker implements BotApiObject { ", setName='" + setName + '\'' + ", maskPosition=" + maskPosition + ", isAnimated=" + isAnimated + + ", fileUniqueId=" + fileUniqueId + '}'; } } diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index dbd57c85..73ed80e0 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambots-spring-boot-starter @@ -78,7 +78,7 @@ org.telegram telegrambots - 4.4.0.2 + 4.5 org.springframework.boot diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 9ea6cb51..e1768165 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots - 4.4.0.2 + 4.5 telegrambots @@ -95,7 +95,7 @@ org.telegram telegrambots-meta - 4.4.0.2 + 4.5 com.fasterxml.jackson.core