Api Version 5.7
This commit is contained in:
parent
6da32da4f8
commit
6bb17461f0
@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots:5.6.0'
|
implementation 'org.telegram:telegrambots:5.7.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.6.0)
|
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.7.1)
|
||||||
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.6.0)
|
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.7.1)
|
||||||
|
|
||||||
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
### <a id="5.7.1"></a>5.7.1 ###
|
||||||
|
1. Update Api version [5.7](https://core.telegram.org/bots/api-changelog#january-31-2022)
|
||||||
|
2. Bug Fixing: #1023
|
||||||
|
|
||||||
### <a id="5.6.0"></a>5.6.0 ###
|
### <a id="5.6.0"></a>5.6.0 ###
|
||||||
1. Update Api version [5.6](https://core.telegram.org/bots/api-changelog#december-30-2021)
|
1. Update Api version [5.6](https://core.telegram.org/bots/api-changelog#december-30-2021)
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* With **Gradle**:
|
* With **Gradle**:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots:5.6.0'
|
implementation 'org.telegram:telegrambots:5.7.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
||||||
|
@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* **Gradle**
|
* **Gradle**
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-abilities:5.6.0'
|
implementation 'org.telegram:telegrambots-abilities:5.7.1'
|
||||||
```
|
```
|
||||||
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>telegrambots</module>
|
<module>telegrambots</module>
|
||||||
|
@ -18,14 +18,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-abilities:5.6.0'
|
implementation 'org.telegram:telegrambots-abilities:5.7.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
@ -15,14 +15,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-chat-session-bot:5.6.0'
|
implementation 'org.telegram:telegrambots-chat-session-bot:5.7.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
||||||
|
@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambotsextensions:5.6.0'
|
implementation 'org.telegram:telegrambotsextensions:5.7.1'
|
||||||
```
|
```
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
|
@ -23,7 +23,8 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* Use this method to send .webp stickers. On success, the sent Message is returned.
|
* Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers.
|
||||||
|
* On success, the sent Message is returned.
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Getter
|
@Getter
|
||||||
@ -83,14 +84,10 @@ public class SendSticker extends PartialBotApiMethod<Message> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (chatId == null || chatId.isEmpty()) {
|
if (chatId.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sticker == null) {
|
|
||||||
throw new TelegramApiValidationException("Sticker parameter can't be empty", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
sticker.validate();
|
sticker.validate();
|
||||||
|
|
||||||
if (replyMarkup != null) {
|
if (replyMarkup != null) {
|
||||||
|
@ -22,11 +22,9 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* Use this method to add a new sticker to a set created by the bot.
|
* Use this method to create a new sticker set owned by a user.
|
||||||
* You must use exactly one of the fields png_sticker or tgs_sticker.
|
* The bot will be able to edit the sticker set thus created.
|
||||||
* Animated stickers can be added to animated sticker sets and only to them.
|
* You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker.
|
||||||
* Animated sticker sets can have up to 50 stickers.
|
|
||||||
* Static sticker sets can have up to 120 stickers.
|
|
||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -44,6 +42,7 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
|||||||
public static final String NAME_FIELD = "name";
|
public static final String NAME_FIELD = "name";
|
||||||
public static final String PNGSTICKER_FIELD = "png_sticker";
|
public static final String PNGSTICKER_FIELD = "png_sticker";
|
||||||
public static final String TGSSTICKER_FIELD = "tgs_sticker";
|
public static final String TGSSTICKER_FIELD = "tgs_sticker";
|
||||||
|
public static final String WEBMSTICKER_FIELD = "webm_sticker";
|
||||||
public static final String EMOJIS_FIELD = "emojis";
|
public static final String EMOJIS_FIELD = "emojis";
|
||||||
public static final String MASKPOSITION_FIELD = "mask_position";
|
public static final String MASKPOSITION_FIELD = "mask_position";
|
||||||
|
|
||||||
@ -69,6 +68,13 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
|||||||
*/
|
*/
|
||||||
private InputFile tgsSticker;
|
private InputFile tgsSticker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional.
|
||||||
|
* WEBM video with the sticker, uploaded using multipart/form-data.
|
||||||
|
* See https://core.telegram.org/stickers#video-stickers for technical requirements
|
||||||
|
*/
|
||||||
|
private InputFile webmSticker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -86,31 +92,37 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (userId == null || userId <= 0) {
|
if (userId <= 0) {
|
||||||
throw new TelegramApiValidationException("userId can't be empty", this);
|
throw new TelegramApiValidationException("userId can't be empty", this);
|
||||||
}
|
}
|
||||||
if (name == null || name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("name can't be empty", this);
|
throw new TelegramApiValidationException("name can't be empty", this);
|
||||||
}
|
}
|
||||||
if (emojis == null || emojis.isEmpty()) {
|
if (emojis.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("emojis can't be empty", this);
|
throw new TelegramApiValidationException("emojis can't be empty", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker == null && tgsSticker == null) {
|
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
|
||||||
throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
|
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker != null && tgsSticker != null) {
|
if ((pngSticker != null && tgsSticker != null) || (pngSticker != null && webmSticker != null) ||
|
||||||
throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
|
(tgsSticker != null && webmSticker != null)) {
|
||||||
|
throw new TelegramApiValidationException("Only one of pngSticker, tgsSticker or webmSticker are allowed", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker != null) {
|
if (pngSticker != null) {
|
||||||
pngSticker.validate();
|
pngSticker.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tgsSticker != null) {
|
if (tgsSticker != null) {
|
||||||
tgsSticker.validate();
|
tgsSticker.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (webmSticker != null) {
|
||||||
|
webmSticker.validate();
|
||||||
|
}
|
||||||
|
|
||||||
if (maskPosition != null) {
|
if (maskPosition != null) {
|
||||||
maskPosition.validate();
|
maskPosition.validate();
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,9 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* 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.
|
* Use this method to create a new sticker set owned by a user.
|
||||||
* You must use exactly one of the fields png_sticker or tgs_sticker.
|
* The bot will be able to edit the sticker set thus created.
|
||||||
|
* You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker.
|
||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -42,6 +43,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
|||||||
public static final String TITLE_FIELD = "title";
|
public static final String TITLE_FIELD = "title";
|
||||||
public static final String PNGSTICKER_FIELD = "png_sticker";
|
public static final String PNGSTICKER_FIELD = "png_sticker";
|
||||||
public static final String TGSSTICKER_FIELD = "tgs_sticker";
|
public static final String TGSSTICKER_FIELD = "tgs_sticker";
|
||||||
|
public static final String WEBMSTICKER_FIELD = "webm_sticker";
|
||||||
public static final String EMOJIS_FIELD = "emojis";
|
public static final String EMOJIS_FIELD = "emojis";
|
||||||
public static final String CONTAINSMASKS_FIELD = "contains_masks";
|
public static final String CONTAINSMASKS_FIELD = "contains_masks";
|
||||||
public static final String MASKPOSITION_FIELD = "mask_position";
|
public static final String MASKPOSITION_FIELD = "mask_position";
|
||||||
@ -73,12 +75,19 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
|||||||
private InputFile pngSticker;
|
private InputFile pngSticker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Optional
|
* Optional
|
||||||
* TGS animation with the sticker, uploaded using multipart/form-data.
|
* TGS animation with the sticker, uploaded using multipart/form-data.
|
||||||
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||||
*/
|
*/
|
||||||
private InputFile tgsSticker;
|
private InputFile tgsSticker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional
|
||||||
|
* WEBM video with the sticker, uploaded using multipart/form-data.
|
||||||
|
* See https://core.telegram.org/stickers#video-stickers for technical requirements
|
||||||
|
*/
|
||||||
|
private InputFile webmSticker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -96,34 +105,40 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (userId == null || userId <= 0) {
|
if (userId <= 0) {
|
||||||
throw new TelegramApiValidationException("userId can't be empty", this);
|
throw new TelegramApiValidationException("userId can't be empty", this);
|
||||||
}
|
}
|
||||||
if (name == null || name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("name can't be empty", this);
|
throw new TelegramApiValidationException("name can't be empty", this);
|
||||||
}
|
}
|
||||||
if (title == null || title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("title can't be empty", this);
|
throw new TelegramApiValidationException("title can't be empty", this);
|
||||||
}
|
}
|
||||||
if (emojis == null || emojis.isEmpty()) {
|
if (emojis.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("emojis can't be empty", this);
|
throw new TelegramApiValidationException("emojis can't be empty", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker == null && tgsSticker == null) {
|
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
|
||||||
throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
|
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker != null && tgsSticker != null) {
|
if ((pngSticker != null && tgsSticker != null) || (pngSticker != null && webmSticker != null)
|
||||||
throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
|
|| (tgsSticker != null && webmSticker != null)) {
|
||||||
|
throw new TelegramApiValidationException("Only one of pngSticker, tgsSticker or webmSticker are allowed", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pngSticker != null) {
|
if (pngSticker != null) {
|
||||||
pngSticker.validate();
|
pngSticker.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tgsSticker != null) {
|
if (tgsSticker != null) {
|
||||||
tgsSticker.validate();
|
tgsSticker.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (webmSticker != null) {
|
||||||
|
webmSticker.validate();
|
||||||
|
}
|
||||||
|
|
||||||
if (maskPosition != null) {
|
if (maskPosition != null) {
|
||||||
maskPosition.validate();
|
maskPosition.validate();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
|
* Use this method to set the thumbnail of a sticker set.
|
||||||
|
* Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only.
|
||||||
* Returns True on success.
|
* Returns True on success.
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -42,14 +43,17 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private Long userId; ///< User identifier of the sticker set owner
|
private Long userId; ///< User identifier of the sticker set owner
|
||||||
/**
|
/**
|
||||||
|
* Optional.
|
||||||
* A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px,
|
* 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;
|
* 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.
|
* see https://core.telegram.org/stickers#animated-sticker-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
|
* or a WEBM video with the thumbnail up to 32 kilobytes in size;
|
||||||
* String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
|
* see https://core.telegram.org/stickers#video-sticker-requirements for video 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. More info on Sending Files ».
|
||||||
* Animated sticker set thumbnail can't be uploaded via HTTP URL.
|
* Animated sticker set thumbnail can't be uploaded via HTTP URL.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
|
||||||
private InputFile thumb;
|
private InputFile thumb;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,15 +78,14 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (name == null || name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("name can't be null", this);
|
throw new TelegramApiValidationException("name can't be null", this);
|
||||||
}
|
}
|
||||||
if (userId == null || userId == 0) {
|
if (userId <= 0) {
|
||||||
throw new TelegramApiValidationException("userId can't be null", this);
|
throw new TelegramApiValidationException("userId can't be null", this);
|
||||||
}
|
}
|
||||||
if (thumb == null) {
|
if (thumb != null) {
|
||||||
throw new TelegramApiValidationException("thumb can't be null", this);
|
|
||||||
}
|
|
||||||
thumb.validate();
|
thumb.validate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ public class Sticker implements BotApiObject {
|
|||||||
private static final String SETNAME_FIELD = "set_name";
|
private static final String SETNAME_FIELD = "set_name";
|
||||||
private static final String MASKPOSITON_FIELD = "mask_position";
|
private static final String MASKPOSITON_FIELD = "mask_position";
|
||||||
private static final String ISANIMATED_FIELD = "is_animated";
|
private static final String ISANIMATED_FIELD = "is_animated";
|
||||||
|
private static final String ISVIDEO_FIELD = "is_video";
|
||||||
|
|
||||||
@JsonProperty(FILEID_FIELD)
|
@JsonProperty(FILEID_FIELD)
|
||||||
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
|
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
|
||||||
@ -58,4 +59,6 @@ public class Sticker implements BotApiObject {
|
|||||||
private MaskPosition maskPosition; ///< Optional. For mask stickers, the position where the mask should be placed
|
private MaskPosition maskPosition; ///< Optional. For mask stickers, the position where the mask should be placed
|
||||||
@JsonProperty(ISANIMATED_FIELD)
|
@JsonProperty(ISANIMATED_FIELD)
|
||||||
private Boolean isAnimated; ///< True, if the sticker is animated
|
private Boolean isAnimated; ///< True, if the sticker is animated
|
||||||
|
@JsonProperty(ISVIDEO_FIELD)
|
||||||
|
private Boolean isVideo; ///< True, if the sticker is a video sticker
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public class StickerSet implements BotApiObject {
|
|||||||
private static final String CONTAINSMASKS_FIELD = "contains_masks";
|
private static final String CONTAINSMASKS_FIELD = "contains_masks";
|
||||||
private static final String STICKERS_FIELD = "stickers";
|
private static final String STICKERS_FIELD = "stickers";
|
||||||
private static final String ISANIMATED_FIELD = "is_animated";
|
private static final String ISANIMATED_FIELD = "is_animated";
|
||||||
|
private static final String ISVIDEO_FIELD = "is_video";
|
||||||
private static final String THUMB_FIELD = "thumb";
|
private static final String THUMB_FIELD = "thumb";
|
||||||
|
|
||||||
@JsonProperty(NAME_FIELD)
|
@JsonProperty(NAME_FIELD)
|
||||||
@ -41,6 +42,8 @@ public class StickerSet implements BotApiObject {
|
|||||||
private List<Sticker> stickers; ///< True, if the sticker set contains masks
|
private List<Sticker> stickers; ///< True, if the sticker set contains masks
|
||||||
@JsonProperty(ISANIMATED_FIELD)
|
@JsonProperty(ISANIMATED_FIELD)
|
||||||
private Boolean isAnimated; ///< List of all set stickers
|
private Boolean isAnimated; ///< List of all set stickers
|
||||||
|
@JsonProperty(ISVIDEO_FIELD)
|
||||||
|
private Boolean isVideo; ///< True, if the sticker set contains video stickers
|
||||||
@JsonProperty(THUMB_FIELD)
|
@JsonProperty(THUMB_FIELD)
|
||||||
private PhotoSize thumb; ///< Optional. Sticker set thumbnail in the .WEBP or .TGS format
|
private PhotoSize thumb; ///< Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-spring-boot-starter:5.6.0'
|
implementation 'org.telegram:telegrambots-spring-boot-starter:5.7.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<telegrambots.version>5.6.0</telegrambots.version>
|
<telegrambots.version>5.7.1</telegrambots.version>
|
||||||
<spring-boot.version>2.5.8</spring-boot.version>
|
<spring-boot.version>2.5.8</spring-boot.version>
|
||||||
|
|
||||||
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
<version>5.6.0</version>
|
<version>5.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@ -110,6 +110,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.module</groupId>
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
<artifactId>jackson-module-jaxb-annotations</artifactId>
|
<artifactId>jackson-module-jaxb-annotations</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>jakarta.activation</groupId>
|
||||||
|
<artifactId>jakarta.activation-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
@ -613,8 +613,10 @@ public abstract class DefaultAbsSender extends AbsSender {
|
|||||||
builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
if (addStickerToSet.getPngSticker() != null) {
|
if (addStickerToSet.getPngSticker() != null) {
|
||||||
addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
|
addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
|
||||||
} else {
|
} else if (addStickerToSet.getTgsSticker() != null) {
|
||||||
addInputFile(builder, addStickerToSet.getTgsSticker(), AddStickerToSet.TGSSTICKER_FIELD, true);
|
addInputFile(builder, addStickerToSet.getTgsSticker(), AddStickerToSet.TGSSTICKER_FIELD, true);
|
||||||
|
} else {
|
||||||
|
addInputFile(builder, addStickerToSet.getWebmSticker(), AddStickerToSet.WEBMSTICKER_FIELD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addStickerToSet.getMaskPosition() != null) {
|
if (addStickerToSet.getMaskPosition() != null) {
|
||||||
@ -641,7 +643,9 @@ public abstract class DefaultAbsSender extends AbsSender {
|
|||||||
builder.setCharset(StandardCharsets.UTF_8);
|
builder.setCharset(StandardCharsets.UTF_8);
|
||||||
builder.addTextBody(SetStickerSetThumb.USERID_FIELD, setStickerSetThumb.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SetStickerSetThumb.USERID_FIELD, setStickerSetThumb.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
builder.addTextBody(SetStickerSetThumb.NAME_FIELD, setStickerSetThumb.getName(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(SetStickerSetThumb.NAME_FIELD, setStickerSetThumb.getName(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
|
if (setStickerSetThumb.getThumb() != null) {
|
||||||
addInputFile(builder, setStickerSetThumb.getThumb(), SetStickerSetThumb.THUMB_FIELD, true);
|
addInputFile(builder, setStickerSetThumb.getThumb(), SetStickerSetThumb.THUMB_FIELD, true);
|
||||||
|
}
|
||||||
HttpEntity multipart = builder.build();
|
HttpEntity multipart = builder.build();
|
||||||
httppost.setEntity(multipart);
|
httppost.setEntity(multipart);
|
||||||
|
|
||||||
@ -668,8 +672,10 @@ public abstract class DefaultAbsSender extends AbsSender {
|
|||||||
builder.addTextBody(CreateNewStickerSet.CONTAINSMASKS_FIELD, createNewStickerSet.getContainsMasks().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
builder.addTextBody(CreateNewStickerSet.CONTAINSMASKS_FIELD, createNewStickerSet.getContainsMasks().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
||||||
if (createNewStickerSet.getPngSticker() != null) {
|
if (createNewStickerSet.getPngSticker() != null) {
|
||||||
addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
|
addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
|
||||||
} else {
|
} else if (createNewStickerSet.getTgsSticker() != null) {
|
||||||
addInputFile(builder, createNewStickerSet.getTgsSticker(), CreateNewStickerSet.TGSSTICKER_FIELD, true);
|
addInputFile(builder, createNewStickerSet.getTgsSticker(), CreateNewStickerSet.TGSSTICKER_FIELD, true);
|
||||||
|
} else {
|
||||||
|
addInputFile(builder, createNewStickerSet.getWebmSticker(), CreateNewStickerSet.WEBMSTICKER_FIELD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createNewStickerSet.getMaskPosition() != null) {
|
if (createNewStickerSet.getMaskPosition() != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user