Merge tag 'v5.7.1'

This commit is contained in:
Andrea Cavalli 2022-02-09 21:06:10 +01:00
commit 359d1db9af
23 changed files with 130 additions and 80 deletions

View File

@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
2. Using 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)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/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.7.1)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -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 ###
1. Update Api version [5.6](https://core.telegram.org/bots/api-changelog#december-30-2021)

View File

@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
* With **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).

View File

@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
* **Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:5.6.0'
implementation 'org.telegram:telegrambots-abilities:5.7.1'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

14
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>5.6.0</version>
<version>5.7.1</version>
<modules>
<module>telegrambots</module>
@ -69,13 +69,13 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit.version>5.7.1</junit.version>
<junit.version>5.7.2</junit.version>
<mockito.version>3.6.0</mockito.version>
<mockitojupiter.version>3.6.0</mockitojupiter.version>
<jacksonanotation.version>2.11.3</jacksonanotation.version>
<jackson.version>2.11.3</jackson.version>
<jacksonanotation.version>2.13.0</jacksonanotation.version>
<jackson.version>2.13.0</jackson.version>
<json.version>20180813</json.version>
<slf4j.version>1.7.30</slf4j.version>
<slf4j.version>1.7.32</slf4j.version>
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
<lombok.version>1.18.22</lombok.version>
<guava.version>30.0-jre</guava.version>
@ -233,10 +233,10 @@
</executions>
<configuration>
<rules>
<DependencyConvergence />
<DependencyConvergence/>
</rules>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
**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)

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambots-abilities</artifactId>
@ -86,7 +86,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@ -15,14 +15,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-chat-session-bot:5.6.0'
implementation 'org.telegram:telegrambots-chat-session-bot:5.7.1'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambots-chat-session-bot</artifactId>
@ -86,7 +86,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->

View File

