From 7f8df47f0be58cb1d955d2a6fd7f02f8e56444a2 Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Tue, 21 Aug 2018 20:59:55 +0100 Subject: [PATCH 1/5] Update version 4.1 --- README.md | 8 +- TelegramBots.wiki/Changelog.md | 5 +- TelegramBots.wiki/Getting-Started.md | 4 +- TelegramBots.wiki/abilities/Simple-Example.md | 4 +- pom.xml | 4 +- 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 +- .../passport/EncryptedPassportElement.java | 30 +++++ .../dataerror/PassportElementError.java | 3 + .../PassportElementErrorTranslationFile.java | 99 ++++++++++++++++ .../PassportElementErrorTranslationFiles.java | 111 ++++++++++++++++++ .../PassportElementErrorUnspecified.java | 97 +++++++++++++++ telegrambots-spring-boot-starter/README.md | 4 +- telegrambots-spring-boot-starter/pom.xml | 4 +- telegrambots/pom.xml | 4 +- 20 files changed, 374 insertions(+), 31 deletions(-) create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java create mode 100644 telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java diff --git a/README.md b/README.md index cefd23dd..f7a862cd 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.0.1 + 4.1 ``` ```gradle - compile "org.telegram:telegrambots:4.0.1" + compile "org.telegram:telegrambots:4.1" ``` - 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.0.1) - 3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.0.1) + 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.1) + 3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.1) 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 ab73da5a..8c0b1392 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,4 +1,7 @@ -### 4.0.0 ### +### 4.1 ### +1. Support for Api Version [4.1](https://core.telegram.org/bots/api-changelog#august-22-2018) + +### 4.0.1 ### 1. Fix bug #499 ### 4.0.0 ### diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index effe0c34..2bea5d5d 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.0.1 + 4.1 ``` * With **Gradle**: ```groovy - compile group: 'org.telegram', name: 'telegrambots', version: '4.0.1' + compile group: 'org.telegram', name: 'telegrambots', version: '4.1' ``` 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 50df2521..a05dddc6 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 - 4.0.1 + 4.1 ``` * **Gradle** ```groovy - compile group: 'org.telegram', name: 'telegrambots-abilties', version: '4.0.1' + compile group: 'org.telegram', name: 'telegrambots-abilties', version: '4.1' ``` * [JitPack](https://jitpack.io/#rubenlagus/TelegramBots) diff --git a/pom.xml b/pom.xml index 73824b21..b6176008 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 4.0.1 + 4.1 telegrambots @@ -28,6 +28,6 @@ true - 4.0.1 + 4.1 \ No newline at end of file diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index c48783d6..22f0dbd7 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,19 +18,19 @@ Usage org.telegram telegrambots-abilities - 4.0.1 + 4.1 ``` **Gradle** ```gradle - compile "org.telegram:telegrambots-abilities:4.0.1" + compile "org.telegram:telegrambots-abilities:4.1" ``` -**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.0.1) +**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.1) -**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.0.1) +**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.1) Motivation ---------- diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index b6b786bc..16ebe0f3 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-abilities - 4.0.1 + 4.1 jar Telegram Ability Bot @@ -65,7 +65,7 @@ UTF-8 UTF-8 - 4.0.1 + 4.1 3.5 3.0.4 19.0 diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md index f43e4428..bbb7ec45 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.0.1 + 4.1 ``` diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index 954607f8..3ce170a9 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-chat-session-bot - 4.0.1 + 4.1 jar Telegram Bots Chat Session Bot @@ -65,7 +65,7 @@ UTF-8 UTF-8 - 4.0.1 + 4.1 1.4.0 diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index 7edc5b7e..02984f67 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.0.1 + 4.1 ``` 2. Using Gradle: ```gradle - compile "org.telegram:telegrambotsextensions:4.0.1" + compile "org.telegram:telegrambotsextensions:4.1" ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index a5ea6a36..ed11f08b 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambotsextensions - 4.0.1 + 4.1 jar Telegram Bots Extensions @@ -59,7 +59,7 @@ UTF-8 UTF-8 - 4.0.1 + 4.1 diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 45f925f8..88dd8d92 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-meta - 4.0.1 + 4.1 jar Telegram Bots Meta diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/EncryptedPassportElement.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/EncryptedPassportElement.java index 5e2b2f7d..25bcab65 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/EncryptedPassportElement.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/EncryptedPassportElement.java @@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.objects.passport; import com.fasterxml.jackson.annotation.JsonProperty; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; +import java.util.ArrayList; import java.util.List; /** @@ -20,6 +21,8 @@ public class EncryptedPassportElement implements BotApiObject { private static final String FRONTSIDE_FIELD = "front_side"; private static final String REVERSESIDE_FIELD = "reverse_side"; private static final String SELFIE_FIELD = "selfie"; + private static final String TRANSLATION_FIELD = "translation"; + private static final String HASH_FIELD = "hash"; /** * Data type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, @@ -68,6 +71,19 @@ public class EncryptedPassportElement implements BotApiObject { */ @JsonProperty(SELFIE_FIELD) private PassportFile selfie; + /** + * Optional. Array of encrypted files with translated versions of documents provided by the user. + * Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, + * “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. + * Files can be decrypted and verified using the accompanying EncryptedCredentials. + */ + @JsonProperty(TRANSLATION_FIELD) + private ArrayList translations; + /** + * Base64-encoded element hash for using in PassportElementErrorUnspecified + */ + @JsonProperty(HASH_FIELD) + private String hash; public EncryptedPassportElement(String type, String data, String phoneNumber, String email, List files, PassportFile frontSide, PassportFile reverseSide, PassportFile selfie) { @@ -116,6 +132,18 @@ public class EncryptedPassportElement implements BotApiObject { return selfie; } + public String getHash() { + return hash; + } + + public boolean hasTranslations() { + return translations != null && !translations.isEmpty(); + } + + public ArrayList getTranslations() { + return translations; + } + @Override public String toString() { return "EncryptedPassportElement{" + @@ -127,6 +155,8 @@ public class EncryptedPassportElement implements BotApiObject { ", frontSide=" + frontSide + ", reverseSide=" + reverseSide + ", selfie=" + selfie + + ", translations=" + translations + + ", hash='" + hash + '\'' + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementError.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementError.java index aa3a66fc..554e3209 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementError.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementError.java @@ -15,6 +15,9 @@ import org.telegram.telegrambots.meta.api.interfaces.Validable; * PassportElementErrorSelfie * PassportElementErrorFile * PassportElementErrorFiles + * PassportElementErrorUnspecified + * PassportElementErrorTranslationFile + * PassportElementErrorTranslationFiles */ public interface PassportElementError extends InputBotApiObject, Validable { } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java new file mode 100644 index 00000000..5581d79a --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java @@ -0,0 +1,99 @@ +package org.telegram.telegrambots.meta.api.objects.passport.dataerror; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * @author Ruben Bermudez + * @version 4.1 + * + * Represents an issue with one of the files that constitute the translation of a document. + * The error is considered resolved when the file changes. + */ +public class PassportElementErrorTranslationFile implements PassportElementError { + private static final String SOURCE_FIELD = "source"; + private static final String TYPE_FIELD = "type"; + private static final String FILEHASH_FIELD = "file_hash"; + private static final String MESSAGE_FIELD = "message"; + + @JsonProperty(SOURCE_FIELD) + private final String source = "translation_file"; ///< Error source, must be translation_file + /** + * Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, + * “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, + * “passport_registration”, “temporary_registration” + */ + @JsonProperty(TYPE_FIELD) + private String type; + @JsonProperty(FILEHASH_FIELD) + private String fileHash; ///< Base64-encoded file hash + @JsonProperty(MESSAGE_FIELD) + private String message; ///< Error message + + public PassportElementErrorTranslationFile() { + super(); + } + + public PassportElementErrorTranslationFile(String type, String fileHash, String message) { + super(); + this.type = checkNotNull(type); + this.fileHash = checkNotNull(fileHash); + this.message = checkNotNull(message); + } + + public String getType() { + return type; + } + + public PassportElementErrorTranslationFile setType(String type) { + this.type = checkNotNull(type); + return this; + } + + public String getSource() { + return source; + } + + public String getFileHash() { + return fileHash; + } + + public PassportElementErrorTranslationFile setFileHash(String fileHash) { + this.fileHash = fileHash; + return this; + } + + public String getMessage() { + return message; + } + + public PassportElementErrorTranslationFile setMessage(String message) { + this.message = checkNotNull(message); + return this; + } + + @Override + public void validate() throws TelegramApiValidationException { + if (fileHash == null || fileHash.isEmpty()) { + throw new TelegramApiValidationException("File hash parameter can't be empty", this); + } + if (message == null || message.isEmpty()) { + throw new TelegramApiValidationException("Message parameter can't be empty", this); + } + if (type == null || type.isEmpty()) { + throw new TelegramApiValidationException("Type parameter can't be empty", this); + } + } + + @Override + public String toString() { + return "PassportElementErrorTranslationFile{" + + "source='" + source + '\'' + + ", type='" + type + '\'' + + ", fileHash='" + fileHash + '\'' + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java new file mode 100644 index 00000000..9579a3a0 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java @@ -0,0 +1,111 @@ +package org.telegram.telegrambots.meta.api.objects.passport.dataerror; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import java.util.ArrayList; +import java.util.List; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * @author Ruben Bermudez + * @version 4.1 + * + * Represents an issue with the translated version of a document. + * The error is considered resolved when a file with the document translation change. + */ +public class PassportElementErrorTranslationFiles implements PassportElementError { + private static final String SOURCE_FIELD = "source"; + private static final String TYPE_FIELD = "type"; + private static final String FILEHASHES_FIELD = "file_hashes"; + private static final String MESSAGE_FIELD = "message"; + + @JsonProperty(SOURCE_FIELD) + private final String source = "translation_files"; ///< Error source, must be translation_files + /** + * Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, + * “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, + * “passport_registration”, “temporary_registration” + */ + @JsonProperty(TYPE_FIELD) + private String type; + @JsonProperty(FILEHASHES_FIELD) + private List fileHashes; ///< List of base64-encoded file hashes + @JsonProperty(MESSAGE_FIELD) + private String message; ///< Error message + + public PassportElementErrorTranslationFiles() { + super(); + } + + public PassportElementErrorTranslationFiles(String type, List fileHashes, String message) { + super(); + this.type = checkNotNull(type); + this.fileHashes = checkNotNull(fileHashes); + this.message = checkNotNull(message); + } + + public String getType() { + return type; + } + + public PassportElementErrorTranslationFiles setType(String type) { + this.type = checkNotNull(type); + return this; + } + + public String getSource() { + return source; + } + + public List getFileHashes() { + return fileHashes; + } + + public PassportElementErrorTranslationFiles setFileHashes(List fileHashes) { + this.fileHashes = checkNotNull(fileHashes); + return this; + } + + public PassportElementErrorTranslationFiles addFileHash(String fileHash) { + fileHash = checkNotNull(fileHash); + if (fileHashes == null) { + fileHashes = new ArrayList<>(); + } + fileHashes.add(fileHash); + return this; + } + + public String getMessage() { + return message; + } + + public PassportElementErrorTranslationFiles setMessage(String message) { + this.message = checkNotNull(message); + return this; + } + + @Override + public void validate() throws TelegramApiValidationException { + if (fileHashes == null || fileHashes.isEmpty()) { + throw new TelegramApiValidationException("File hash parameter can't be empty", this); + } + if (message == null || message.isEmpty()) { + throw new TelegramApiValidationException("Message parameter can't be empty", this); + } + if (type == null || type.isEmpty()) { + throw new TelegramApiValidationException("Type parameter can't be empty", this); + } + } + + @Override + public String toString() { + return "PassportElementErrorTranslationFiles{" + + "source='" + source + '\'' + + ", type='" + type + '\'' + + ", fileHashes=" + fileHashes + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java new file mode 100644 index 00000000..e49efcfb --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java @@ -0,0 +1,97 @@ +package org.telegram.telegrambots.meta.api.objects.passport.dataerror; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * @author Ruben Bermudez + * @version 4.1 + * + * Represents an issue in an unspecified place. + * The error is considered resolved when new data is added. + */ +public class PassportElementErrorUnspecified implements PassportElementError { + private static final String SOURCE_FIELD = "source"; + private static final String TYPE_FIELD = "type"; + private static final String ELEMENTHASH_FIELD = "element_hash"; + private static final String MESSAGE_FIELD = "message"; + + @JsonProperty(SOURCE_FIELD) + private final String source = "unspecified"; ///< Error source, must be unspecified + /** + * Type of element of the user's Telegram Passport which has the issue + */ + @JsonProperty(TYPE_FIELD) + private String type; + @JsonProperty(ELEMENTHASH_FIELD) + private String elementHash; ///< Base64-encoded element hash + @JsonProperty(MESSAGE_FIELD) + private String message; ///< Error message + + public PassportElementErrorUnspecified() { + super(); + } + + public PassportElementErrorUnspecified(String type, String elementHash, String message) { + super(); + this.type = checkNotNull(type); + this.elementHash = checkNotNull(elementHash); + this.message = checkNotNull(message); + } + + public String getType() { + return type; + } + + public PassportElementErrorUnspecified setType(String type) { + this.type = checkNotNull(type); + return this; + } + + public String getSource() { + return source; + } + + public String getElementHash() { + return elementHash; + } + + public PassportElementErrorUnspecified setElementHash(String elementHash) { + this.elementHash = elementHash; + return this; + } + + public String getMessage() { + return message; + } + + public PassportElementErrorUnspecified setMessage(String message) { + this.message = checkNotNull(message); + return this; + } + + @Override + public void validate() throws TelegramApiValidationException { + if (elementHash == null || elementHash.isEmpty()) { + throw new TelegramApiValidationException("Element hash parameter can't be empty", this); + } + if (message == null || message.isEmpty()) { + throw new TelegramApiValidationException("Message parameter can't be empty", this); + } + if (type == null || type.isEmpty()) { + throw new TelegramApiValidationException("Type parameter can't be empty", this); + } + } + + @Override + public String toString() { + return "PassportElementErrorFile{" + + "source='" + source + '\'' + + ", type='" + type + '\'' + + ", elementHash='" + elementHash + '\'' + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md index a20ed49e..42d4b151 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 - 4.0.1 + 4.1 ``` **Gradle** ```gradle - compile "org.telegram:telegrambots-spring-boot-starter:4.0.1" + compile "org.telegram:telegrambots-spring-boot-starter:4.1" ``` Motivation diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index ac0bb53b..d4060688 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-spring-boot-starter - 4.0.1 + 4.1 jar Telegram Bots Spring Boot Starter @@ -59,7 +59,7 @@ UTF-8 UTF-8 - 4.0.1 + 4.1 2.0.2.RELEASE diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 1f57dab8..baba488b 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots - 4.0.1 + 4.1 jar Telegram Bots @@ -66,7 +66,7 @@ 2.8.7 2.8.0 2.5 - 4.0.1 + 4.1 From 3e5f12a4c411079e6db9b9f43df85aedb70c332f Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Tue, 21 Aug 2018 21:19:31 +0100 Subject: [PATCH 2/5] Fix #512 --- .../org/telegram/telegrambots/meta/api/objects/Chat.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 3d5d7b9c..14427628 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 @@ -9,6 +9,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; * @version 1.0 * This object represents a Telegram chat with an user or a group */ +@SuppressWarnings("WeakerAccess") public class Chat implements BotApiObject { private static final String ID_FIELD = "id"; @@ -64,7 +65,7 @@ public class Chat implements BotApiObject { @JsonProperty(STICKERSETNAME_FIELD) private String stickerSetName; ///< Optional. For supergroups, name of Group sticker set. Returned only in getChat. @JsonProperty(CANSETSTICKERSET_FIELD) - private Message canSetStickerSet; ///< Optional. True, if the bot can change group the sticker set. Returned only in getChat. + private Boolean canSetStickerSet; ///< Optional. True, if the bot can change group the sticker set. Returned only in getChat. public Chat() { super(); @@ -130,7 +131,7 @@ public class Chat implements BotApiObject { return stickerSetName; } - public Message getCanSetStickerSet() { + public Boolean getCanSetStickerSet() { return canSetStickerSet; } From f415afb568de157f29d72f6763f1c616e579db54 Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Tue, 21 Aug 2018 21:27:54 +0100 Subject: [PATCH 3/5] #Fix 507 --- .../meta/api/methods/send/SendAnimation.java | 2 +- .../telegrambots/meta/bots/AbsSender.java | 8 +++ .../telegrambots/bots/DefaultAbsSender.java | 51 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) 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 cb943c3d..d5a7fb37 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 @@ -52,7 +52,7 @@ public class SendAnimation extends PartialBotApiMethod { private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound. private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard - private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. /** * Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. * A thumbnail‘s width and height should not exceed 90. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java index f3a82ebf..b83122a4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java @@ -150,6 +150,14 @@ public abstract class AbsSender { */ public abstract Serializable execute(EditMessageMedia editMessageMedia) throws TelegramApiException; + /** + * Send animation + * @param sendAnimation Information of the animation + * @return Sent message + * @throws TelegramApiException If there is any error sending animation + */ + public abstract Message execute(SendAnimation sendAnimation) throws TelegramApiException; + // Simplified methods protected abstract , Callback extends SentCallback> void sendApiMethodAsync(Method method, Callback callback); 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 c79ff378..2a4e2d80 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java @@ -636,6 +636,57 @@ public abstract class DefaultAbsSender extends AbsSender { } } + @Override + public Message execute(SendAnimation sendAnimation) throws TelegramApiException { + assertParamNotNull(sendAnimation, "sendAnimation"); + sendAnimation.validate(); + try { + String url = getBaseUrl() + SendVoice.PATH; + HttpPost httppost = configuredHttpPost(url); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setLaxMode(); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendAnimation.CHATID_FIELD, sendAnimation.getChatId(), TEXT_PLAIN_CONTENT_TYPE); + addInputFile(builder, sendAnimation.getAnimation(), SendAnimation.ANIMATION_FIELD, true); + + if (sendAnimation.getReplyMarkup() != null) { + builder.addTextBody(SendAnimation.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendAnimation.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getReplyToMessageId() != null) { + builder.addTextBody(SendAnimation.REPLYTOMESSAGEID_FIELD, sendAnimation.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getDisableNotification() != null) { + builder.addTextBody(SendAnimation.DISABLENOTIFICATION_FIELD, sendAnimation.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getDuration() != null) { + builder.addTextBody(SendAnimation.DURATION_FIELD, sendAnimation.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getWidth() != null) { + builder.addTextBody(SendAnimation.WIDTH_FIELD, sendAnimation.getWidth().toString(), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getHeight() != null) { + builder.addTextBody(SendAnimation.HEIGHT_FIELD, sendAnimation.getHeight().toString(), TEXT_PLAIN_CONTENT_TYPE); + } + if (sendAnimation.getThumb() != null) { + addInputFile(builder, sendAnimation.getThumb(), SendAnimation.THUMB_FIELD, false); + builder.addTextBody(SendAnimation.THUMB_FIELD, sendAnimation.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE); + } + + if (sendAnimation.getCaption() != null) { + builder.addTextBody(SendAnimation.CAPTION_FIELD, sendAnimation.getCaption(), TEXT_PLAIN_CONTENT_TYPE); + if (sendAnimation.getParseMode() != null) { + builder.addTextBody(SendAnimation.PARSEMODE_FIELD, sendAnimation.getParseMode(), TEXT_PLAIN_CONTENT_TYPE); + } + } + HttpEntity multipart = builder.build(); + httppost.setEntity(multipart); + + return sendAnimation.deserializeResponse(sendHttpPostRequest(httppost)); + } catch (IOException e) { + throw new TelegramApiException("Unable to edit message media", e); + } + } + // Simplified methods @Override From a4b7abce78365307003404f6aef535beb11a80df Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Tue, 21 Aug 2018 21:29:33 +0100 Subject: [PATCH 4/5] Update changelog --- TelegramBots.wiki/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TelegramBots.wiki/Changelog.md b/TelegramBots.wiki/Changelog.md index 8c0b1392..92487ca7 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,5 +1,6 @@ ### 4.1 ### 1. Support for Api Version [4.1](https://core.telegram.org/bots/api-changelog#august-22-2018) +2. Fix #507 and #512 ### 4.0.1 ### 1. Fix bug #499 From 01d3de494529be4dd8daf698ed4e1bd4943dc830 Mon Sep 17 00:00:00 2001 From: Ruben Bermudez Date: Wed, 29 Aug 2018 21:36:11 +0100 Subject: [PATCH 5/5] Update changelog --- TelegramBots.wiki/Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TelegramBots.wiki/Changelog.md b/TelegramBots.wiki/Changelog.md index 92487ca7..07da17cb 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,5 +1,5 @@ ### 4.1 ### -1. Support for Api Version [4.1](https://core.telegram.org/bots/api-changelog#august-22-2018) +1. Support for Api Version [4.1](https://core.telegram.org/bots/api-changelog#august-27-2018) 2. Fix #507 and #512 ### 4.0.1 ###