Update version 4.9
This commit is contained in:
parent
28f60e3024
commit
72b239e851
@ -27,16 +27,16 @@ 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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambots:4.8.1"
|
compile "org.telegram:telegrambots:4.9"
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.8.1)
|
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.9)
|
||||||
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.8.1)
|
3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.9)
|
||||||
|
|
||||||
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="4.9"></a>4.9 ###
|
||||||
|
1. Update Api version [4.9](https://core.telegram.org/bots/api-changelog#june-4-2020)
|
||||||
|
2. Bug fixing: #731, #749, #752 and #753
|
||||||
|
|
||||||
### <a id="4.8.1"></a>4.8.1 ###
|
### <a id="4.8.1"></a>4.8.1 ###
|
||||||
1. Update Api version [4.8](https://core.telegram.org/bots/api-changelog#april-24-2020)
|
1. Update Api version [4.8](https://core.telegram.org/bots/api-changelog#april-24-2020)
|
||||||
2. Add stats for Abilities
|
2. Add stats for Abilities
|
||||||
|
@ -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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* With **Gradle**:
|
* With **Gradle**:
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
compile group: 'org.telegram', name: 'telegrambots', version: '4.8.1'
|
compile group: 'org.telegram', name: 'telegrambots', version: '4.9'
|
||||||
```
|
```
|
||||||
|
|
||||||
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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* **Gradle**
|
* **Gradle**
|
||||||
```groovy
|
```groovy
|
||||||
implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '4.8.1'
|
implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '4.9'
|
||||||
```
|
```
|
||||||
* [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>4.8.1</version>
|
<version>4.9</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>telegrambots</module>
|
<module>telegrambots</module>
|
||||||
|
@ -18,19 +18,19 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambots-abilities:4.8.1"
|
compile "org.telegram:telegrambots-abilities:4.9"
|
||||||
```
|
```
|
||||||
|
|
||||||
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.8.1)
|
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.9)
|
||||||
|
|
||||||
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.8.1)
|
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.9)
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
----------
|
----------
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
@ -15,7 +15,7 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</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>4.8.1</version>
|
<version>4.9</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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambotsextensions:4.8.1"
|
compile "org.telegram:telegrambotsextensions:4.9"
|
||||||
```
|
```
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</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>4.8.1</version>
|
<version>4.9</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>4.8.1</version>
|
<version>4.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
|
@ -10,14 +10,18 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
|||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 4.7
|
* @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.
|
* Use this method to send an animated emoji that will display a random value. 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<Message> {
|
public class SendDice extends BotApiMethod<Message> {
|
||||||
|
private static final List<String> VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("\uD83C\uDFB2", "\uD83C\uDFAF", "\uD83C\uDFC0"));
|
||||||
|
|
||||||
public static final String PATH = "sendDice";
|
public static final String PATH = "sendDice";
|
||||||
|
|
||||||
private static final String CHATID_FIELD = "chat_id";
|
private static final String CHATID_FIELD = "chat_id";
|
||||||
@ -28,8 +32,12 @@ public class SendDice extends BotApiMethod<Message> {
|
|||||||
|
|
||||||
@JsonProperty(CHATID_FIELD)
|
@JsonProperty(CHATID_FIELD)
|
||||||
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||||
|
/**
|
||||||
|
* Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, or “🏀”.
|
||||||
|
* Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”. Defauts to “🎲”
|
||||||
|
*/
|
||||||
@JsonProperty(EMOJI_FIELD)
|
@JsonProperty(EMOJI_FIELD)
|
||||||
private String emoji; ///< Optional. Emoji on which the dice throw animation is based. Currently, must be one of “🎲” or “🎯”. Defauts to “🎲”
|
private String emoji;
|
||||||
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
||||||
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
||||||
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
||||||
@ -121,8 +129,8 @@ public class SendDice extends BotApiMethod<Message> {
|
|||||||
if (chatId == null) {
|
if (chatId == null) {
|
||||||
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
||||||
}
|
}
|
||||||
if (emoji != null && !emoji.equals("\uD83C\uDFB2") && !emoji.equals("\uD83C\uDFAF")) {
|
if (emoji != null && !VALIDEMOJIS.contains(emoji)) {
|
||||||
throw new TelegramApiValidationException("Only \uD83C\uDFB2 and \uD83C\uDFAF are allowed in Emoji field ", this);
|
throw new TelegramApiValidationException("Only \uD83C\uDFB2, \uD83C\uDFAF or \uD83C\uDFC0 are allowed in Emoji field ", this);
|
||||||
}
|
}
|
||||||
if (replyMarkup != null) {
|
if (replyMarkup != null) {
|
||||||
replyMarkup.validate();
|
replyMarkup.validate();
|
||||||
|
@ -6,15 +6,14 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 4.7
|
* @version 4.7
|
||||||
* This object represents a dice with random value from 1 to 6.
|
* This object represents an animated emoji that displays a random value.
|
||||||
* (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 {
|
public class Dice implements BotApiObject {
|
||||||
private static final String VALUE_FIELD = "value";
|
private static final String VALUE_FIELD = "value";
|
||||||
private static final String EMOJI_FIELD = "emoji";
|
private static final String EMOJI_FIELD = "emoji";
|
||||||
|
|
||||||
@JsonProperty(VALUE_FIELD)
|
@JsonProperty(VALUE_FIELD)
|
||||||
private Integer value; ///< Value of the dice, 1-6
|
private Integer value; ///< Value of the dice, 1-6 for “🎲” and “🎯” base emoji, 1-5 for “🏀” base emoji
|
||||||
@JsonProperty(EMOJI_FIELD)
|
@JsonProperty(EMOJI_FIELD)
|
||||||
private String emoji; ///< Emoji on which the dice throw animation is based
|
private String emoji; ///< Emoji on which the dice throw animation is based
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ public class Message implements BotApiObject {
|
|||||||
private static final String POLL_FIELD = "poll";
|
private static final String POLL_FIELD = "poll";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String DICE_FIELD = "dice";
|
private static final String DICE_FIELD = "dice";
|
||||||
|
private static final String VIABOT_FIELD = "via_bot";
|
||||||
|
|
||||||
@JsonProperty(MESSAGEID_FIELD)
|
@JsonProperty(MESSAGEID_FIELD)
|
||||||
private Integer messageId; ///< Integer Unique message identifier
|
private Integer messageId; ///< Integer Unique message identifier
|
||||||
@ -210,7 +211,8 @@ public class Message implements BotApiObject {
|
|||||||
private InlineKeyboardMarkup replyMarkup;
|
private InlineKeyboardMarkup replyMarkup;
|
||||||
@JsonProperty(DICE_FIELD)
|
@JsonProperty(DICE_FIELD)
|
||||||
private Dice dice; // Optional. Message is a dice with random value from 1 to 6
|
private Dice dice; // Optional. Message is a dice with random value from 1 to 6
|
||||||
|
@JsonProperty(VIABOT_FIELD)
|
||||||
|
private User viaBot; // Optional. Bot through which the message was sent
|
||||||
public Message() {
|
public Message() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -521,6 +523,14 @@ public class Message implements BotApiObject {
|
|||||||
return dice != null;
|
return dice != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User getViaBot() {
|
||||||
|
return viaBot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasViaBot() {
|
||||||
|
return viaBot != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasReplyMarkup() {
|
public boolean hasReplyMarkup() {
|
||||||
return replyMarkup != null;
|
return replyMarkup != null;
|
||||||
}
|
}
|
||||||
@ -579,6 +589,8 @@ public class Message implements BotApiObject {
|
|||||||
", forwardSenderName='" + forwardSenderName + '\'' +
|
", forwardSenderName='" + forwardSenderName + '\'' +
|
||||||
", poll=" + poll +
|
", poll=" + poll +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", dice=" + dice +
|
||||||
|
", viaBot=" + viaBot +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessageconten
|
|||||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -16,12 +20,15 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
|||||||
*/
|
*/
|
||||||
@JsonDeserialize
|
@JsonDeserialize
|
||||||
public class InlineQueryResultGif implements InlineQueryResult {
|
public class InlineQueryResultGif implements InlineQueryResult {
|
||||||
|
private static final List<String> VALIDTHUMBTYPES = Collections.unmodifiableList(Arrays.asList("image/jpeg", "image/gif", "video/mp4"));
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String GIFURL_FIELD = "gif_url";
|
private static final String GIFURL_FIELD = "gif_url";
|
||||||
private static final String GIFWIDTH_FIELD = "gif_width";
|
private static final String GIFWIDTH_FIELD = "gif_width";
|
||||||
private static final String GIFHEIGHT_FIELD = "gif_height";
|
private static final String GIFHEIGHT_FIELD = "gif_height";
|
||||||
private static final String THUMBURL_FIELD = "thumb_url";
|
private static final String THUMBURL_FIELD = "thumb_url";
|
||||||
|
private static final String THUMBMIMETYPE_FIELD = "thumb_mime_type";
|
||||||
private static final String TITLE_FIELD = "title";
|
private static final String TITLE_FIELD = "title";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
@ -40,7 +47,9 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
@JsonProperty(GIFHEIGHT_FIELD)
|
@JsonProperty(GIFHEIGHT_FIELD)
|
||||||
private Integer gifHeight; ///< Optional. Height of the GIF
|
private Integer gifHeight; ///< Optional. Height of the GIF
|
||||||
@JsonProperty(THUMBURL_FIELD)
|
@JsonProperty(THUMBURL_FIELD)
|
||||||
private String thumbUrl; ///< Optional. URL of a static thumbnail for the result (jpeg or gif)
|
private String thumbUrl; ///< Optional. URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
|
||||||
|
@JsonProperty(THUMBMIMETYPE_FIELD)
|
||||||
|
private String thumbUrlType; ///< Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”
|
||||||
@JsonProperty(TITLE_FIELD)
|
@JsonProperty(TITLE_FIELD)
|
||||||
private String title; ///< Optional. Title for the result
|
private String title; ///< Optional. Title for the result
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
@ -107,6 +116,15 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getThumbUrlType() {
|
||||||
|
return thumbUrlType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultGif setThumbUrlType(String thumbUrlType) {
|
||||||
|
this.thumbUrlType = thumbUrlType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
@ -169,6 +187,9 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
if (gifUrl == null || gifUrl.isEmpty()) {
|
if (gifUrl == null || gifUrl.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("GifUrl parameter can't be empty", this);
|
throw new TelegramApiValidationException("GifUrl parameter can't be empty", this);
|
||||||
}
|
}
|
||||||
|
if (thumbUrlType != null && !VALIDTHUMBTYPES.contains(thumbUrlType)) {
|
||||||
|
throw new TelegramApiValidationException("ThumbUrlType parameter must be one of “image/jpeg”, “image/gif”, or “video/mp4”", this);
|
||||||
|
}
|
||||||
if (inputMessageContent != null) {
|
if (inputMessageContent != null) {
|
||||||
inputMessageContent.validate();
|
inputMessageContent.validate();
|
||||||
}
|
}
|
||||||
@ -186,6 +207,7 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
", gifWidth=" + gifWidth +
|
", gifWidth=" + gifWidth +
|
||||||
", gifHeight=" + gifHeight +
|
", gifHeight=" + gifHeight +
|
||||||
", thumbUrl='" + thumbUrl + '\'' +
|
", thumbUrl='" + thumbUrl + '\'' +
|
||||||
|
", thumbUrlType='" + thumbUrlType + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
|
@ -8,6 +8,10 @@ import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQuery
|
|||||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@ -17,11 +21,15 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
|||||||
*/
|
*/
|
||||||
@JsonDeserialize
|
@JsonDeserialize
|
||||||
public class InlineQueryResultCachedGif implements InlineQueryResult {
|
public class InlineQueryResultCachedGif implements InlineQueryResult {
|
||||||
|
private static final List<String> VALIDTHUMBTYPES = Collections.unmodifiableList(Arrays.asList("image/jpeg", "image/gif", "video/mp4"));
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String GIF_FILE_ID_FIELD = "gif_file_id";
|
private static final String GIF_FILE_ID_FIELD = "gif_file_id";
|
||||||
private static final String TITLE_FIELD = "title";
|
private static final String TITLE_FIELD = "title";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String THUMBURL_FIELD = "thumb_url";
|
||||||
|
private static final String THUMBMIMETYPE_FIELD = "thumb_mime_type";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String PARSEMODE_FIELD = "parse_mode";
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
@ -42,6 +50,10 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(PARSEMODE_FIELD)
|
@JsonProperty(PARSEMODE_FIELD)
|
||||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||||
|
@JsonProperty(THUMBURL_FIELD)
|
||||||
|
private String thumbUrl; ///< Optional. URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
|
||||||
|
@JsonProperty(THUMBMIMETYPE_FIELD)
|
||||||
|
private String thumbUrlType;
|
||||||
|
|
||||||
public InlineQueryResultCachedGif() {
|
public InlineQueryResultCachedGif() {
|
||||||
super();
|
super();
|
||||||
@ -114,6 +126,24 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getThumbUrl() {
|
||||||
|
return thumbUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedGif setThumbUrl(String thumbUrl) {
|
||||||
|
this.thumbUrl = thumbUrl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getThumbUrlType() {
|
||||||
|
return thumbUrlType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedGif setThumbUrlType(String thumbUrlType) {
|
||||||
|
this.thumbUrlType = thumbUrlType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -122,6 +152,9 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
if (gifFileId == null || gifFileId.isEmpty()) {
|
if (gifFileId == null || gifFileId.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("GifFileId parameter can't be empty", this);
|
throw new TelegramApiValidationException("GifFileId parameter can't be empty", this);
|
||||||
}
|
}
|
||||||
|
if (thumbUrlType != null && !VALIDTHUMBTYPES.contains(thumbUrlType)) {
|
||||||
|
throw new TelegramApiValidationException("ThumbUrlType parameter must be one of “image/jpeg”, “image/gif”, or “video/mp4”", this);
|
||||||
|
}
|
||||||
if (inputMessageContent != null) {
|
if (inputMessageContent != null) {
|
||||||
inputMessageContent.validate();
|
inputMessageContent.validate();
|
||||||
}
|
}
|
||||||
@ -141,6 +174,8 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", parseMode='" + parseMode + '\'' +
|
", parseMode='" + parseMode + '\'' +
|
||||||
|
", thumbUrl='" + thumbUrl + '\'' +
|
||||||
|
", thumbUrlType='" + thumbUrlType + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
@ -95,7 +95,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user