@ -27,6 +27,7 @@ public abstract class TelegramLongPollingSessionBot extends TelegramLongPollingB
}
public TelegramLongPollingSessionBot(ChatIdConverter chatIdConverter, DefaultBotOptions defaultBotOptions){
super(defaultBotOptions);
this.setSessionManager(new DefaultSessionManager());
this.setChatIdConverter(chatIdConverter);
AbstractSessionDAO sessionDAO = (AbstractSessionDAO) sessionManager.getSessionDAO();

View File

@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambotsextensions:5.6.0'
implementation 'org.telegram:telegrambotsextensions:5.7.1'
```

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambotsextensions</artifactId>
@ -77,7 +77,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
</dependencies>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambots-meta</artifactId>

View File

@ -23,7 +23,8 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
* @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)
@Getter
@ -83,14 +84,10 @@ public class SendSticker extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
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();
if (replyMarkup != null) {

View File

@ -22,11 +22,9 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* 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.
* 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, tgs_sticker, or webm_sticker.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@ -44,6 +42,7 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
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 WEBMSTICKER_FIELD = "webm_sticker";
public static final String EMOJIS_FIELD = "emojis";
public static final String MASKPOSITION_FIELD = "mask_position";
@ -69,6 +68,13 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
*/
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
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -86,31 +92,37 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (userId == null || userId <= 0) {
if (userId <= 0) {
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);
}
if (emojis == null || emojis.isEmpty()) {
if (emojis.isEmpty()) {
throw new TelegramApiValidationException("emojis can't be empty", this);
}
if (pngSticker == null && tgsSticker == null) {
throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
}
if (pngSticker != null && tgsSticker != null) {
throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
if ((pngSticker != null && tgsSticker != null) || (pngSticker != null && webmSticker != null) ||
(tgsSticker != null && webmSticker != null)) {
throw new TelegramApiValidationException("Only one of pngSticker, tgsSticker or webmSticker are allowed", this);
}
if (pngSticker != null) {
pngSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (maskPosition != null) {
maskPosition.validate();
}

View File

@ -22,8 +22,9 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
* @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.
* You must use exactly one of the fields png_sticker or tgs_sticker.
* 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, tgs_sticker, or webm_sticker.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@ -42,6 +43,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
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 WEBMSTICKER_FIELD = "webm_sticker";
public static final String EMOJIS_FIELD = "emojis";
public static final String CONTAINSMASKS_FIELD = "contains_masks";
public static final String MASKPOSITION_FIELD = "mask_position";
@ -73,12 +75,19 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
private InputFile pngSticker;
/**
* @Optional
* Optional
* 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;
/**
* 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
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -96,34 +105,40 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (userId == null || userId <= 0) {
if (userId <= 0) {
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);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
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);
}
if (pngSticker == null && tgsSticker == null) {
throw new TelegramApiValidationException("One of pngSticker or tgsSticker is needed", this);
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
}
if (pngSticker != null && tgsSticker != null) {
throw new TelegramApiValidationException("Only one of pngSticker or tgsSticker are allowed", this);
if ((pngSticker != null && tgsSticker != null) || (pngSticker != null && webmSticker != null)
|| (tgsSticker != null && webmSticker != null)) {
throw new TelegramApiValidationException("Only one of pngSticker, tgsSticker or webmSticker are allowed", this);
}
if (pngSticker != null) {
pngSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (maskPosition != null) {
maskPosition.validate();
}

View File

@ -20,7 +20,8 @@ import java.io.IOException;
/**
* @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.
* 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.
*/
@EqualsAndHashCode(callSuper = false)
@ -42,14 +43,17 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
@NonNull
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,
* 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.
* see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements,
* or a WEBM video with the thumbnail up to 32 kilobytes in size;
* 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.
*/
@NonNull
private InputFile thumb;
@Override
@ -74,15 +78,14 @@ public class SetStickerSetThumb extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (name == null || name.isEmpty()) {
if (name.isEmpty()) {
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);
}
if (thumb == null) {
throw new TelegramApiValidationException("thumb can't be null", this);
if (thumb != null) {
thumb.validate();
}
thumb.validate();
}
}

View File

@ -33,6 +33,7 @@ public class Sticker implements BotApiObject {
private static final String SETNAME_FIELD = "set_name";
private static final String MASKPOSITON_FIELD = "mask_position";
private static final String ISANIMATED_FIELD = "is_animated";
private static final String ISVIDEO_FIELD = "is_video";
@JsonProperty(FILEID_FIELD)
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
@JsonProperty(ISANIMATED_FIELD)
private Boolean isAnimated; ///< True, if the sticker is animated
@JsonProperty(ISVIDEO_FIELD)
private Boolean isVideo; ///< True, if the sticker is a video sticker
}

View File

@ -29,6 +29,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 ISVIDEO_FIELD = "is_video";
private static final String THUMB_FIELD = "thumb";
@JsonProperty(NAME_FIELD)
@ -41,6 +42,8 @@ public class StickerSet implements BotApiObject {
private List<Sticker> stickers; ///< True, if the sticker set contains masks
@JsonProperty(ISANIMATED_FIELD)
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)
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
}

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-spring-boot-starter</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-spring-boot-starter:5.6.0'
implementation 'org.telegram:telegrambots-spring-boot-starter:5.7.1'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambots-spring-boot-starter</artifactId>
@ -72,8 +72,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<telegrambots.version>5.6.0</telegrambots.version>
<spring-boot.version>2.4.5</spring-boot.version>
<telegrambots.version>5.7.1</telegrambots.version>
<spring-boot.version>2.5.8</spring-boot.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</parent>
<artifactId>telegrambots</artifactId>
@ -75,7 +75,7 @@
<glassfish.version>2.32</glassfish.version>
<jerseybundle.version>1.19.3</jerseybundle.version>
<httpcompontents.version>4.5.13</httpcompontents.version>
<commonio.version>2.8.0</commonio.version>
<commonio.version>2.11.0</commonio.version>
</properties>
<dependencyManagement>
@ -94,7 +94,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@ -112,6 +112,12 @@
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@ -298,7 +304,7 @@
</executions>
<configuration>
<rules>
<DependencyConvergence />
<DependencyConvergence/>
</rules>
</configuration>
</plugin>

View File

@ -613,8 +613,10 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
if (addStickerToSet.getPngSticker() != null) {
addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
} else {
} else if (addStickerToSet.getTgsSticker() != null) {
addInputFile(builder, addStickerToSet.getTgsSticker(), AddStickerToSet.TGSSTICKER_FIELD, true);
} else {
addInputFile(builder, addStickerToSet.getWebmSticker(), AddStickerToSet.WEBMSTICKER_FIELD, true);
}
if (addStickerToSet.getMaskPosition() != null) {
@ -641,7 +643,9 @@ public abstract class DefaultAbsSender extends AbsSender {
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);
if (setStickerSetThumb.getThumb() != null) {
addInputFile(builder, setStickerSetThumb.getThumb(), SetStickerSetThumb.THUMB_FIELD, true);
}
HttpEntity multipart = builder.build();
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);
if (createNewStickerSet.getPngSticker() != null) {
addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
} else {
} else if (createNewStickerSet.getTgsSticker() != null) {
addInputFile(builder, createNewStickerSet.getTgsSticker(), CreateNewStickerSet.TGSSTICKER_FIELD, true);
} else {
addInputFile(builder, createNewStickerSet.getWebmSticker(), CreateNewStickerSet.WEBMSTICKER_FIELD, true);
}
if (createNewStickerSet.getMaskPosition() != null) {