Skip to content

Commit

Permalink
Api Version 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Feb 1, 2022
1 parent 6da32da commit 6bb1746
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 71 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
4 changes: 4 additions & 0 deletions TelegramBots.wiki/Changelog.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 2 additions & 2 deletions TelegramBots.wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions TelegramBots.wiki/abilities/Simple-Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-abilities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-abilities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -84,7 +84,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>
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-chat-session-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-chat-session-bot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -84,7 +84,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 -->
Expand Down
4 changes: 2 additions & 2 deletions telegrambots-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
```
4 changes: 2 additions & 2 deletions telegrambots-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.6.0</version>
<version>5.7.1</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion telegrambots-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/**
* @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
Expand Down Expand Up @@ -83,14 +84,10 @@ public Message deserializeResponse(String answer) throws TelegramApiRequestExcep

@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
/**
* @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)
Expand All @@ -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";

Expand All @@ -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 {
Expand All @@ -86,31 +92,37 @@ public Boolean deserializeResponse(String answer) throws TelegramApiRequestExcep

@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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
/**
* @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)
Expand All @@ -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";
Expand Down Expand Up @@ -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 {
Expand All @@ -96,34 +105,40 @@ public Boolean deserializeResponse(String answer) throws TelegramApiRequestExcep

@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();
}
Expand Down
Loading

0 comments on commit 6bb1746

Please sign in to comment.