diff --git a/README.md b/README.md index 98e5ecce..c37e5307 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 - 3.2 + 3.3 ``` ```gradle - compile "org.telegram:telegrambots:3.2" + compile "org.telegram:telegrambots:3.3" ``` - 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/3.2) - 3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.2) + 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/3.3) + 3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.3) 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 0ef3a7b0..2027e50b 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,48 +1,45 @@ -### 2.4.3 ### -1. Split library in two modules to allow custom implementations. -2. Use [Guice](https://github.com/google/guice) for dependency injection. -3. Use [Jackson](https://github.com/FasterXML/jackson) for json (de)serialization. -4. Added extra validation to methods before performing requests. -5. BotOptions has been renamed ot DefaultBotOptions. It allows now to set number of threads for async methods execution and the complete `RequestConfig` for customization purpose. -6. Added convenient method for `setChatId` using just a `Long` value instead of an String. -7. In `SentCallback` method `onError` changed second parameter to `TelegramApiRequestException` and `onResult` now receives the deserialized answer (of type `T`) instead of a `JSONObject` as second parameter -8. Moved to MIT license +### 3.2 ### +1. Support for Api Version [3.3](https://core.telegram.org/bots/api-changelog#july-21-2017) -**[[How to update to version 2.4.3|How-To-Update#2.4.3]]** -### 2.4.4 ### -1. Added `cache_time` to ÀnswerCallbackQuery method -2. Added field `forward_from_message_id` to `Message` object -3. Renamed `ReplyKeyboardHide` to `ReplyKeyboardRemove` and its field `hide_keyboard` to `remove_keyboard` -4. Added field `force` and `disable_edit_message` to `SetGameScore`, removed `edit_message` one. -5. Added `channel_post` and `edited_channel_post` to `Update` object. +### 3.2 ### +1. Support for Api Version [3.2](https://core.telegram.org/bots/api-changelog#july-21-2017) +2. Deprecated all redundant methods in AbsSender, will be removed in next major release +3. New Abstract methods `addStickerToSet`, `createNewStickerSet` and `uploadStickerFile` in AbsSender. +4. Abilities module +5. Removed deprecated methods from previous versions +6. Bug fixing: #257, #270 +7. Simplify code from DefaultAbsSender: #272 -**[[How to update to version 2.4.4|How-To-Update#2.4.4]]** +**[[How to update to version 3.2|How-To-Update#3.2]]** -### 2.4.4.1 ### -1. New `max_connections` in `setWebhook` method. -2. New `allowed_updates` in `setWebhook` and `getUpdates` -3. New `deleteWebhook` method -4. Added new configs to DefaultBotOptions to handle `max_connections` and `allowed_updates` +### 3.1.2 ### +1. Fix bug #266 -### 2.4.4.3 ### -1. In `BotSession`, renamed `close` to `stop`. `Close` method is maintained for backward compatibility. -2. Support crating webhook with HTTP servers (HTTPS must be managed via external tools) +### 3.1.1 ### +1. Fix bug #264 -**[[How to update to version 2.4.4.3|How-To-Update#2.4.4.3]]** +### 3.1.0 ### +1. Support for Api Version [3.1](https://core.telegram.org/bots/api-changelog#june-30-2017) +2. Simplified `DefaultAbsSender` +3. Added new abstract method `setChatPhoto` to AbsSender. +4. Added new method `execute` and `executeAsync` that can be used to send any api method that extends `BotApiMethod` class. +5. Added new constructors to `GetChat`, `GetChatAdministrators`, `GetChatMember`, `GetChatMemberCount`, `KickChatMember`, `LeaveChat` and `UnbanChatMember` with mandatory fields as parameters. -### 2.4.4.4 ### -1. EditMessageText, EditMessageCaption and EditMessageReplyMarkup now return a `Serializable` object that can be `Boolean` or `Message` +**[[How to update to version 3.1.0|How-To-Update#3.1.0]]** -**[[How to update to version 2.4.4.4|How-To-Update#2.4.4.4]]** +### 3.0.2 ### +1. Bug Fixing: #250 +2. Added new module `telegrambots-extensions` that should contains any extensions of the API such as CommandBot or TimedBot. +3. `TelegramLongPollingCommandBot` receives now the bot username as constructor parameters, all deprecated constructors will be removed in next major release. +4. `getUsername` method from `TelegramLongPollingCommandBot` can be considered `final` and will be so in next major release. -### 2.4.4.5 ### -1. New validations for AnswerInlineQuery according to Telegram Bots API changes. -2. Added Maven-enforcer-plugin to Maven pom. -3. Added new How to send photos by file_id to FAQ. -4. Added reference to new gitbook about this library. -5. Added custom ExponentialBackOff waiting time when having network problems in long-polling mode. (Custom implementation is allowed via BotOptions) -6. Bug fixing: #184, #183 +**[[How to update to version 3.0.2|How-To-Update#3.0.2]]** + +### 3.0.1 ### +1. Added `getLevel` to `BotLogger` class. +2. Fix wrong URL when setting webhook +3. Bug Fixing: #244, #233 ### 3.0 ### 1. New field `gif_duration` and `mpeg4_duration` in `InlineQueryResultGif` and `InlineQueryResultMpeg4Gif`. @@ -55,42 +52,48 @@ **[[How to update to version 3.0|How-To-Update#3.0]]** -### 3.0.1 ### -1. Added `getLevel` to `BotLogger` class. -2. Fix wrong URL when setting webhook -3. Bug Fixing: #244, #233 +### 2.4.4.5 ### +1. New validations for AnswerInlineQuery according to Telegram Bots API changes. +2. Added Maven-enforcer-plugin to Maven pom. +3. Added new How to send photos by file_id to FAQ. +4. Added reference to new gitbook about this library. +5. Added custom ExponentialBackOff waiting time when having network problems in long-polling mode. (Custom implementation is allowed via BotOptions) +6. Bug fixing: #184, #183 -### 3.0.2 ### -1. Bug Fixing: #250 -2. Added new module `telegrambots-extensions` that should contains any extensions of the API such as CommandBot or TimedBot. -3. `TelegramLongPollingCommandBot` receives now the bot username as constructor parameters, all deprecated constructors will be removed in next major release. -4. `getUsername` method from `TelegramLongPollingCommandBot` can be considered `final` and will be so in next major release. +### 2.4.4.4 ### +1. EditMessageText, EditMessageCaption and EditMessageReplyMarkup now return a `Serializable` object that can be `Boolean` or `Message` -**[[How to update to version 3.0.2|How-To-Update#3.0.2]]** +**[[How to update to version 2.4.4.4|How-To-Update#2.4.4.4]]** -### 3.1.0 ### -1. Support for Api Version [3.1](https://core.telegram.org/bots/api-changelog#june-30-2017) -2. Simplified `DefaultAbsSender` -3. Added new abstract method `setChatPhoto` to AbsSender. -4. Added new method `execute` and `executeAsync` that can be used to send any api method that extends `BotApiMethod` class. -5. Added new constructors to `GetChat`, `GetChatAdministrators`, `GetChatMember`, `GetChatMemberCount`, `KickChatMember`, `LeaveChat` and `UnbanChatMember` with mandatory fields as parameters. +### 2.4.4.3 ### +1. In `BotSession`, renamed `close` to `stop`. `Close` method is maintained for backward compatibility. +2. Support crating webhook with HTTP servers (HTTPS must be managed via external tools) -**[[How to update to version 3.1.0|How-To-Update#3.1.0]]** +**[[How to update to version 2.4.4.3|How-To-Update#2.4.4.3]]** -### 3.1.1 ### -1. Fix bug #264 +### 2.4.4.1 ### +1. New `max_connections` in `setWebhook` method. +2. New `allowed_updates` in `setWebhook` and `getUpdates` +3. New `deleteWebhook` method +4. Added new configs to DefaultBotOptions to handle `max_connections` and `allowed_updates` +### 2.4.4 ### +1. Added `cache_time` to ÀnswerCallbackQuery method +2. Added field `forward_from_message_id` to `Message` object +3. Renamed `ReplyKeyboardHide` to `ReplyKeyboardRemove` and its field `hide_keyboard` to `remove_keyboard` +4. Added field `force` and `disable_edit_message` to `SetGameScore`, removed `edit_message` one. +5. Added `channel_post` and `edited_channel_post` to `Update` object. -### 3.1.2 ### -1. Fix bug #266 +**[[How to update to version 2.4.4|How-To-Update#2.4.4]]** -### 3.2 ### -1. Support for Api Version [3.2](https://core.telegram.org/bots/api-changelog#july-21-2017) -2. Deprecated all redundant methods in AbsSender, will be removed in next major release -3. New Abstract methods `addStickerToSet`, `createNewStickerSet` and `uploadStickerFile` in AbsSender. -4. Abilities module -5. Removed deprecated methods from previous versions -6. Bug fixing: #257, #270 -7. Simplify code from DefaultAbsSender: #272 +### 2.4.3 ### +1. Split library in two modules to allow custom implementations. +2. Use [Guice](https://github.com/google/guice) for dependency injection. +3. Use [Jackson](https://github.com/FasterXML/jackson) for json (de)serialization. +4. Added extra validation to methods before performing requests. +5. BotOptions has been renamed ot DefaultBotOptions. It allows now to set number of threads for async methods execution and the complete `RequestConfig` for customization purpose. +6. Added convenient method for `setChatId` using just a `Long` value instead of an String. +7. In `SentCallback` method `onError` changed second parameter to `TelegramApiRequestException` and `onResult` now receives the deserialized answer (of type `T`) instead of a `JSONObject` as second parameter +8. Moved to MIT license -**[[How to update to version 3.2|How-To-Update#3.2]]** \ No newline at end of file +**[[How to update to version 2.4.3|How-To-Update#2.4.3]]** \ No newline at end of file diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index c45cc993..c8f49e42 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 - 3.2 + 3.3 ``` * With **Gradle**: ```groovy - compile group: 'org.telegram', name: 'telegrambots', version: '3.2' + compile group: 'org.telegram', name: 'telegrambots', version: '3.3' ``` 2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots). diff --git a/pom.xml b/pom.xml index af5ae0f0..15e915d9 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.telegram Bots pom - 3.2 + 3.3 telegrambots @@ -26,6 +26,6 @@ true - 3.2 + 3.3 \ No newline at end of file diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index c4f76df4..8c8f6ba6 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,19 +18,19 @@ Usage org.telegram telegrambots-abilities - 3.2 + 3.3 ``` **Gradle** ```gradle - compile "org.telegram:telegrambots-abilities:3.2" + compile "org.telegram:telegrambots-abilities:3.3" ``` -**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v3.2) +**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v3.3) -**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.2) +**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.3) Motivation ---------- diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index 6017c0bc..4565f134 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-abilities - 3.2 + 3.3 jar Telegram Ability Bot @@ -65,7 +65,7 @@ UTF-8 UTF-8 - 3.2 + 3.3 3.5 3.0.4 19.0 diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index e6176851..bf75827a 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 - 3.2 + 3.3 ``` 2. Using Gradle: ```gradle - compile "org.telegram:telegrambotsextensions:3.2" + compile "org.telegram:telegrambotsextensions:3.3" ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index f4d66ff8..c8ef2b38 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambotsextensions - 3.2 + 3.3 jar Telegram Bots Extensions @@ -59,7 +59,7 @@ UTF-8 UTF-8 - 3.2 + 3.3 diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 8d9fecf3..501eec82 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots-meta - 3.2 + 3.3 jar Telegram Bots Meta diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Chat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Chat.java index d5b113e8..0ac20c70 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Chat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Chat.java @@ -21,6 +21,7 @@ public class Chat implements BotApiObject { private static final String PHOTO_FIELD = "photo"; private static final String DESCRIPTION_FIELD = "description"; private static final String INVITELINK_FIELD = "invite_link"; + private static final String PINNEDMESSAGE_FIELD = "pinned_message"; private static final String USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; @@ -56,6 +57,8 @@ public class Chat implements BotApiObject { private String description; ///< Optional. Description, for supergroups and channel chats. Returned only in getChat. @JsonProperty(INVITELINK_FIELD) private String inviteLink; ///< Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat. + @JsonProperty(PINNEDMESSAGE_FIELD) + private Message pinnedMessage; ///< Optional. Pinned message, for supergroups. Returned only in getChat. public Chat() { super(); @@ -113,6 +116,10 @@ public class Chat implements BotApiObject { return inviteLink; } + public Message getPinnedMessage() { + return pinnedMessage; + } + @Override public String toString() { return "Chat{" + @@ -126,6 +133,7 @@ public class Chat implements BotApiObject { ", photo=" + photo + ", description='" + description + '\'' + ", inviteLink='" + inviteLink + '\'' + + ", pinnedMessage=" + pinnedMessage + '}'; } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Message.java index 05ec6374..d396ce8a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/Message.java @@ -52,6 +52,8 @@ public class Message implements BotApiObject { private static final String INVOICE_FIELD = "invoice"; private static final String SUCCESSFUL_PAYMENT_FIELD = "successful_payment"; private static final String VIDEO_NOTE_FIELD = "video_note"; + private static final String AUTHORSIGNATURE_FIELD = "author_signature"; + private static final String FORWARDSIGNATURE_FIELD = "forward_signature"; @JsonProperty(MESSAGEID_FIELD) private Integer messageId; ///< Integer Unique message identifier @@ -159,6 +161,11 @@ public class Message implements BotApiObject { private SuccessfulPayment successfulPayment; ///< Optional. Message is a service message about a successful payment, information about the payment. @JsonProperty(VIDEO_NOTE_FIELD) private VideoNote videoNote; ///< Optional. Message is a video note, information about the video message + @JsonProperty(AUTHORSIGNATURE_FIELD) + private String authorSignature; ///< Optional. Post author signature for posts in channel chats + @JsonProperty(FORWARDSIGNATURE_FIELD) + private String forwardSignature; ///< Optional. Post author signature for messages forwarded from channel chats + public Message() { super(); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java index ede33902..88a0f0a9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/api/objects/User.java @@ -13,6 +13,7 @@ public class User implements BotApiObject { private static final String ID_FIELD = "id"; private static final String FIRSTNAME_FIELD = "first_name"; + private static final String ISBOT_FIELD = "is_bot"; private static final String LASTNAME_FIELD = "last_name"; private static final String USERNAME_FIELD = "username"; private static final String LANGUAGECODE_FIELD = "language_code"; @@ -21,6 +22,8 @@ public class User implements BotApiObject { private Integer id; ///< Unique identifier for this user or bot @JsonProperty(FIRSTNAME_FIELD) private String firstName; ///< User‘s or bot’s first name + @JsonProperty(ISBOT_FIELD) + private Boolean isBot; ///< True, if this user is a bot @JsonProperty(LASTNAME_FIELD) private String lastName; ///< Optional. User‘s or bot’s last name @JsonProperty(USERNAME_FIELD) @@ -52,11 +55,16 @@ public class User implements BotApiObject { return languageCode; } + public Boolean getBot() { + return isBot; + } + @Override public String toString() { return "User{" + "id=" + id + ", firstName='" + firstName + '\'' + + ", isBot=" + isBot + ", lastName='" + lastName + '\'' + ", userName='" + userName + '\'' + ", languageCode='" + languageCode + '\'' + diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 80d06cd4..36e7b5f1 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.telegram telegrambots - 3.2 + 3.3 jar Telegram Bots @@ -66,7 +66,7 @@ 2.8.7 2.8.0 2.5 - 3.2 + 3.3 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 6327b6cf..c4c09f29 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java @@ -133,6 +133,7 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.isNewDocument()) { if (sendDocument.getNewDocumentFile() != null) { @@ -176,7 +177,8 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendPhoto.isNewPhoto()) { if (sendPhoto.getNewPhotoFile() != null) { builder.addBinaryBody(SendPhoto.PHOTO_FIELD, sendPhoto.getNewPhotoFile()); @@ -186,19 +188,19 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(SendPhoto.PHOTO_FIELD, new java.io.File(sendPhoto.getPhoto()), ContentType.APPLICATION_OCTET_STREAM, sendPhoto.getPhotoName()); } } else { - builder.addTextBody(SendPhoto.PHOTO_FIELD, sendPhoto.getPhoto()); + builder.addTextBody(SendPhoto.PHOTO_FIELD, sendPhoto.getPhoto(), TEXT_PLAIN_CONTENT_TYPE); } if (sendPhoto.getReplyMarkup() != null) { builder.addTextBody(SendPhoto.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendPhoto.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendPhoto.getReplyToMessageId() != null) { - builder.addTextBody(SendPhoto.REPLYTOMESSAGEID_FIELD, sendPhoto.getReplyToMessageId().toString()); + builder.addTextBody(SendPhoto.REPLYTOMESSAGEID_FIELD, sendPhoto.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendPhoto.getCaption() != null) { builder.addTextBody(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption(), TEXT_PLAIN_CONTENT_TYPE); } if (sendPhoto.getDisableNotification() != null) { - builder.addTextBody(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString()); + builder.addTextBody(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -219,7 +221,8 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendVideo.isNewVideo()) { if (sendVideo.getNewVideoFile() != null) { builder.addBinaryBody(SendVideo.VIDEO_FIELD, sendVideo.getNewVideoFile()); @@ -229,28 +232,28 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(SendVideo.VIDEO_FIELD, new java.io.File(sendVideo.getVideo()), ContentType.APPLICATION_OCTET_STREAM, sendVideo.getVideoName()); } } else { - builder.addTextBody(SendVideo.VIDEO_FIELD, sendVideo.getVideo()); + builder.addTextBody(SendVideo.VIDEO_FIELD, sendVideo.getVideo(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getReplyMarkup() != null) { builder.addTextBody(SendVideo.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendVideo.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getReplyToMessageId() != null) { - builder.addTextBody(SendVideo.REPLYTOMESSAGEID_FIELD, sendVideo.getReplyToMessageId().toString()); + builder.addTextBody(SendVideo.REPLYTOMESSAGEID_FIELD, sendVideo.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getCaption() != null) { builder.addTextBody(SendVideo.CAPTION_FIELD, sendVideo.getCaption(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getDuration() != null) { - builder.addTextBody(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString()); + builder.addTextBody(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getWidth() != null) { - builder.addTextBody(SendVideo.WIDTH_FIELD, sendVideo.getWidth().toString()); + builder.addTextBody(SendVideo.WIDTH_FIELD, sendVideo.getWidth().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getHeight() != null) { - builder.addTextBody(SendVideo.HEIGHT_FIELD, sendVideo.getHeight().toString()); + builder.addTextBody(SendVideo.HEIGHT_FIELD, sendVideo.getHeight().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideo.getDisableNotification() != null) { - builder.addTextBody(SendVideo.DISABLENOTIFICATION_FIELD, sendVideo.getDisableNotification().toString()); + builder.addTextBody(SendVideo.DISABLENOTIFICATION_FIELD, sendVideo.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -271,7 +274,8 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendVideoNote.CHATID_FIELD, sendVideoNote.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendVideoNote.CHATID_FIELD, sendVideoNote.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendVideoNote.isNewVideoNote()) { if (sendVideoNote.getNewVideoNoteFile() != null) { builder.addBinaryBody(SendVideoNote.VIDEONOTE_FIELD, sendVideoNote.getNewVideoNoteFile()); @@ -281,22 +285,22 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(SendVideoNote.VIDEONOTE_FIELD, new java.io.File(sendVideoNote.getVideoNote()), ContentType.APPLICATION_OCTET_STREAM, sendVideoNote.getVideoNoteName()); } } else { - builder.addTextBody(SendVideoNote.VIDEONOTE_FIELD, sendVideoNote.getVideoNote()); + builder.addTextBody(SendVideoNote.VIDEONOTE_FIELD, sendVideoNote.getVideoNote(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideoNote.getReplyMarkup() != null) { builder.addTextBody(SendVideoNote.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendVideoNote.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideoNote.getReplyToMessageId() != null) { - builder.addTextBody(SendVideoNote.REPLYTOMESSAGEID_FIELD, sendVideoNote.getReplyToMessageId().toString()); + builder.addTextBody(SendVideoNote.REPLYTOMESSAGEID_FIELD, sendVideoNote.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideoNote.getDuration() != null) { - builder.addTextBody(SendVideoNote.DURATION_FIELD, sendVideoNote.getDuration().toString()); + builder.addTextBody(SendVideoNote.DURATION_FIELD, sendVideoNote.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideoNote.getLength() != null) { - builder.addTextBody(SendVideoNote.LENGTH_FIELD, sendVideoNote.getLength().toString()); + builder.addTextBody(SendVideoNote.LENGTH_FIELD, sendVideoNote.getLength().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVideoNote.getDisableNotification() != null) { - builder.addTextBody(SendVideoNote.DISABLENOTIFICATION_FIELD, sendVideoNote.getDisableNotification().toString()); + builder.addTextBody(SendVideoNote.DISABLENOTIFICATION_FIELD, sendVideoNote.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -318,7 +322,8 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendSticker.isNewSticker()) { if (sendSticker.getNewStickerFile() != null) { builder.addBinaryBody(SendSticker.STICKER_FIELD, sendSticker.getNewStickerFile()); @@ -328,16 +333,16 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(SendSticker.STICKER_FIELD, new java.io.File(sendSticker.getSticker()), ContentType.APPLICATION_OCTET_STREAM, sendSticker.getStickerName()); } } else { - builder.addTextBody(SendSticker.STICKER_FIELD, sendSticker.getSticker()); + builder.addTextBody(SendSticker.STICKER_FIELD, sendSticker.getSticker(), TEXT_PLAIN_CONTENT_TYPE); } if (sendSticker.getReplyMarkup() != null) { builder.addTextBody(SendSticker.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendSticker.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendSticker.getReplyToMessageId() != null) { - builder.addTextBody(SendSticker.REPLYTOMESSAGEID_FIELD, sendSticker.getReplyToMessageId().toString()); + builder.addTextBody(SendSticker.REPLYTOMESSAGEID_FIELD, sendSticker.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendSticker.getDisableNotification() != null) { - builder.addTextBody(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString()); + builder.addTextBody(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); @@ -362,7 +367,8 @@ public abstract class DefaultAbsSender extends AbsSender { String url = getBaseUrl() + SendAudio.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendAudio.isNewAudio()) { if (sendAudio.getNewAudioFile() != null) { builder.addBinaryBody(SendAudio.AUDIO_FIELD, sendAudio.getNewAudioFile()); @@ -378,7 +384,7 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendAudio.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendAudio.getReplyToMessageId() != null) { - builder.addTextBody(SendAudio.REPLYTOMESSAGEID_FIELD, sendAudio.getReplyToMessageId().toString()); + builder.addTextBody(SendAudio.REPLYTOMESSAGEID_FIELD, sendAudio.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendAudio.getPerformer() != null) { builder.addTextBody(SendAudio.PERFOMER_FIELD, sendAudio.getPerformer(), TEXT_PLAIN_CONTENT_TYPE); @@ -387,10 +393,10 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addTextBody(SendAudio.TITLE_FIELD, sendAudio.getTitle(), TEXT_PLAIN_CONTENT_TYPE); } if(sendAudio.getDuration() != null){ - builder.addTextBody(SendAudio.DURATION_FIELD, sendAudio.getDuration().toString()); + builder.addTextBody(SendAudio.DURATION_FIELD, sendAudio.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendAudio.getDisableNotification() != null) { - builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString()); + builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendAudio.getCaption() != null) { builder.addTextBody(SendAudio.CAPTION_FIELD, sendAudio.getCaption(), TEXT_PLAIN_CONTENT_TYPE); @@ -420,7 +426,8 @@ public abstract class DefaultAbsSender extends AbsSender { String url = getBaseUrl() + SendVoice.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (sendVoice.isNewVoice()) { if (sendVoice.getNewVoiceFile() != null) { builder.addBinaryBody(SendVoice.VOICE_FIELD, sendVoice.getNewVoiceFile()); @@ -430,19 +437,19 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(SendVoice.VOICE_FIELD, new java.io.File(sendVoice.getVoice()), ContentType.create("audio/ogg"), sendVoice.getVoiceName()); } } else { - builder.addTextBody(SendVoice.VOICE_FIELD, sendVoice.getVoice()); + builder.addTextBody(SendVoice.VOICE_FIELD, sendVoice.getVoice(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVoice.getReplyMarkup() != null) { builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendVoice.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendVoice.getReplyToMessageId() != null) { - builder.addTextBody(SendVoice.REPLYTOMESSAGEID_FIELD, sendVoice.getReplyToMessageId().toString()); + builder.addTextBody(SendVoice.REPLYTOMESSAGEID_FIELD, sendVoice.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVoice.getDisableNotification() != null) { - builder.addTextBody(SendVoice.DISABLENOTIFICATION_FIELD, sendVoice.getDisableNotification().toString()); + builder.addTextBody(SendVoice.DISABLENOTIFICATION_FIELD, sendVoice.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVoice.getDuration() != null) { - builder.addTextBody(SendVoice.DURATION_FIELD, sendVoice.getDuration().toString()); + builder.addTextBody(SendVoice.DURATION_FIELD, sendVoice.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendVoice.getCaption() != null) { builder.addTextBody(SendVoice.CAPTION_FIELD, sendVoice.getCaption(), TEXT_PLAIN_CONTENT_TYPE); @@ -466,7 +473,8 @@ public abstract class DefaultAbsSender extends AbsSender { HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody(SetChatPhoto.CHATID_FIELD, setChatPhoto.getChatId()); + builder.setCharset(StandardCharsets.UTF_8); + builder.addTextBody(SetChatPhoto.CHATID_FIELD, setChatPhoto.getChatId(), TEXT_PLAIN_CONTENT_TYPE); if (setChatPhoto.getPhoto() != null) { builder.addBinaryBody(SetChatPhoto.PHOTO_FIELD, setChatPhoto.getPhoto()); } else if (setChatPhoto.getPhotoStream() != null) { @@ -490,6 +498,7 @@ public abstract class DefaultAbsSender extends AbsSender { String url = getBaseUrl() + AddStickerToSet.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(AddStickerToSet.USERID_FIELD, addStickerToSet.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE); builder.addTextBody(AddStickerToSet.NAME_FIELD, addStickerToSet.getName(), TEXT_PLAIN_CONTENT_TYPE); builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE); @@ -502,7 +511,7 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(AddStickerToSet.PNGSTICKER_FIELD, new java.io.File(addStickerToSet.getPngSticker()), ContentType.create("image/png"), addStickerToSet.getPngStickerName()); } } else { - builder.addTextBody(AddStickerToSet.PNGSTICKER_FIELD, addStickerToSet.getPngSticker()); + builder.addTextBody(AddStickerToSet.PNGSTICKER_FIELD, addStickerToSet.getPngSticker(), TEXT_PLAIN_CONTENT_TYPE); } if (addStickerToSet.getMaskPosition() != null) { builder.addTextBody(AddStickerToSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(addStickerToSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE); @@ -524,11 +533,12 @@ public abstract class DefaultAbsSender extends AbsSender { String url = getBaseUrl() + CreateNewStickerSet.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(CreateNewStickerSet.USERID_FIELD, createNewStickerSet.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE); builder.addTextBody(CreateNewStickerSet.NAME_FIELD, createNewStickerSet.getName(), TEXT_PLAIN_CONTENT_TYPE); builder.addTextBody(CreateNewStickerSet.TITLE_FIELD, createNewStickerSet.getTitle(), TEXT_PLAIN_CONTENT_TYPE); builder.addTextBody(CreateNewStickerSet.EMOJIS_FIELD, createNewStickerSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE); - builder.addTextBody(CreateNewStickerSet.CONTAINSMASKS_FIELD, createNewStickerSet.getContainsMasks().toString()); + builder.addTextBody(CreateNewStickerSet.CONTAINSMASKS_FIELD, createNewStickerSet.getContainsMasks().toString(), TEXT_PLAIN_CONTENT_TYPE); if (createNewStickerSet.isNewPngSticker()) { if (createNewStickerSet.getPngStickerFile() != null) { builder.addBinaryBody(CreateNewStickerSet.PNGSTICKER_FIELD, createNewStickerSet.getPngStickerFile()); @@ -538,7 +548,7 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addBinaryBody(CreateNewStickerSet.PNGSTICKER_FIELD, new java.io.File(createNewStickerSet.getPngSticker()), ContentType.create("image/png"), createNewStickerSet.getPngStickerName()); } } else { - builder.addTextBody(CreateNewStickerSet.PNGSTICKER_FIELD, createNewStickerSet.getPngSticker()); + builder.addTextBody(CreateNewStickerSet.PNGSTICKER_FIELD, createNewStickerSet.getPngSticker(), TEXT_PLAIN_CONTENT_TYPE); } if (createNewStickerSet.getMaskPosition() != null) { builder.addTextBody(CreateNewStickerSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(createNewStickerSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE); @@ -560,6 +570,7 @@ public abstract class DefaultAbsSender extends AbsSender { String url = getBaseUrl() + UploadStickerFile.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(UploadStickerFile.USERID_FIELD, uploadStickerFile.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE); if (uploadStickerFile.getNewPngStickerFile() != null) { builder.addBinaryBody(UploadStickerFile.PNGSTICKER_FIELD, uploadStickerFile.getNewPngStickerFile());