diff --git a/Bots.ipr b/Bots.ipr
index bca33768..946ddb9d 100644
--- a/Bots.ipr
+++ b/Bots.ipr
@@ -22,10 +22,10 @@
-
-
-
+
+
+
@@ -791,30 +791,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -876,6 +852,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1423,37 +1421,37 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/README.md b/README.md
index 9faef288..6693c1fa 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.6
+ 4.7
```
```gradle
- compile "org.telegram:telegrambots:4.6"
+ compile "org.telegram:telegrambots:4.7"
```
- 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.6)
- 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.6)
+ 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.7)
+ 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.7)
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 1ab4cef5..1a666552 100644
--- a/TelegramBots.wiki/Changelog.md
+++ b/TelegramBots.wiki/Changelog.md
@@ -1,3 +1,6 @@
+### 4.7 ###
+1. Update Api version [4.7](https://core.telegram.org/bots/api-changelog#march-30-2020)
+
### 4.6 ###
1. Update Api version [4.6](https://core.telegram.org/bots/api-changelog#january-23-2020)
diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md
index d244923d..9eba8666 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.6
+ 4.7
```
* With **Gradle**:
```groovy
- compile group: 'org.telegram', name: 'telegrambots', version: '4.6'
+ compile group: 'org.telegram', name: 'telegrambots', version: '4.7'
```
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 add6c2b6..3e3407c6 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.6
+ 4.7
```
* **Gradle**
diff --git a/pom.xml b/pom.xml
index ff9a6ce5..593ae589 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
pom
- 4.6
+ 4.7
telegrambots
@@ -156,6 +156,11 @@
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.8.2
+
org.apache.maven.plugins
maven-gpg-plugin
@@ -170,6 +175,23 @@
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.1.1
+
+
+ aggregate
+ site
+
+ aggregate
+
+
+
+
+ none
+
+
org.sonatype.plugins
nexus-staging-maven-plugin
diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md
index 173558cd..018a1d6c 100644
--- a/telegrambots-abilities/README.md
+++ b/telegrambots-abilities/README.md
@@ -18,19 +18,19 @@ Usage
org.telegram
telegrambots-abilities
- 4.6
+ 4.7
```
**Gradle**
```gradle
- compile "org.telegram:telegrambots-abilities:4.6"
+ compile "org.telegram:telegrambots-abilities:4.7"
```
-**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.6)
+**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.7)
-**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.6)
+**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.7)
Motivation
----------
diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml
index e496e171..de5452d8 100644
--- a/telegrambots-abilities/pom.xml
+++ b/telegrambots-abilities/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambots-abilities
@@ -84,7 +84,7 @@
org.telegram
telegrambots
- 4.6
+ 4.7
org.apache.commons
diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md
index 8df586ff..c8ca3f29 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.6
+ 4.7
```
diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml
index 84834dcc..d8ebd720 100644
--- a/telegrambots-chat-session-bot/pom.xml
+++ b/telegrambots-chat-session-bot/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambots-chat-session-bot
@@ -84,7 +84,7 @@
org.telegram
telegrambots
- 4.6
+ 4.7
diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md
index 6fc85cb3..ec5e4e06 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.6
+ 4.7
```
2. Using Gradle:
```gradle
- compile "org.telegram:telegrambotsextensions:4.6"
+ compile "org.telegram:telegrambotsextensions:4.7"
```
\ No newline at end of file
diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml
index 26e835ec..495e12e6 100644
--- a/telegrambots-extensions/pom.xml
+++ b/telegrambots-extensions/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambotsextensions
@@ -75,7 +75,7 @@
org.telegram
telegrambots
- 4.6
+ 4.7
diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml
index c95ecee0..889dbd23 100644
--- a/telegrambots-meta/pom.xml
+++ b/telegrambots-meta/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambots-meta
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java
new file mode 100644
index 00000000..a1347bc3
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java
@@ -0,0 +1,55 @@
+package org.telegram.telegrambots.meta.api.methods.commands;
+
+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.api.objects.commands.BotCommand;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * @author Ruben Bermudez
+ * @version 4.7
+ * Use this method to get the current list of the bot's commands.
+ * Requires no parameters.
+ * Returns Array of BotCommand on success.
+ */
+public class GetMyCommands extends BotApiMethod> {
+ public static final String PATH = "getMyCommands";
+
+ public GetMyCommands() {
+ super();
+ }
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public ArrayList 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 sending commands", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ }
+
+ @Override
+ public String toString() {
+ return "GetMyCommands{}";
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java
new file mode 100644
index 00000000..4828e0db
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java
@@ -0,0 +1,89 @@
+package org.telegram.telegrambots.meta.api.methods.commands;
+
+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.api.objects.commands.BotCommand;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Ruben Bermudez
+ * @version 4.7
+ * Use this method to change the list of the bot's commands. Returns True on success.
+ */
+public class SetMyCommands extends BotApiMethod {
+ public static final String PATH = "setMyCommands";
+
+ private static final String COMMANDS_FIELD = "commands";
+
+ /**
+ * A JSON-serialized list of bot commands to be set as the list of the bot's commands.
+ * At most 100 commands can be specified.
+ */
+ @JsonProperty(COMMANDS_FIELD)
+ private List commands;
+
+ public SetMyCommands() {
+ super();
+ }
+
+ public SetMyCommands(List commands) {
+ this.commands = checkNotNull(commands);
+ }
+
+ public List getCommands() {
+ return commands;
+ }
+
+ public SetMyCommands setCommands(List commands) {
+ this.commands = checkNotNull(commands);
+ 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 sending commands", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (commands == null) {
+ throw new TelegramApiValidationException("Commands parameter can't be empty", this);
+ }
+ if (commands.size() > 100) {
+ throw new TelegramApiValidationException("No more than 100 commands are allowed", this);
+ }
+ for (BotCommand command : commands) {
+ command.validate();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "SetMyCommands{" +
+ "commands=" + commands +
+ '}';
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java
new file mode 100644
index 00000000..f2a391f7
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java
@@ -0,0 +1,126 @@
+package org.telegram.telegrambots.meta.api.methods.send;
+
+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.api.objects.Message;
+import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 4.7
+ * Use this method to send a dice, which will have a random value from 1 to 6. On success, the sent Message is returned.
+ * (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
+ */
+public class SendDice extends BotApiMethod {
+ public static final String PATH = "sendDice";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+
+ @JsonProperty(CHATID_FIELD)
+ private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ @JsonProperty(DISABLENOTIFICATION_FIELD)
+ private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
+ @JsonProperty(REPLYTOMESSAGEID_FIELD)
+ private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
+ @JsonProperty(REPLYMARKUP_FIELD)
+ private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+
+ public SendDice() {
+ super();
+ }
+
+ public String getChatId() {
+ return chatId;
+ }
+
+ public SendDice setChatId(String chatId) {
+ this.chatId = chatId;
+ return this;
+ }
+
+ public SendDice setChatId(Long chatId) {
+ this.chatId = chatId.toString();
+ return this;
+ }
+
+ public Integer getReplyToMessageId() {
+ return replyToMessageId;
+ }
+
+ public SendDice setReplyToMessageId(Integer replyToMessageId) {
+ this.replyToMessageId = replyToMessageId;
+ return this;
+ }
+
+ public ReplyKeyboard getReplyMarkup() {
+ return replyMarkup;
+ }
+
+ public SendDice setReplyMarkup(ReplyKeyboard replyMarkup) {
+ this.replyMarkup = replyMarkup;
+ return this;
+ }
+
+ public Boolean getDisableNotification() {
+ return disableNotification;
+ }
+
+ public SendDice enableNotification() {
+ this.disableNotification = false;
+ return this;
+ }
+
+ public SendDice disableNotification() {
+ this.disableNotification = true;
+ return this;
+ }
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public Message 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 sending dice", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (chatId == null) {
+ throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
+ }
+ if (replyMarkup != null) {
+ replyMarkup.validate();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "SendDice{" +
+ "chatId='" + chatId + '\'' +
+ ", disableNotification=" + disableNotification +
+ ", replyToMessageId=" + replyToMessageId +
+ ", replyMarkup=" + replyMarkup +
+ '}';
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java
index 5dc3e48e..e1f433d0 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java
@@ -2,8 +2,8 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -18,7 +18,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
- * Use this method to add a new sticker to a set created by the bot. Returns True on success.
+ * Use this method to add a new sticker to a set created by the bot.
+ * You must use exactly one of the fields png_sticker or tgs_sticker.
+ * Animated stickers can be added to animated sticker sets and only to them.
+ * Animated sticker sets can have up to 50 stickers.
+ * Static sticker sets can have up to 120 stickers.
+ * Returns True on success.
*/
public class AddStickerToSet extends PartialBotApiMethod {
public static final String PATH = "addStickerToSet";
@@ -26,6 +31,7 @@ public class AddStickerToSet extends PartialBotApiMethod {
public static final String USERID_FIELD = "user_id";
public static final String NAME_FIELD = "name";
public static final String PNGSTICKER_FIELD = "png_sticker";
+ public static final String TGSSTICKER_FIELD = "tgs_sticker";
public static final String EMOJIS_FIELD = "emojis";
public static final String MASKPOSITION_FIELD = "mask_position";
@@ -40,6 +46,11 @@ public class AddStickerToSet extends PartialBotApiMethod {
* to get a file from the Internet, or upload a new one using multipart/form-data.
*/
private InputFile pngSticker;
+ /**
+ * TGS animation with the sticker, uploaded using multipart/form-data.
+ * See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
+ */
+ private InputFile tgsSticker;
public AddStickerToSet() {
super();
@@ -82,6 +93,20 @@ public class AddStickerToSet extends PartialBotApiMethod {
return this;
}
+ public AddStickerToSet setTgsSticker(File tgsSticker) {
+ this.tgsSticker = new InputFile(checkNotNull(tgsSticker), tgsSticker.getName());
+ return this;
+ }
+
+ public AddStickerToSet setTgsSticker(String tgsStickerName, InputStream tgsSticker) {
+ this.tgsSticker = new InputFile(checkNotNull(tgsSticker), checkNotNull(tgsStickerName));
+ return this;
+ }
+
+ public InputFile getTgsSticker() {
+ return tgsSticker;
+ }
+
public String getName() {
return name;
}
@@ -136,11 +161,20 @@ public class AddStickerToSet extends PartialBotApiMethod {
throw new TelegramApiValidationException("emojis can't be empty", this);
}
- if (pngSticker == null) {
- throw new TelegramApiValidationException("PngSticker can't be empty", this);
+ if (pngSticker == null && tgsSticker == null) {
+ throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
}
- pngSticker.validate();
+ if (pngSticker != null && tgsSticker != null) {
+ throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
+ }
+
+ if (pngSticker != null) {
+ pngSticker.validate();
+ }
+ if (tgsSticker != null) {
+ tgsSticker.validate();
+ }
if (maskPosition != null) {
maskPosition.validate();
@@ -155,6 +189,7 @@ public class AddStickerToSet extends PartialBotApiMethod {
", emojis='" + emojis + '\'' +
", maskPosition=" + maskPosition +
", pngSticker=" + pngSticker +
+ ", tgsSticker=" + tgsSticker +
'}';
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java
index eeab6e4a..f42fab7f 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java
@@ -2,8 +2,8 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -18,7 +18,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
- * Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set.
+ * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created.
+ * You must use exactly one of the fields png_sticker or tgs_sticker.
* Returns True on success.
*/
public class CreateNewStickerSet extends PartialBotApiMethod {
@@ -28,6 +29,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
public static final String NAME_FIELD = "name";
public static final String TITLE_FIELD = "title";
public static final String PNGSTICKER_FIELD = "png_sticker";
+ public static final String TGSSTICKER_FIELD = "tgs_sticker";
public static final String EMOJIS_FIELD = "emojis";
public static final String CONTAINSMASKS_FIELD = "contains_masks";
public static final String MASKPOSITION_FIELD = "mask_position";
@@ -53,6 +55,12 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
*/
private InputFile pngSticker;
+ /**
+ * TGS animation with the sticker, uploaded using multipart/form-data.
+ * See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
+ */
+ private InputFile tgsSticker;
+
public CreateNewStickerSet() {
super();
}
@@ -100,6 +108,21 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
return this;
}
+ public CreateNewStickerSet setTgsSticker(InputFile tgsSticker) {
+ this.tgsSticker = checkNotNull(tgsSticker);
+ return this;
+ }
+
+ public CreateNewStickerSet setTgsSticker(File tgsStickerFile) {
+ this.tgsSticker = new InputFile(checkNotNull(tgsStickerFile), tgsStickerFile.getName());;
+ return this;
+ }
+
+ public CreateNewStickerSet setTgsSticker(String tgsStickerName, InputStream tgsStickerStream) {
+ this.pngSticker = new InputFile(checkNotNull(tgsStickerStream), checkNotNull(tgsStickerName));
+ return this;
+ }
+
public String getName() {
return name;
}
@@ -140,6 +163,10 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
this.maskPosition = maskPosition;
}
+ public InputFile getTgsSticker() {
+ return tgsSticker;
+ }
+
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@@ -170,11 +197,20 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
throw new TelegramApiValidationException("emojis can't be empty", this);
}
- if (pngSticker == null) {
- throw new TelegramApiValidationException("PngSticker parameter can't be empty", this);
+ if (pngSticker == null && tgsSticker == null) {
+ throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
}
- pngSticker.validate();
+ if (pngSticker != null && tgsSticker != null) {
+ throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
+ }
+
+ if (pngSticker != null) {
+ pngSticker.validate();
+ }
+ if (tgsSticker != null) {
+ tgsSticker.validate();
+ }
if (maskPosition != null) {
maskPosition.validate();
@@ -191,6 +227,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
", containsMasks=" + containsMasks +
", maskPosition=" + maskPosition +
", pngSticker=" + pngSticker +
+ ", tgsSticker=" + tgsSticker +
'}';
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java
new file mode 100644
index 00000000..5dad0304
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java
@@ -0,0 +1,133 @@
+package org.telegram.telegrambots.meta.api.methods.stickers;
+
+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.api.objects.InputFile;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
+ * Returns True on success.
+ */
+public class SetStickerSetThumb extends BotApiMethod {
+ private static final String PATH = "setStickerSetThumb";
+
+ public static final String NAME_FIELD = "name";
+ public static final String USERID_FIELD = "user_id";
+ public static final String THUMB_FIELD = "thumb";
+
+ private String name; ///< Sticker set name
+ private Integer userId; ///< User identifier of the sticker set owner
+ /**
+ * A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px,
+ * or a TGS animation with the thumbnail up to 32 kilobytes in size;
+ * see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements.
+ * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
+ * String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
+ * Animated sticker set thumbnail can't be uploaded via HTTP URL.
+ */
+ private InputFile thumb;
+
+ public SetStickerSetThumb() {
+ super();
+ }
+
+ public SetStickerSetThumb(String name, Integer userId, InputFile thumb) {
+ this.name = name;
+ this.userId = userId;
+ this.thumb = thumb;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public InputFile getThumb() {
+ return thumb;
+ }
+
+ public SetStickerSetThumb setThumb(String thumb) {
+ this.thumb = new InputFile(thumb);
+ return this;
+ }
+
+ public SetStickerSetThumb setThumb(InputFile thumb) {
+ this.thumb = thumb;
+ return this;
+ }
+
+ public SetStickerSetThumb setThumb(File thumbFile) {
+ this.thumb = new InputFile(checkNotNull(thumbFile), thumbFile.getName());;
+ return this;
+ }
+
+ public SetStickerSetThumb setThumb(String thumbName, InputStream thumbStream) {
+ this.thumb = new InputFile(checkNotNull(thumbStream), checkNotNull(thumbName));
+ 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 sticker thumb in set", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (name == null || name.isEmpty()) {
+ throw new TelegramApiValidationException("name can't be null", this);
+ }
+ if (userId == null || userId == 0) {
+ throw new TelegramApiValidationException("userId can't be null", this);
+ }
+ if (thumb == null) {
+ throw new TelegramApiValidationException("thumb can't be null", this);
+ }
+ thumb.validate();
+ }
+
+ @Override
+ public String toString() {
+ return "SetStickerSetThumb{" +
+ "name='" + name + '\'' +
+ ", userId=" + userId +
+ ", thumb=" + thumb +
+ '}';
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java
new file mode 100644
index 00000000..4efed1a5
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java
@@ -0,0 +1,32 @@
+package org.telegram.telegrambots.meta.api.objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+
+/**
+ * @author Ruben Bermudez
+ * @version 4.7
+ * This object represents a dice with random value from 1 to 6.
+ * (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
+ */
+public class Dice implements BotApiObject {
+ private static final String VALUE_FIELD = "value";
+
+ @JsonProperty(VALUE_FIELD)
+ private Integer value; ///< Value of the dice, 1-6
+
+ public Dice() {
+ super();
+ }
+
+ public Integer getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return "Dice{" +
+ "value=" + value +
+ '}';
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
index b5d010b7..551922ab 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
@@ -67,6 +67,7 @@ public class Message implements BotApiObject {
private static final String FORWARDSENDERNAME_FIELD = "forward_sender_name";
private static final String POLL_FIELD = "poll";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
+ private static final String DICE_FIELD = "dice";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@@ -207,6 +208,8 @@ public class Message implements BotApiObject {
*/
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup;
+ @JsonProperty(DICE_FIELD)
+ private Dice dice; // Optional. Message is a dice with random value from 1 to 6
public Message() {
super();
@@ -510,6 +513,14 @@ public class Message implements BotApiObject {
return poll;
}
+ public Dice getDice() {
+ return dice;
+ }
+
+ public boolean hasDice() {
+ return dice != null;
+ }
+
public boolean hasReplyMarkup() {
return replyMarkup != null;
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java
new file mode 100644
index 00000000..63fb2419
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java
@@ -0,0 +1,71 @@
+package org.telegram.telegrambots.meta.api.objects.commands;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Ruben Bermudez
+ * @version 4.7
+ * This object represents a bot command.
+ */
+public class BotCommand implements BotApiObject, Validable {
+ private static final String COMMAND_FIELD = "command";
+ private static final String DESCRIPTION_FIELD = "description";
+
+ /**
+ * Text of the command. Can contain only lowercase English letters, digits and underscores. 1-32 characters.
+ */
+ @JsonProperty(COMMAND_FIELD)
+ private String command; ///< Value of the dice, 1-6
+ @JsonProperty(DESCRIPTION_FIELD)
+ private String description; ///< Description of the command, 3-256 characters.
+
+ public BotCommand() {
+ super();
+ }
+
+ public BotCommand(String command, String description) {
+ this.command = checkNotNull(command);
+ this.description = checkNotNull(description);
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public BotCommand setCommand(String command) {
+ this.command = command;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public BotCommand setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (command == null || command.isEmpty()) {
+ throw new TelegramApiValidationException("Command parameter can't be empty", this);
+ }
+ if (description == null || description.isEmpty()) {
+ throw new TelegramApiValidationException("Description parameter can't be empty", this);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "BotCommand{" +
+ "command='" + command + '\'' +
+ ", description='" + description + '\'' +
+ '}';
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java
index 8ea7c1ec..15093821 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java
@@ -9,7 +9,7 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
- * @version 4.6
+ * @version 4.7
*
* This object represents an answer of a user in a non-anonymous poll.
*/
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonPollType.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonPollType.java
index 539fb56c..5135e23e 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonPollType.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonPollType.java
@@ -9,7 +9,7 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
- * @version 4.6
+ * @version 4.7
*
* This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
*/
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java
index ba053d29..e9b34571 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java
@@ -2,6 +2,7 @@ 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;
import java.util.List;
@@ -16,6 +17,7 @@ public class StickerSet implements BotApiObject {
private static final String CONTAINSMASKS_FIELD = "contains_masks";
private static final String STICKERS_FIELD = "stickers";
private static final String ISANIMATED_FIELD = "is_animated";
+ private static final String THUMB_FIELD = "thumb";
@JsonProperty(NAME_FIELD)
private String name;
@@ -27,6 +29,8 @@ public class StickerSet implements BotApiObject {
private List stickers;
@JsonProperty(ISANIMATED_FIELD)
private Boolean isAnimated;
+ @JsonProperty(THUMB_FIELD)
+ private PhotoSize thumb; ///< Optional. Sticker set thumbnail in the .WEBP or .TGS format
public StickerSet() {
super();
@@ -52,6 +56,10 @@ public class StickerSet implements BotApiObject {
return isAnimated;
}
+ public PhotoSize getThumb() {
+ return thumb;
+ }
+
@Override
public String toString() {
return "StickerSet{" +
@@ -60,6 +68,7 @@ public class StickerSet implements BotApiObject {
", containsMasks=" + containsMasks +
", stickers=" + stickers +
", isAnimated=" + isAnimated +
+ ", thumb=" + thumb +
'}';
}
}
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 b83122a4..dd41bd94 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
@@ -3,9 +3,18 @@ package org.telegram.telegrambots.meta.bots;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.GetMe;
import org.telegram.telegrambots.meta.api.methods.groupadministration.SetChatPhoto;
-import org.telegram.telegrambots.meta.api.methods.send.*;
+import org.telegram.telegrambots.meta.api.methods.send.SendAnimation;
+import org.telegram.telegrambots.meta.api.methods.send.SendAudio;
+import org.telegram.telegrambots.meta.api.methods.send.SendDocument;
+import org.telegram.telegrambots.meta.api.methods.send.SendMediaGroup;
+import org.telegram.telegrambots.meta.api.methods.send.SendPhoto;
+import org.telegram.telegrambots.meta.api.methods.send.SendSticker;
+import org.telegram.telegrambots.meta.api.methods.send.SendVideo;
+import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote;
+import org.telegram.telegrambots.meta.api.methods.send.SendVoice;
import org.telegram.telegrambots.meta.api.methods.stickers.AddStickerToSet;
import org.telegram.telegrambots.meta.api.methods.stickers.CreateNewStickerSet;
+import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumb;
import org.telegram.telegrambots.meta.api.methods.stickers.UploadStickerFile;
import org.telegram.telegrambots.meta.api.methods.updates.GetWebhookInfo;
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageMedia;
@@ -126,6 +135,14 @@ public abstract class AbsSender {
*/
public abstract Boolean execute(AddStickerToSet addStickerToSet) throws TelegramApiException;
+ /**
+ * Set sticker set thumb (https://core.telegram.org/bots/api#setStickerSetThumb)
+ * @param setStickerSetThumb Information of the sticker to set
+ * @return If success, true is returned
+ * @throws TelegramApiException If there is any error setting the thumb to the set
+ */
+ public abstract Boolean execute(SetStickerSetThumb setStickerSetThumb) throws TelegramApiException;
+
/**
* Creates a new sticker set (https://core.telegram.org/bots/api#createNewStickerSet)
* @param createNewStickerSet Information of the sticker set to create
diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml
index 083abae9..46c70b31 100644
--- a/telegrambots-spring-boot-starter/pom.xml
+++ b/telegrambots-spring-boot-starter/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambots-spring-boot-starter
@@ -78,7 +78,7 @@
org.telegram
telegrambots
- 4.6
+ 4.7
org.springframework.boot
diff --git a/telegrambots/LICENSE b/telegrambots/LICENSE
new file mode 100644
index 00000000..16d9ac5f
--- /dev/null
+++ b/telegrambots/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Ruben Bermudez
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml
index a8c418e7..045612a3 100644
--- a/telegrambots/pom.xml
+++ b/telegrambots/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.6
+ 4.7
telegrambots
@@ -95,7 +95,7 @@
org.telegram
telegrambots-meta
- 4.6
+ 4.7
com.fasterxml.jackson.core
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 f6c522d3..aab32d63 100644
--- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java
+++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java
@@ -26,6 +26,7 @@ import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote;
import org.telegram.telegrambots.meta.api.methods.send.SendVoice;
import org.telegram.telegrambots.meta.api.methods.stickers.AddStickerToSet;
import org.telegram.telegrambots.meta.api.methods.stickers.CreateNewStickerSet;
+import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumb;
import org.telegram.telegrambots.meta.api.methods.stickers.UploadStickerFile;
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageMedia;
import org.telegram.telegrambots.meta.api.objects.File;
@@ -548,7 +549,11 @@ public abstract class DefaultAbsSender extends AbsSender {
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);
- addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
+ if (addStickerToSet.getPngSticker() != null) {
+ addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
+ } else {
+ addInputFile(builder, addStickerToSet.getTgsSticker(), AddStickerToSet.TGSSTICKER_FIELD, true);
+ }
if (addStickerToSet.getMaskPosition() != null) {
builder.addTextBody(AddStickerToSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(addStickerToSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE);
@@ -562,6 +567,28 @@ public abstract class DefaultAbsSender extends AbsSender {
}
}
+ @Override
+ public Boolean execute(SetStickerSetThumb setStickerSetThumb) throws TelegramApiException {
+ assertParamNotNull(setStickerSetThumb, "setStickerSetThumb");
+ setStickerSetThumb.validate();
+ try {
+ String url = getBaseUrl() + AddStickerToSet.PATH;
+ HttpPost httppost = configuredHttpPost(url);
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.setLaxMode();
+ builder.setCharset(StandardCharsets.UTF_8);
+ builder.addTextBody(SetStickerSetThumb.USERID_FIELD, setStickerSetThumb.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
+ builder.addTextBody(SetStickerSetThumb.NAME_FIELD, setStickerSetThumb.getName(), TEXT_PLAIN_CONTENT_TYPE);
+ addInputFile(builder, setStickerSetThumb.getThumb(), SetStickerSetThumb.THUMB_FIELD, true);
+ HttpEntity multipart = builder.build();
+ httppost.setEntity(multipart);
+
+ return setStickerSetThumb.deserializeResponse(sendHttpPostRequest(httppost));
+ } catch (IOException e) {
+ throw new TelegramApiException("Unable to add sticker to set", e);
+ }
+ }
+
@Override
public Boolean execute(CreateNewStickerSet createNewStickerSet) throws TelegramApiException {
assertParamNotNull(createNewStickerSet, "createNewStickerSet");
@@ -577,7 +604,11 @@ public abstract class DefaultAbsSender extends AbsSender {
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(), TEXT_PLAIN_CONTENT_TYPE);
- addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
+ if (createNewStickerSet.getPngSticker() != null) {
+ addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
+ } else {
+ addInputFile(builder, createNewStickerSet.getTgsSticker(), CreateNewStickerSet.TGSSTICKER_FIELD, true);
+ }
if (createNewStickerSet.getMaskPosition() != null) {
builder.addTextBody(CreateNewStickerSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(createNewStickerSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE);