Api Version 5.6

This commit is contained in:
Ruben 2022-01-01 23:06:28 +00:00
parent 5c6bbbe1db
commit feffffe112
39 changed files with 140 additions and 53 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.5.0</version>
<version>5.6.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambots:5.5.0'
implementation 'org.telegram:telegrambots:5.6.0'
```
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.5.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.5.0)
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)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,5 +1,8 @@
### <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)
### <a id="5.5.0"></a>5.5.0 ###
1. Update Api version [5.5](https://core.telegram.org/bots/api#december-7-2021)
1. Update Api version [5.5](https://core.telegram.org/bots/api-changelog#december-7-2021)
### <a id="5.4.0.1"></a>5.4.0.1 ###
1. Bug fixing: #999, #1000

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.5.0</version>
<version>5.6.0</version>
</dependency>
```
* With **Gradle**:
```gradle
implementation 'org.telegram:telegrambots:5.5.0'
implementation 'org.telegram:telegrambots:5.6.0'
```
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.5.0</version>
<version>5.6.0</version>
</dependency>
```
* **Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:5.5.0'
implementation 'org.telegram:telegrambots-abilities:5.6.0'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>5.5.0</version>
<version>5.6.0</version>
<modules>
<module>telegrambots</module>

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:5.5.0'
implementation 'org.telegram:telegrambots-abilities:5.6.0'
```
**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.5.0</version>
<version>5.6.0</version>
</parent>
<artifactId>telegrambots-abilities</artifactId>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.5.0</version>
<version>5.6.0</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.5.0</version>
<version>5.6.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-chat-session-bot:5.5.0'
implementation 'org.telegram:telegrambots-chat-session-bot:5.6.0'
```
Motivation

View File

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

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.5.0</version>
<version>5.6.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambotsextensions:5.5.0'
implementation 'org.telegram:telegrambotsextensions:5.6.0'
```

View File

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

View File

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

View File

@ -53,6 +53,7 @@ public class CopyMessage extends BotApiMethod<MessageId> {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -85,6 +86,8 @@ public class CopyMessage extends BotApiMethod<MessageId> {
@JsonProperty(REPLYMARKUP_FIELD)
@JsonDeserialize()
private ReplyKeyboard replyMarkup;
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = null;

View File

@ -41,6 +41,7 @@ public class ForwardMessage extends BotApiMethod<Message> {
private static final String FROMCHATID_FIELD = "from_chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -59,6 +60,8 @@ public class ForwardMessage extends BotApiMethod<Message> {
*/
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification;
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Override
public void validate() throws TelegramApiValidationException {

View File

@ -60,6 +60,7 @@ public class SendPoll extends BotApiMethod<Message> {
private static final String EXPLANATIONPARSEMODE_FIELD = "explanation_parse_mode";
private static final String EXPLANATION_ENTITIES_FIELD = "explanation_entities";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
@ -105,6 +106,8 @@ public class SendPoll extends BotApiMethod<Message> {
private List<MessageEntity> explanationEntities; ///< Optional. List of special entities that appear in the poll explanation, which can be specified instead of parse_mode
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = null;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -55,6 +56,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
public static final String THUMB_FIELD = "thumb";
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -85,6 +87,7 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -56,6 +57,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
public static final String THUMB_FIELD = "thumb";
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
@ -81,6 +83,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -46,6 +46,7 @@ public class SendContact extends BotApiMethod<Message> {
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String VCARD_FIELD = "vcard";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -68,6 +69,8 @@ public class SendContact extends BotApiMethod<Message> {
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -47,6 +47,7 @@ public class SendDice extends BotApiMethod<Message> {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -72,6 +73,8 @@ public class SendDice extends BotApiMethod<Message> {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -50,6 +51,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String DISABLECONTENTTYPEDETECTION_FIELD = "disable_content_type_detection";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
@ -73,6 +75,7 @@ public class SendDocument extends PartialBotApiMethod<Message> {
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean disableContentTypeDetection; ///< Optional Disables automatic server-side content type detection for files uploaded using multipart/form-data
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -59,6 +59,7 @@ public class SendGame extends BotApiMethod<Message> {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -74,6 +75,8 @@ public class SendGame extends BotApiMethod<Message> {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = null;

View File

@ -66,6 +66,7 @@ public class SendInvoice extends BotApiMethod<Message> {
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String MAXTIPAMOUNT_FIELD = "max_tip_amount";
private static final String SUGGESTEDTIPAMOUNTS_FIELD = "suggested_tip_amounts";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -161,6 +162,8 @@ public class SendInvoice extends BotApiMethod<Message> {
@JsonProperty(SUGGESTEDTIPAMOUNTS_FIELD)
@Singular
private List<Integer> suggestedTipAmounts;
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Override
public String getMethod() {

View File

@ -47,6 +47,7 @@ public class SendLocation extends BotApiMethod<Message> {
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
private static final String HEADING_FIELD = "heading";
private static final String PROXIMITYALERTRADIUS_FIELD = "proximity_alert_radius";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -87,6 +88,8 @@ public class SendLocation extends BotApiMethod<Message> {
*/
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
private Integer proximityAlertRadius;
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -50,6 +50,7 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -63,6 +64,7 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
private Boolean disableNotification; ///< Optional. Sends the messages silently. Users will receive a notification with no sound.
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -50,6 +50,7 @@ public class SendMessage extends BotApiMethod<Message> {
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String ENTITIES_FIELD = "entities";
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -72,6 +73,8 @@ public class SendMessage extends BotApiMethod<Message> {
private List<MessageEntity> entities; ///< Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void disableWebPagePreview() {
disableWebPagePreview = true;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -49,6 +50,7 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -62,6 +64,7 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -42,6 +42,7 @@ public class SendSticker extends PartialBotApiMethod<Message> {
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -51,6 +52,7 @@ public class SendSticker extends PartialBotApiMethod<Message> {
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public Boolean getDisableNotification() {
return disableNotification;

View File

@ -50,6 +50,7 @@ public class SendVenue extends BotApiMethod<Message> {
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
private static final String PROTECTCONTENT_FIELD = "protect_content";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -82,6 +83,8 @@ public class SendVenue extends BotApiMethod<Message> {
private String googlePlaceId; ///< Optional. Google Places identifier of the venue
@JsonProperty(GOOGLEPLACETYPE_FIELD)
private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -54,6 +55,7 @@ public class SendVideo extends PartialBotApiMethod<Message> {
public static final String THUMB_FIELD = "thumb";
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -80,6 +82,7 @@ public class SendVideo extends PartialBotApiMethod<Message> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -47,6 +48,7 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String THUMB_FIELD = "thumb";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -66,6 +68,7 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
*/
private InputFile thumb;
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -51,6 +52,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@NonNull
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
@ -65,6 +67,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
public void enableNotification() {
this.disableNotification = false;

View File

@ -20,6 +20,7 @@ public class EntityType {
public static final String PRE = "pre"; ///< Monowidth block
public static final String TEXTLINK = "text_link"; ///< Clickable urls
public static final String TEXTMENTION = "text_mention"; ///< for users without usernames
public static final String SPOILER = "spoiler"; ///< spoiler message
private EntityType() {
}

View File

@ -36,24 +36,25 @@ public class MessageEntity implements BotApiObject {
private static final String USER_FIELD = "user";
private static final String LANGUAGE_FIELD = "language";
/**
* Type of the entity. One of
* mention (@username),
* hashtag,
* cashtag
* bot_command,
* url,
* email,
* phone_number,
* bold (bold text),
* italic (italic text),
* code (monowidth string),
* pre (monowidth block),
* text_link (for clickable text URLs),
* text_mention (for users without usernames),
* underline,
* strikethrough
* Type of the entity.
* Currently, can be:
* - mention (@username)
* - hashtag (#hashtag)
* - cashtag ($USD)
* - bot_command (/start@jobs_bot)
* - url (https://telegram.org)
* - email (do-not-reply@telegram.org)
* - phone_number (+1-212-555-0123),
* - bold (bold text)
* - italic (italic text)
* - underline (underlined text)
* - strikethrough (strikethrough text)
* - spoiler (spoiler message)
* - code (monowidth string)
* - pre (monowidth block)
* - text_link (for clickable text URLs)
* - text_mention (for users without usernames)
*/
@JsonProperty(TYPE_FIELD)
@NonNull
private String type;

View File

@ -43,7 +43,7 @@ public abstract class InputMedia implements Validable, BotApiObject {
public static final String MEDIA_FIELD = "media";
public static final String CAPTION_FIELD = "caption";
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String ENTITIES_FIELD = "caption_entities";
public static final String CAPTIONENTITIES_FIELD = "caption_entities";
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended),
@ -57,9 +57,9 @@ public abstract class InputMedia implements Validable, BotApiObject {
private String caption; ///< Optional. Caption of the media to be sent, 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
@JsonProperty(ENTITIES_FIELD)
@JsonProperty(CAPTIONENTITIES_FIELD)
@Singular
private List<MessageEntity> entities; ///< Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
@JsonIgnore
private boolean isNewMedia; ///< True to upload a new media, false to use a fileId or URL
@JsonIgnore
@ -117,7 +117,7 @@ public abstract class InputMedia implements Validable, BotApiObject {
} else if (media == null || media.isEmpty()) {
throw new TelegramApiValidationException("Media can't be empty", this);
}
if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
}
}

View File

@ -31,9 +31,9 @@ public class InputMediaSerializer extends JsonSerializer<InputMedia> {
if (value.getParseMode() != null) {
gen.writeStringField(InputMedia.PARSEMODE_FIELD, value.getParseMode());
}
if (value.getEntities() != null) {
gen.writeArrayFieldStart(InputMedia.ENTITIES_FIELD);
for (MessageEntity entity : value.getEntities()) {
if (value.getCaptionEntities() != null) {
gen.writeArrayFieldStart(InputMedia.CAPTIONENTITIES_FIELD);
for (MessageEntity entity : value.getCaptionEntities()) {
gen.writeObject(entity);
}
gen.writeEndArray();

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</parent>
<artifactId>telegrambots</artifactId>
@ -92,7 +92,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

View File

@ -176,6 +176,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendDocument.getDisableNotification() != null) {
builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendDocument.getProtectContent() != null) {
builder.addTextBody(SendDocument.PROTECTCONTENT_FIELD, sendDocument.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendDocument.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendDocument.ALLOWSENDINGWITHOUTREPLY_FIELD, sendDocument.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -234,6 +237,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendPhoto.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendPhoto.ALLOWSENDINGWITHOUTREPLY_FIELD, sendPhoto.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendPhoto.getProtectContent() != null) {
builder.addTextBody(SendPhoto.PROTECTCONTENT_FIELD, sendPhoto.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendPhoto.getCaptionEntities() != null) {
builder.addTextBody(SendPhoto.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendPhoto.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
}
@ -288,6 +294,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendVideo.getDisableNotification() != null) {
builder.addTextBody(SendVideo.DISABLENOTIFICATION_FIELD, sendVideo.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideo.getProtectContent() != null) {
builder.addTextBody(SendVideo.PROTECTCONTENT_FIELD, sendVideo.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideo.getThumb() != null) {
addInputFile(builder, sendVideo.getThumb(), SendVideo.THUMB_FIELD, false);
builder.addTextBody(SendVideo.THUMB_FIELD, sendVideo.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
@ -338,6 +347,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendVideoNote.getDisableNotification() != null) {
builder.addTextBody(SendVideoNote.DISABLENOTIFICATION_FIELD, sendVideoNote.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideoNote.getProtectContent() != null) {
builder.addTextBody(SendVideoNote.PROTECTCONTENT_FIELD, sendVideoNote.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideoNote.getThumb() != null) {
addInputFile(builder, sendVideoNote.getThumb(), SendVideoNote.THUMB_FIELD, false);
builder.addTextBody(SendVideoNote.THUMB_FIELD, sendVideoNote.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
@ -379,6 +391,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendSticker.getDisableNotification() != null) {
builder.addTextBody(SendSticker.DISABLENOTIFICATION_FIELD, sendSticker.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendSticker.getProtectContent() != null) {
builder.addTextBody(SendSticker.PROTECTCONTENT_FIELD, sendSticker.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendSticker.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendSticker.ALLOWSENDINGWITHOUTREPLY_FIELD, sendSticker.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
@ -441,6 +456,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendAudio.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendAudio.ALLOWSENDINGWITHOUTREPLY_FIELD, sendAudio.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAudio.getProtectContent() != null) {
builder.addTextBody(SendAudio.PROTECTCONTENT_FIELD, sendAudio.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAudio.getCaptionEntities() != null) {
builder.addTextBody(SendAudio.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendAudio.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
}
@ -496,6 +514,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendVoice.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendVoice.ALLOWSENDINGWITHOUTREPLY_FIELD, sendVoice.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVoice.getProtectContent() != null) {
builder.addTextBody(SendVoice.PROTECTCONTENT_FIELD, sendVoice.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVoice.getCaptionEntities() != null) {
builder.addTextBody(SendVoice.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendVoice.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
}
@ -563,6 +584,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendMediaGroup.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendMediaGroup.ALLOWSENDINGWITHOUTREPLY_FIELD, sendMediaGroup.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendMediaGroup.getProtectContent() != null) {
builder.addTextBody(SendMediaGroup.PROTECTCONTENT_FIELD, sendMediaGroup.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
HttpEntity multipart = builder.build();
@ -758,6 +782,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendAnimation.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendAnimation.ALLOWSENDINGWITHOUTREPLY_FIELD, sendAnimation.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAnimation.getProtectContent() != null) {
builder.addTextBody(SendAnimation.PROTECTCONTENT_FIELD, sendAnimation.getProtectContent().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAnimation.getCaptionEntities() != null) {
builder.addTextBody(SendAnimation.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendAnimation.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
}