Api version 6.6

This commit is contained in:
ruben 2023-05-30 01:32:15 +01:00
parent 61eb857248
commit c3925e035d
68 changed files with 1999 additions and 374 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>6.5.0</version>
<version>6.6.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambots:6.5.0'
implementation 'org.telegram:telegrambots:6.6.0'
```
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.5.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.5.0)
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.6.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.6.0)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,4 +1,7 @@
### <a id="6.4.0"></a>6.4.0 ###
### <a id="6.6.0"></a>6.6.0 ###
1. Update Api version [6.6](https://core.telegram.org/bots/api-changelog#march-9-2023)
### <a id="6.5.0"></a>6.5.0 ###
1. Update Api version [6.5](https://core.telegram.org/bots/api-changelog#february-3-2023)
### <a id="6.4.0"></a>6.4.0 ###

View File

@ -11,13 +11,13 @@ First you need to acquire the library and add it to your project. There are seve
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</dependency>
```
* With **Gradle**:
```gradle
implementation 'org.telegram:telegrambots:6.5.0'
implementation 'org.telegram:telegrambots:6.6.0'
```
2. Don't like the **Maven Central Repository**? It can also be grabbed 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>6.5.0</version>
<version>6.6.0</version>
</dependency>
```
* **Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:6.5.0'
implementation 'org.telegram:telegrambots-abilities:6.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>6.5.0</version>
<version>6.6.0</version>
<modules>
<module>telegrambots</module>
@ -70,8 +70,8 @@
<junit.version>5.9.1</junit.version>
<mockito.version>4.8.1</mockito.version>
<mockitojupiter.version>4.8.1</mockitojupiter.version>
<jacksonanotation.version>2.14.0</jacksonanotation.version>
<jackson.version>2.14.0</jackson.version>
<jacksonanotation.version>2.14.2</jacksonanotation.version>
<jackson.version>2.14.2</jackson.version>
<slf4j.version>2.0.3</slf4j.version>
<jakarta.annotation.version>2.1.1</jakarta.annotation.version>
<lombok.version>1.18.24</lombok.version>

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:6.5.0'
implementation 'org.telegram:telegrambots-abilities:6.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>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>telegrambots-abilities</artifactId>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@ -107,7 +107,7 @@ import static org.telegram.abilitybots.api.util.AbilityUtils.isUserMessage;
*
* @author Abbas Abou Daya
*/
@SuppressWarnings({"ConfusingArgumentToVarargsMethod", "UnusedReturnValue", "WeakerAccess", "unused", "ConstantConditions"})
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess", "unused", "ConstantConditions"})
public abstract class BaseAbilityBot extends DefaultAbsSender implements AbilityExtension {
private static final Logger log = LoggerFactory.getLogger(BaseAbilityBot.class);

View File

@ -30,9 +30,9 @@ public interface MessageSender {
Boolean addStickerToSet(AddStickerToSet addStickerToSet) throws TelegramApiException;
public Boolean createNewStickerSet(CreateNewStickerSet createNewStickerSet) throws TelegramApiException;
Boolean createNewStickerSet(CreateNewStickerSet createNewStickerSet) throws TelegramApiException;
public File uploadStickerFile(UploadStickerFile uploadStickerFile) throws TelegramApiException;
File uploadStickerFile(UploadStickerFile uploadStickerFile) throws TelegramApiException;
Boolean setChatPhoto(SetChatPhoto setChatPhoto) throws TelegramApiException;

View File

@ -72,6 +72,4 @@ class SilentSenderTest {
}
}
;
}

View File

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

View File

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

View File

@ -20,7 +20,7 @@ public class DefaultChatIdConverter implements ChatIdConverter {
@Override
public void setSessionId(Serializable sessionId){
this.sessionId = (long) sessionId;
};
}
@Override
public Serializable getSessionId() {

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

View File

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

View File

@ -26,7 +26,9 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
* Creates a TelegramLongPollingCommandBot using default options
* Use ICommandRegistry's methods on this bot to register commands
*
* @deprecated Use {{@link #TelegramLongPollingBot(String)}
*/
@Deprecated
public TelegramLongPollingCommandBot() {
this(new DefaultBotOptions());
}
@ -37,7 +39,10 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
* Use ICommandRegistry's methods on this bot to register commands
*
* @param options Bot options
*
* @deprecated Use {{@link #TelegramLongPollingBot(DefaultBotOptions, String)}
*/
@Deprecated
public TelegramLongPollingCommandBot(DefaultBotOptions options) {
this(options, true);
}
@ -49,12 +54,48 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
* @param options Bot options
* @param allowCommandsWithUsername true to allow commands with parameters (default),
* false otherwise
*
* @deprecated Use {{@link #TelegramLongPollingBot(DefaultBotOptions, boolean, String)}
*/
@Deprecated
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername) {
super(options);
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, this::getBotUsername);
}
/**
* Creates a TelegramLongPollingCommandBot using default options
* Use ICommandRegistry's methods on this bot to register commands
*
*/
public TelegramLongPollingCommandBot(String botToken) {
this(new DefaultBotOptions(), botToken);
}
/**
* Creates a TelegramLongPollingCommandBot with custom options and allowing commands with
* usernames
* Use ICommandRegistry's methods on this bot to register commands
*
* @param options Bot options
*/
public TelegramLongPollingCommandBot(DefaultBotOptions options, String botToken) {
this(options, true, botToken);
}
/**
* Creates a TelegramLongPollingCommandBot
* Use ICommandRegistry's methods on this bot to register commands
*
* @param options Bot options
* @param allowCommandsWithUsername true to allow commands with parameters (default),
* false otherwise
*/
public TelegramLongPollingCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botToken) {
super(options, botToken);
this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, this::getBotUsername);
}
@Override
public final void onUpdateReceived(Update update) {
if (update.hasMessage()) {

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>telegrambots-meta</artifactId>
@ -95,6 +95,13 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.14.2</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,50 @@
package org.telegram.telegrambots.meta.api.methods.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.description.BotDescription;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
/**
* @author Ruben Bermudez
* @version 6.6
* Use this method to get the current bot description for the given user language.
* Returns BotDescription on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetMyDescription extends BotApiMethod<BotDescription> {
public static final String PATH = "getMyDescription";
private static final String LANGUAGE_CODE_FIELD = "language_code";
/**
* Optional
* A two-letter ISO 639-1 language code.
* If empty, the description will be applied to all users for whose language there is no dedicated description.
*/
@JsonProperty(LANGUAGE_CODE_FIELD)
private String languageCode;
@Override
public BotDescription deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, BotDescription.class);
}
@Override
public String getMethod() {
return PATH;
}
}

View File

@ -0,0 +1,52 @@
package org.telegram.telegrambots.meta.api.methods.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.description.BotShortDescription;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
/**
* @author Ruben Bermudez
* @version 6.6
*
* Use this method to get the current bot short description for the given user language.
*
* Returns BotShortDescription on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetMyShortDescription extends BotApiMethod<BotShortDescription> {
public static final String PATH = "getMyShortDescription";
private static final String LANGUAGE_CODE_FIELD = "language_code";
/**
* Optional
* A two-letter ISO 639-1 language code.
* If empty, the description will be applied to all users for whose language there is no dedicated description.
*/
@JsonProperty(LANGUAGE_CODE_FIELD)
private String languageCode;
@Override
public BotShortDescription deserializeResponse(String answer) throws TelegramApiRequestException {
return deserializeResponse(answer, BotShortDescription.class);
}
@Override
public String getMethod() {
return PATH;
}
}

View File

@ -0,0 +1,51 @@
package org.telegram.telegrambots.meta.api.methods.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
/**
* @author Ruben Bermudez
* @version 6.6
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SetMyDescription extends BotApiMethodBoolean {
public static final String PATH = "setMyDescription";
private static final String DESCRIPTION_FIELD = "description";
private static final String LANGUAGE_CODE_FIELD = "language_code";
/**
* Optional
* New bot description; 0-512 characters.
* Pass an empty string to remove the dedicated description for the given language.
*/
@JsonProperty(DESCRIPTION_FIELD)
private String description;
/**
* Optional
* A two-letter ISO 639-1 language code.
* If empty, the description will be applied to all users for whose language there is no dedicated description.
*/
@JsonProperty(LANGUAGE_CODE_FIELD)
private String languageCode;
@Override
public String getMethod() {
return PATH;
}
}

View File

@ -0,0 +1,54 @@
package org.telegram.telegrambots.meta.api.methods.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
/**
* @author Ruben Bermudez
* @version 6.6
*
* Use this method to change the bot's short description, which is shown on the bot's
* profile page and is sent together with the link when users share the bot.
*
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SetMyShortDescription extends BotApiMethodBoolean {
public static final String PATH = "setMyShortDescription";
private static final String SHORT_DESCRIPTION_FIELD = "short_description";
private static final String LANGUAGE_CODE_FIELD = "language_code";
/**
* Optional
* New short description for the bot; 0-120 characters.
* Pass an empty string to remove the dedicated short description for the given language.
*/
@JsonProperty(SHORT_DESCRIPTION_FIELD)
private String shortDescription;
/**
* Optional
* A two-letter ISO 639-1 language code.
* If empty, the short description will be applied to all users for whose language there is no dedicated short description.
*/
@JsonProperty(LANGUAGE_CODE_FIELD)
private String languageCode;
@Override
public String getMethod() {
return PATH;
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -33,7 +34,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendAnimation extends SendMediaBotMethod<Message> {
@ -50,7 +51,7 @@ public class SendAnimation extends SendMediaBotMethod<Message> {
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
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";
@ -87,7 +88,7 @@ public class SendAnimation extends SendMediaBotMethod<Message> {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
@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
@ -131,8 +132,8 @@ public class SendAnimation extends SendMediaBotMethod<Message> {
if (replyMarkup != null) {
replyMarkup.validate();
}
if (thumb != null) {
thumb.validate();
if (thumbnail != null) {
thumbnail.validate();
}
}
@ -151,6 +152,24 @@ public class SendAnimation extends SendMediaBotMethod<Message> {
return ANIMATION_FIELD;
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class SendAnimationBuilder {
@Tolerate
@ -158,5 +177,12 @@ public class SendAnimation extends SendMediaBotMethod<Message> {
this.chatId = chatId.toString();
return this;
}
@Tolerate
@Deprecated
public SendAnimationBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -34,7 +35,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendAudio extends SendMediaBotMethod<Message> {
@ -51,7 +52,7 @@ public class SendAudio extends SendMediaBotMethod<Message> {
public static final String TITLE_FIELD = "title";
public static final String CAPTION_FIELD = "caption";
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
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";
@ -81,7 +82,7 @@ public class SendAudio extends SendMediaBotMethod<Message> {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass
* attach://<file_attach_name> if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
@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
@ -117,8 +118,8 @@ public class SendAudio extends SendMediaBotMethod<Message> {
audio.validate();
if (thumb != null) {
thumb.validate();
if (thumbnail != null) {
thumbnail.validate();
}
if (replyMarkup != null) {
@ -141,6 +142,24 @@ public class SendAudio extends SendMediaBotMethod<Message> {
return AUDIO_FIELD;
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class SendAudioBuilder {
@Tolerate
@ -148,5 +167,12 @@ public class SendAudio extends SendMediaBotMethod<Message> {
this.chatId = chatId.toString();
return this;
}
@Tolerate
@Deprecated
public SendAudioBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -30,7 +31,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendDocument extends SendMediaBotMethod<Message> {
@ -44,7 +45,7 @@ public class SendDocument extends SendMediaBotMethod<Message> {
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
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";
@ -72,7 +73,7 @@ public class SendDocument extends SendMediaBotMethod<Message> {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
@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
@ -109,8 +110,8 @@ public class SendDocument extends SendMediaBotMethod<Message> {
document.validate();
if (thumb != null) {
thumb.validate();
if (thumbnail != null) {
thumbnail.validate();
}
if (replyMarkup != null) {
@ -133,6 +134,24 @@ public class SendDocument extends SendMediaBotMethod<Message> {
return PATH;
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class SendDocumentBuilder {
@Tolerate
@ -140,5 +159,12 @@ public class SendDocument extends SendMediaBotMethod<Message> {
this.chatId = chatId.toString();
return this;
}
@Tolerate
@Deprecated
public SendDocumentBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendSticker extends SendMediaBotMethod<Message> {
@ -41,6 +41,7 @@ public class SendSticker extends SendMediaBotMethod<Message> {
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";
public static final String EMOJI_FIELD = "emoji";
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@ -49,6 +50,14 @@ public class SendSticker extends SendMediaBotMethod<Message> {
* for forum supergroups only
*/
private Integer messageThreadId;
/**
* Sticker to send.
* Pass a file_id as String to send a file that exists on the Telegram servers (recommended),
* pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet,
* or upload a new .WEBP or .TGS sticker using multipart/form-data.
* Video stickers can only be sent by a file_id.
* Animated stickers can't be sent via an HTTP URL.
*/
@NonNull
private InputFile sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers or URL to upload it
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@ -57,6 +66,12 @@ public class SendSticker extends SendMediaBotMethod<Message> {
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
/**
* Optional
* Emoji associated with the sticker; only for uploaded stickers
*/
private String emoji;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -31,7 +32,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendVideo extends SendMediaBotMethod<Message> {
@ -49,7 +50,7 @@ public class SendVideo extends SendMediaBotMethod<Message> {
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PARSEMODE_FIELD = "parse_mode";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
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";
@ -81,7 +82,7 @@ public class SendVideo extends SendMediaBotMethod<Message> {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
@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
@ -122,8 +123,8 @@ public class SendVideo extends SendMediaBotMethod<Message> {
video.validate();
if (thumb != null) {
thumb.validate();
if (thumbnail != null) {
thumbnail.validate();
}
if (replyMarkup != null) {
replyMarkup.validate();
@ -145,6 +146,25 @@ public class SendVideo extends SendMediaBotMethod<Message> {
return VIDEO_FIELD;
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class SendVideoBuilder {
@Tolerate
@ -152,5 +172,12 @@ public class SendVideo extends SendMediaBotMethod<Message> {
this.chatId = chatId.toString();
return this;
}
@Tolerate
@Deprecated
public SendVideoBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -28,7 +29,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SendVideoNote extends SendMediaBotMethod<Message> {
@ -42,7 +43,7 @@ public class SendVideoNote extends SendMediaBotMethod<Message> {
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
public static final String PROTECTCONTENT_FIELD = "protect_content";
@ -67,7 +68,7 @@ public class SendVideoNote extends SendMediaBotMethod<Message> {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
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
@ -97,8 +98,8 @@ public class SendVideoNote extends SendMediaBotMethod<Message> {
videoNote.validate();
if (thumb != null) {
thumb.validate();
if (thumbnail != null) {
thumbnail.validate();
}
if (replyMarkup != null) {
replyMarkup.validate();
@ -120,6 +121,25 @@ public class SendVideoNote extends SendMediaBotMethod<Message> {
return VIDEONOTE_FIELD;
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class SendVideoNoteBuilder {
@Tolerate
@ -127,5 +147,12 @@ public class SendVideoNote extends SendMediaBotMethod<Message> {
this.chatId = chatId.toString();
return this;
}
@Tolerate
@Deprecated
public SendVideoNoteBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -18,9 +19,9 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @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, tgs_sticker, or webm_sticker.
* Use this method to add a new sticker to a set created by the bot.
* The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers.
* Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@ -28,7 +29,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
@ -36,18 +37,38 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
public static final String USERID_FIELD = "user_id";
public static final String NAME_FIELD = "name";
public static final String STICKER_FIELD = "sticker";
@Deprecated
public static final String PNGSTICKER_FIELD = "png_sticker";
@Deprecated
public static final String TGSSTICKER_FIELD = "tgs_sticker";
@Deprecated
public static final String WEBMSTICKER_FIELD = "webm_sticker";
@Deprecated
public static final String EMOJIS_FIELD = "emojis";
@Deprecated
public static final String MASKPOSITION_FIELD = "mask_position";
@NonNull
private Long userId; ///< User identifier of sticker set owner
@NonNull
private String name; ///< Sticker set name
/**
* A JSON-serialized object with information about the added sticker.
* If exactly the same sticker had already been added to the set, then the set isn't changed.
*
* @apiNote This field will become NonNull in next major release as per Telegram API definition.
*/
// @NonNull
private InputSticker sticker;
@NonNull
@Deprecated
private String emojis; ///< One or more emoji corresponding to the sticker
@Deprecated
private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
/**
* Optional.
@ -56,19 +77,22 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
* 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.
*/
@Deprecated
private InputFile pngSticker;
/**
* Optional.
* TGS animation with the sticker, uploaded using multipart/form-data.
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
* See <a href="https://core.telegram.org/animated_stickers#technical-requirements"/a> for technical requirements
*/
@Deprecated
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
* See <a href="https://core.telegram.org/stickers#video-stickers"/a> for technical requirements
*/
@Deprecated
private InputFile webmSticker;
@Override
@ -89,33 +113,38 @@ public class AddStickerToSet extends PartialBotApiMethod<Boolean> {
if (name.isEmpty()) {
throw new TelegramApiValidationException("name can't be empty", this);
}
if (emojis.isEmpty()) {
throw new TelegramApiValidationException("emojis can't be empty", this);
}
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
}
if (sticker == null) {
throw new TelegramApiValidationException("Sticker can't be empty", this);
} else {
sticker.validate();
}
} else {
// Support deprecated mode
if (emojis.isEmpty()) {
throw new TelegramApiValidationException("emojis can't be empty", 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 && 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 (pngSticker != null) {
pngSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (maskPosition != null) {
maskPosition.validate();
if (maskPosition != null) {
maskPosition.validate();
}
}
}
}

View File

@ -8,15 +8,18 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker;
import org.telegram.telegrambots.meta.api.objects.stickers.MaskPosition;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Arrays;
import java.util.List;
/**
* @author Ruben Bermudez
@ -31,33 +34,79 @@ import java.util.Arrays;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
public static final String PATH = "createNewStickerSet";
public static final String USERID_FIELD = "user_id";
public static final String STICKERS_FIELD = "stickers";
public static final String NAME_FIELD = "name";
public static final String STICKERTYPE_FIELD = "sticker_type";
public static final String TITLE_FIELD = "title";
public static final String STICKER_FORMAT_FIELD = "sticker_format";
public static final String STICKERTYPE_FIELD = "sticker_type";
public static final String NEEDS_REPAINTING_FIELD = "needs_repainting";
@Deprecated
public static final String PNGSTICKER_FIELD = "png_sticker";
@Deprecated
public static final String TGSSTICKER_FIELD = "tgs_sticker";
@Deprecated
public static final String WEBMSTICKER_FIELD = "webm_sticker";
@Deprecated
public static final String EMOJIS_FIELD = "emojis";
@Deprecated
public static final String CONTAINSMASKS_FIELD = "contains_masks";
@Deprecated
public static final String MASKPOSITION_FIELD = "mask_position";
@NonNull
private Long userId; ///< User identifier of created sticker set owner
/**
* Type of stickers in the set, pass regular or mask.
* Custom emoji sticker sets can't be created via the Bot API at the moment.
* User identifier of created sticker set owner
*/
@NonNull
private Long userId;
/**
* Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals).
* Can contain only English letters, digits and underscores.
* Must begin with a letter, can't contain consecutive underscores and must end in
* "_by_<bot_username>". <bot_username> is case-insensitive. 1-64 characters.
*/
@NonNull
private String name;
/**
* Sticker set title, 1-64 characters
*/
@NonNull
private String title;
/**
* A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
*/
@NonNull
@Singular
private List<InputSticker> stickers;
/**
* Format of stickers in the set, must be one of static, animated, video
*/
@NonNull
private String stickerFormat;
/**
* Optional
* True if stickers in the sticker set must be repainted to the color of text when used in messages,
* the accent color if used as emoji status, white on chat photos, or another appropriate color based on context;
* for custom emoji sticker sets only
*/
private Boolean needsRepainting;
/**
* Optional
* Type of stickers in the set, pass regular, mask, or custom_emoji.
* By default, a regular sticker set is created.
*/
@Builder.Default
private String stickerType = "regular";
/**
* Name of sticker set, to be used in t.me/addstickers/<name> URLs.
* Can contain only english letters, digits and underscores.
@ -65,11 +114,9 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
* <bot_username> is case insensitive. 7-64 characters.
*/
@NonNull
private String name; ///< Sticker set title, 1-64 characters
@NonNull
private String title; ///< User identifier of created sticker set owner
@NonNull
@Deprecated
private String emojis; ///< One or more emoji corresponding to the sticker
@Deprecated
private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
/**
* Optional.
@ -79,6 +126,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
* 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 »
*/
@Deprecated
private InputFile pngSticker;
/**
@ -86,6 +134,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
* TGS animation with the sticker, uploaded using multipart/form-data.
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
*/
@Deprecated
private InputFile tgsSticker;
/**
@ -93,6 +142,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
* WEBM video with the sticker, uploaded using multipart/form-data.
* See https://core.telegram.org/stickers#video-stickers for technical requirements
*/
@Deprecated
private InputFile webmSticker;
/**
@ -115,9 +165,11 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
return isMask();
}
@Deprecated
public boolean isRegularSticker() {
return "regular".equals(stickerType);
}
@Deprecated
public boolean isMask() {
return "mask".equals(stickerType);
}
@ -137,42 +189,55 @@ public class CreateNewStickerSet extends PartialBotApiMethod<Boolean> {
if (userId <= 0) {
throw new TelegramApiValidationException("userId can't be empty", this);
}
if (!Arrays.asList("regular", "mask").contains(stickerType)) {
throw new TelegramApiValidationException("Stickertype must be 'regular' or 'mask'", this);
if (name.isEmpty() || name.length() > 64) {
throw new TelegramApiValidationException("name must be between 1 and 64 characters", this);
}
if (name.isEmpty()) {
throw new TelegramApiValidationException("name can't be empty", this);
if (title.isEmpty() || title.length() > 64) {
throw new TelegramApiValidationException("title must be between 1 and 64 characters", this);
}
if (title.isEmpty()) {
throw new TelegramApiValidationException("title can't be empty", this);
if (!Arrays.asList("regular", "mask", "custom_emoji").contains(stickerType)) {
throw new TelegramApiValidationException("Stickertype must be 'regular', 'mask' or 'custom_emoji'", this);
}
if (emojis.isEmpty()) {
throw new TelegramApiValidationException("emojis can't be empty", this);
if (!Arrays.asList("static", "animated", "video").contains(stickerFormat)) {
throw new TelegramApiValidationException("StickerFormat must be 'static', 'animated', 'video'", this);
}
if (needsRepainting != null && !"custom_emoji".equals(stickerType)) {
throw new TelegramApiValidationException("needsRepainting is only allowed with custom emojis", this);
}
if (pngSticker == null && tgsSticker == null && webmSticker == null) {
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", this);
}
if (stickers.isEmpty()) {
throw new TelegramApiValidationException("sticker can't be empty", this);
} else {
for (InputSticker sticker : stickers) {
sticker.validate();
}
}
} else {
// Support deprecated option
if (emojis.isEmpty()) {
throw new TelegramApiValidationException("emojis can't be empty", this);
}
if ((pngSticker != null && tgsSticker != null) || (pngSticker != null && webmSticker != null)
|| (tgsSticker != null && webmSticker != null)) {
throw new TelegramApiValidationException("One of pngSticker, tgsSticker or webmSticker is needed", 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 (pngSticker != null) {
pngSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (tgsSticker != null) {
tgsSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (webmSticker != null) {
webmSticker.validate();
}
if (maskPosition != null) {
maskPosition.validate();
if (maskPosition != null) {
maskPosition.validate();
}
}
}

View File

@ -0,0 +1,65 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 6.6
* Use this method to set the thumbnail of a custom emoji sticker set.
*
* Returns True on success.
*
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor(force = true)
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class SetCustomEmojiStickerSetThumbnail extends BotApiMethodBoolean {
public static final String PATH = "setStickerSetThumb";
public static final String NAME_FIELD = "name";
public static final String CUSTOM_EMOJI_ID_FIELD = "custom_emoji_id";
/**
* Sticker set name
*/
@NonNull
@JsonProperty(NAME_FIELD)
private String name;
/**
* Optional.
*
* Custom emoji identifier of a sticker from the sticker set;
* pass an empty string to drop the thumbnail and use the first sticker as the thumbnail.
*/
@JsonProperty(CUSTOM_EMOJI_ID_FIELD)
private String customEmojiId;
@Override
public String getMethod() {
return PATH;
}
@Override
public void validate() throws TelegramApiValidationException {
if (name.isEmpty()) {
throw new TelegramApiValidationException("name can't be null", this);
}
}
}

View File

@ -15,13 +15,14 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
* Use this method to move a sticker in a set created by the bot to a specific position.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class SetStickerPositionInSet extends BotApiMethodBoolean {

View File

@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean;
@ -15,15 +16,16 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
* @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. Video thumbnails can be set only for video sticker sets only.
* Use this method to set the thumbnail of a regular or mask sticker set.
* The format of the thumbnail file must match the format of the stickers in the set.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@NoArgsConstructor(force = true)
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class SetStickerSetThumb extends BotApiMethodBoolean {
@ -33,21 +35,29 @@ public class SetStickerSetThumb extends BotApiMethodBoolean {
public static final String USERID_FIELD = "user_id";
public static final String THUMB_FIELD = "thumb";
@NonNull
private String name; ///< Sticker set name
@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/stickers#animated-sticker-requirements for animated sticker technical requirements,
* Sticker set name
*/
@NonNull
private String name;
/**
* User identifier of the sticker set owner
*/
@NonNull
private Long userId;
/**
* Optional
* A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of
* exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size
* (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.
* or upload a new one using multipart/form-data. More information on Sending Files ».
* Animated and video sticker set thumbnails can't be uploaded via HTTP URL.
*
* If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
*/
private InputFile thumb;

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
@ -8,12 +9,15 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.File;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Arrays;
/**
* @author Ruben Bermudez
* @version 1.0
@ -24,23 +28,29 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Getter
@Setter
@ToString
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class UploadStickerFile extends PartialBotApiMethod<File> {
public static final String PATH = "uploadStickerFile";
public static final String USERID_FIELD = "user_id";
public static final String PNGSTICKER_FIELD = "png_sticker";
public static final String STICKER_FORMAT_FIELD = "sticker_format";
public static final String STICKER_FIELD = "sticker";
@NonNull
private Long userId; ///< User identifier of sticker file owner
/**
* Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px,
* and either width or height must be exactly 512px. More info on Sending Files »
* Format of the sticker, must be one of static, animated, video
*/
@NonNull
private InputFile pngSticker; ///< New sticker file
private String stickerFormat;
/**
* A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format.
* See <a href="https://core.telegram.org/stickers"/a> for technical requirements.
*/
@NonNull
private InputFile sticker; ///< New sticker file
@Override
public String getMethod() {
@ -52,12 +62,43 @@ public class UploadStickerFile extends PartialBotApiMethod<File> {
return deserializeResponse(answer, File.class);
}
/**
* @deprecated Use {{@link #getSticker()}}
*/
@JsonIgnore
@Deprecated
public InputFile getPngSticker() {
return sticker;
}
/**
* @deprecated Use {{@link #setSticker(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setPngSticker(InputFile pngSticker) {
this.sticker = pngSticker;
}
@Override
public void validate() throws TelegramApiValidationException {
if (userId <= 0) {
throw new TelegramApiValidationException("userId can't be empty", this);
}
if (stickerFormat.isEmpty() || !Arrays.asList("static", "animated", "video").contains(stickerFormat)) {
throw new TelegramApiValidationException("Sticker Format must be one of 'static', 'animated', 'video'", this);
}
pngSticker.validate();
sticker.validate();
}
public static class UploadStickerFileBuilder {
@Tolerate
@Deprecated
public UploadStickerFileBuilder pngSticker(InputFile pngSticker) {
this.sticker = pngSticker;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -29,7 +30,7 @@ public class Audio implements BotApiObject {
private static final String FILESIZE_FIELD = "file_size";
private static final String TITLE_FIELD = "title";
private static final String PERFORMER_FIELD = "performer";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String FILENAME_FIELD = "file_name";
/**
@ -78,12 +79,30 @@ public class Audio implements BotApiObject {
* Optional.
* Thumbnail of the album cover to which the music file belongs
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* Original filename as defined by sender
*/
@JsonProperty(FILENAME_FIELD)
private String fileName;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -25,7 +26,7 @@ public class Document implements BotApiObject {
private static final String FILEID_FIELD = "file_id";
private static final String FILEUNIQUEID_FIELD = "file_unique_id";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String FILENAME_FIELD = "file_name";
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
@ -44,8 +45,8 @@ public class Document implements BotApiObject {
/**
* Document thumbnail as defined by sender
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* Original filename as defined by sender
@ -66,4 +67,22 @@ public class Document implements BotApiObject {
*/
@JsonProperty(FILESIZE_FIELD)
private Long fileSize;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -27,7 +28,7 @@ public class Video implements BotApiObject {
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String DURATION_FIELD = "duration";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
private static final String FILENAME_FIELD = "file_name";
@ -61,8 +62,8 @@ public class Video implements BotApiObject {
/**
* Video thumbnail
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* Mime type of file as defined by sender
@ -83,4 +84,22 @@ public class Video implements BotApiObject {
*/
@JsonProperty(FILENAME_FIELD)
private String fileName;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -25,7 +26,7 @@ public class VideoNote implements BotApiObject {
private static final String FILEUNIQUEID_FIELD = "file_unique_id";
private static final String LENGTH_FIELD = "length";
private static final String DURATION_FIELD = "duration";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String FILESIZE_FIELD = "file_size";
/**
@ -53,12 +54,30 @@ public class VideoNote implements BotApiObject {
* Optional.
* Video thumbnail
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* File size
*/
@JsonProperty(FILESIZE_FIELD)
private Integer fileSize;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -0,0 +1,31 @@
package org.telegram.telegrambots.meta.api.objects.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 6.6
* This object represents the bot's description.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@AllArgsConstructor
@Builder
public class BotDescription implements BotApiObject {
private static final String DESCRIPTION_FIELD = "description";
/**
* The bot's description
*/
@JsonProperty(DESCRIPTION_FIELD)
private String description;
}

View File

@ -0,0 +1,31 @@
package org.telegram.telegrambots.meta.api.objects.description;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 6.6
* This object represents the bot's short description.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@AllArgsConstructor
@Builder
public class BotShortDescription implements BotApiObject {
private static final String SHORT_DESCRIPTION_FIELD = "short_description";
/**
* The bot's short description
*/
@JsonProperty(SHORT_DESCRIPTION_FIELD)
private String shortDescription;
}

View File

@ -16,6 +16,7 @@
*/
package org.telegram.telegrambots.meta.api.objects.games;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -38,7 +39,7 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
public class Animation implements BotApiObject {
private static final String FILEID_FIELD = "file_id";
@ -46,7 +47,7 @@ public class Animation implements BotApiObject {
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String DURATION_FIELD = "duration";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String FILENAME_FIELD = "file_name";
private static final String MIMETYPE_FIELD = "mime_type";
private static final String FILESIZE_FIELD = "file_size";
@ -86,8 +87,8 @@ public class Animation implements BotApiObject {
* Optional.
* Animation thumbnail as defined by sender
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* Original animation filename as defined by sender
@ -108,4 +109,22 @@ public class Animation implements BotApiObject {
*/
@JsonProperty(FILESIZE_FIELD)
private Long fileSize;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -5,6 +5,10 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.serialization.InlineQueryResultDeserializer;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 1.0
@ -14,4 +18,6 @@ import org.telegram.telegrambots.meta.api.objects.inlinequery.result.serializati
*/
@JsonDeserialize(using = InlineQueryResultDeserializer.class)
public interface InlineQueryResult extends Validable, BotApiObject {
List<String> VALIDTHUMBTYPES = Collections.unmodifiableList(Arrays.asList("image/jpeg", "image/gif", "video/mp4"));
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
@ -11,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -26,7 +28,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultArticle implements InlineQueryResult {
@ -39,9 +41,9 @@ public class InlineQueryResultArticle implements InlineQueryResult {
private static final String URL_FIELD = "url";
private static final String HIDEURL_FIELD = "hide_url";
private static final String DESCRIPTION_FIELD = "description";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_WIDTH_FIELD = "thumbnail_width";
private static final String THUMBNAUK_HEIGHT_FIELD = "thumbnail_height";
@JsonProperty(TYPE_FIELD)
private final String type = "article"; ///< Type of the result, must be article
@ -62,27 +64,104 @@ public class InlineQueryResultArticle implements InlineQueryResult {
private Boolean hideUrl; ///< Optional. Pass True, if you don't want the URL to be shown in the message
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. Url of the thumbnail for the result
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. Url of the thumbnail for the result
@JsonProperty(THUMBNAIL_WIDTH_FIELD)
private Integer thumbnailWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBNAUK_HEIGHT_FIELD)
private Integer thumbnailHeight; ///< Optional. Thumbnail height
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (inputMessageContent == null) {
throw new TelegramApiValidationException("InputMessageContent parameter can't be null", this);
}
inputMessageContent.validate();
if (replyMarkup != null) {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailWidth()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbWidth() {
return thumbnailWidth;
}
/**
* @deprecated Use {{@link #setThumbnailWidth(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
}
/**
* @deprecated Use {{@link #getThumbnailHeight()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbHeight() {
return thumbnailHeight;
}
/**
* @deprecated Use {{@link #setThumbnailHeight(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
}
public static class InlineQueryResultArticleBuilder {
@Tolerate
@Deprecated
public InlineQueryResultArticleBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultArticleBuilder thumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultArticleBuilder thumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
@ -11,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -30,7 +32,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultContact implements InlineQueryResult {
@ -42,9 +44,9 @@ public class InlineQueryResultContact implements InlineQueryResult {
private static final String LAST_NAME_FIELD = "last_name";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_WIDTH_FIELD = "thumbnail_width";
private static final String THUMBNAUK_HEIGHT_FIELD = "thumbnail_height";
private static final String VCARD_FIELD = "vcard";
@JsonProperty(TYPE_FIELD)
@ -64,24 +66,24 @@ public class InlineQueryResultContact implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBNAIL_WIDTH_FIELD)
private Integer thumbnailWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBNAUK_HEIGHT_FIELD)
private Integer thumbnailHeight; ///< Optional. Thumbnail height
@JsonProperty(VCARD_FIELD)
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (phoneNumber == null || phoneNumber.isEmpty()) {
if (phoneNumber.isEmpty()) {
throw new TelegramApiValidationException("PhoneNumber parameter can't be empty", this);
}
if (firstName == null || firstName.isEmpty()) {
if (firstName.isEmpty()) {
throw new TelegramApiValidationException("FirstName parameter can't be empty", this);
}
if (inputMessageContent != null) {
@ -91,4 +93,82 @@ public class InlineQueryResultContact implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailWidth()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbWidth() {
return thumbnailWidth;
}
/**
* @deprecated Use {{@link #setThumbnailWidth(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
}
/**
* @deprecated Use {{@link #getThumbnailHeight()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbHeight() {
return thumbnailHeight;
}
/**
* @deprecated Use {{@link #setThumbnailHeight(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
}
public static class InlineQueryResultContactBuilder {
@Tolerate
@Deprecated
public InlineQueryResultContactBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultContactBuilder thumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultContactBuilder thumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -36,7 +38,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultDocument implements InlineQueryResult {
@ -50,9 +52,9 @@ public class InlineQueryResultDocument implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_WIDTH_FIELD = "thumbnail_width";
private static final String THUMBNAUK_HEIGHT_FIELD = "thumbnail_height";
private static final String PARSEMODE_FIELD = "parse_mode";
private static final String CAPTION_ENTITIES_FIELD = "caption_entities";
@ -78,12 +80,12 @@ public class InlineQueryResultDocument implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBNAIL_WIDTH_FIELD)
private Integer thumbnailWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBNAUK_HEIGHT_FIELD)
private Integer thumbnailHeight; ///< Optional. Thumbnail height
@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(CAPTION_ENTITIES_FIELD)
@ -92,21 +94,24 @@ public class InlineQueryResultDocument implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (mimeType == null || mimeType.isEmpty()) {
if (mimeType.isEmpty()) {
throw new TelegramApiValidationException("Mimetype parameter can't be empty", this);
}
if (documentUrl == null || documentUrl.isEmpty()) {
if (documentUrl.isEmpty()) {
throw new TelegramApiValidationException("DocumentUrl parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
}
if (thumbnailUrl != null && !"image/jpeg".equalsIgnoreCase(thumbnailUrl)) {
throw new TelegramApiValidationException("Thumbnail Url must be JPEG", this);
}
if (inputMessageContent != null) {
inputMessageContent.validate();
}
@ -114,4 +119,82 @@ public class InlineQueryResultDocument implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailWidth()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbWidth() {
return thumbnailWidth;
}
/**
* @deprecated Use {{@link #setThumbnailWidth(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
}
/**
* @deprecated Use {{@link #getThumbnailHeight()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbHeight() {
return thumbnailHeight;
}
/**
* @deprecated Use {{@link #setThumbnailHeight(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
}
public static class InlineQueryResultDocumentBuilder {
@Tolerate
@Deprecated
public InlineQueryResultDocumentBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultDocumentBuilder thumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultDocumentBuilder thumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
return this;
}
}
}

View File

@ -1,7 +1,7 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -13,13 +13,12 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@ -35,19 +34,17 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
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 ID_FIELD = "id";
private static final String GIFURL_FIELD = "gif_url";
private static final String GIFWIDTH_FIELD = "gif_width";
private static final String GIFHEIGHT_FIELD = "gif_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBMIMETYPE_FIELD = "thumb_mime_type";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_MIMETYPE_FIELD = "thumbnail_mime_type";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
@ -68,10 +65,10 @@ public class InlineQueryResultGif implements InlineQueryResult {
private Integer gifWidth; ///< Optional. Width of the GIF
@JsonProperty(GIFHEIGHT_FIELD)
private Integer gifHeight; ///< Optional. Height of the GIF
@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; ///< Optional. MIME type of the thumbnail, must be one of image/jpeg, image/gif, or video/mp4
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
@JsonProperty(THUMBNAIL_MIMETYPE_FIELD)
private String thumbnailMimeType; ///< Optional. MIME type of the thumbnail, must be one of image/jpeg, image/gif, or video/mp4
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(CAPTION_FIELD)
@ -90,13 +87,13 @@ public class InlineQueryResultGif implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (gifUrl == null || gifUrl.isEmpty()) {
if (gifUrl.isEmpty()) {
throw new TelegramApiValidationException("GifUrl parameter can't be empty", this);
}
if (thumbUrlType != null && !VALIDTHUMBTYPES.contains(thumbUrlType)) {
if (thumbnailMimeType != null && !VALIDTHUMBTYPES.contains(thumbnailMimeType)) {
throw new TelegramApiValidationException("ThumbUrlType parameter must be one of “image/jpeg”, “image/gif”, or “video/mp4”", this);
}
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
@ -109,4 +106,60 @@ public class InlineQueryResultGif implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrlType() {
return thumbnailMimeType;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrlType(String thumbUrlType) {
this.thumbnailMimeType = thumbUrlType;
}
public static class InlineQueryResultGifBuilder {
@Tolerate
@Deprecated
public InlineQueryResultGifBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultGifBuilder thumbUrlType(String thumbUrlType) {
this.thumbnailMimeType = thumbUrlType;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -12,6 +13,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -31,7 +33,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultLocation implements InlineQueryResult {
@ -43,9 +45,9 @@ public class InlineQueryResultLocation implements InlineQueryResult {
private static final String LONGITUDE_FIELD = "longitude";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_WIDTH_FIELD = "thumbnail_width";
private static final String THUMBNAUK_HEIGHT_FIELD = "thumbnail_height";
private static final String LIVEPERIOD_FIELD = "live_period";
private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
private static final String HEADING_FIELD = "heading";
@ -69,12 +71,12 @@ public class InlineQueryResultLocation implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBNAIL_WIDTH_FIELD)
private Integer thumbnailWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBNAUK_HEIGHT_FIELD)
private Integer thumbnailHeight; ///< Optional. Thumbnail height
@JsonProperty(LIVEPERIOD_FIELD)
private Integer livePeriod; ///< Optional. Period in seconds for which the location can be updated, should be between 60 and 86400.
/**
@ -100,18 +102,12 @@ public class InlineQueryResultLocation implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (livePeriod != null && (livePeriod < 60 || livePeriod > 86400)) {
throw new TelegramApiValidationException("Live period parameter must be between 60 and 86400", this);
}
@ -131,4 +127,82 @@ public class InlineQueryResultLocation implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailWidth()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbWidth() {
return thumbnailWidth;
}
/**
* @deprecated Use {{@link #setThumbnailWidth(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
}
/**
* @deprecated Use {{@link #getThumbnailHeight()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbHeight() {
return thumbnailHeight;
}
/**
* @deprecated Use {{@link #setThumbnailHeight(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
}
public static class InlineQueryResultLocationBuilder {
@Tolerate
@Deprecated
public InlineQueryResultLocationBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultLocationBuilder thumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultLocationBuilder thumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -33,7 +35,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
@ -43,7 +45,8 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
private static final String MPEG4URL_FIELD = "mpeg4_url";
private static final String MPEG4WIDTH_FIELD = "mpeg4_width";
private static final String MPEG4HEIGHT_FIELD = "mpeg4_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_MIMETYPE_FIELD = "thumbnail_mime_type";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
@ -64,8 +67,10 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
private Integer mpeg4Width; ///< Optional. Video width
@JsonProperty(MPEG4HEIGHT_FIELD)
private Integer mpeg4Height; ///< Optional. Video height
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the static thumbnail (jpeg or gif) for the result
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the static thumbnail (jpeg or gif) for the result
@JsonProperty(THUMBNAIL_MIMETYPE_FIELD)
private String thumbnailMimeType; ///< Optional. MIME type of the thumbnail, must be one of image/jpeg, image/gif, or video/mp4
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(CAPTION_FIELD)
@ -84,15 +89,18 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (mpeg4Url == null || mpeg4Url.isEmpty()) {
if (mpeg4Url.isEmpty()) {
throw new TelegramApiValidationException("Mpeg4Url parameter can't be empty", this);
}
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
}
if (thumbnailMimeType != null && !VALIDTHUMBTYPES.contains(thumbnailMimeType)) {
throw new TelegramApiValidationException("ThumbUrlType parameter must be one of “image/jpeg”, “image/gif”, or “video/mp4”", this);
}
if (inputMessageContent != null) {
inputMessageContent.validate();
}
@ -100,4 +108,32 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
public static class InlineQueryResultMpeg4GifBuilder {
@Tolerate
@Deprecated
public InlineQueryResultMpeg4GifBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
@ -12,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -32,7 +34,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultPhoto implements InlineQueryResult {
@ -42,7 +44,7 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
private static final String MIMETYPE_FIELD = "mime_type";
private static final String PHOTOWIDTH_FIELD = "photo_width";
private static final String PHOTOHEIGHT_FIELD = "photo_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
@ -65,8 +67,8 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
private Integer photoWidth; ///< Optional. Width of the photo
@JsonProperty(PHOTOHEIGHT_FIELD)
private Integer photoHeight; ///< Optional. Height of the photo
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail for the photo
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail for the photo
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DESCRIPTION_FIELD)
@ -85,10 +87,10 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (photoUrl == null || photoUrl.isEmpty()) {
if (photoUrl.isEmpty()) {
throw new TelegramApiValidationException("PhotoUrl parameter can't be empty", this);
}
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
@ -101,4 +103,33 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
public static class InlineQueryResultPhotoBuilder {
@Tolerate
@Deprecated
public InlineQueryResultPhotoBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -12,6 +13,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -30,7 +32,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultVenue implements InlineQueryResult {
@ -44,9 +46,9 @@ public class InlineQueryResultVenue implements InlineQueryResult {
private static final String FOURSQUAREID_FIELD = "foursquare_id";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String THUMBNAIL_URL_FIELD = "thumbnail_url";
private static final String THUMBNAIL_WIDTH_FIELD = "thumbnail_width";
private static final String THUMBNAUK_HEIGHT_FIELD = "thumbnail_height";
private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
@ -74,12 +76,12 @@ public class InlineQueryResultVenue implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(THUMBNAIL_URL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBNAIL_WIDTH_FIELD)
private Integer thumbnailWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBNAUK_HEIGHT_FIELD)
private Integer thumbnailHeight; ///< Optional. Thumbnail height
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
@JsonProperty(GOOGLEPLACEID_FIELD)
@ -89,19 +91,13 @@ public class InlineQueryResultVenue implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (address == null || address.isEmpty()) {
if (address.isEmpty()) {
throw new TelegramApiValidationException("Address parameter can't be empty", this);
}
if (inputMessageContent != null) {
@ -112,4 +108,82 @@ public class InlineQueryResultVenue implements InlineQueryResult {
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
/**
* @deprecated Use {{@link #getThumbnailWidth()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbWidth() {
return thumbnailWidth;
}
/**
* @deprecated Use {{@link #setThumbnailWidth(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
}
/**
* @deprecated Use {{@link #getThumbnailHeight()}}
*/
@JsonIgnore
@Deprecated
public Integer getThumbHeight() {
return thumbnailHeight;
}
/**
* @deprecated Use {{@link #setThumbnailHeight(Integer)}}
*/
@JsonIgnore
@Deprecated
public void setThumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
}
public static class InlineQueryResultVenueBuilder {
@Tolerate
@Deprecated
public InlineQueryResultVenueBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultVenueBuilder thumbHeight(Integer thumbHeight) {
this.thumbnailHeight = thumbHeight;
return this;
}
@Tolerate
@Deprecated
public InlineQueryResultVenueBuilder thumbWidth(Integer thumbWidth) {
this.thumbnailWidth = thumbWidth;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -33,7 +35,7 @@ import java.util.List;
@Setter
@ToString
@RequiredArgsConstructor
@NoArgsConstructor
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Builder
public class InlineQueryResultVideo implements InlineQueryResult {
@ -44,7 +46,7 @@ public class InlineQueryResultVideo implements InlineQueryResult {
private static final String VIDEOWIDTH_FIELD = "video_width";
private static final String VIDEOHEIGHT_FIELD = "video_height";
private static final String VIDEODURATION_FIELD = "video_duration";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBNAILURL_FIELD = "thumbnail_url";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
@ -70,8 +72,8 @@ public class InlineQueryResultVideo implements InlineQueryResult {
private Integer videoHeight; ///< Optional. Video height
@JsonProperty(VIDEODURATION_FIELD)
private Integer videoDuration; ///< Optional. Video duration in seconds
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video
@JsonProperty(THUMBNAILURL_FIELD)
private String thumbnailUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DESCRIPTION_FIELD)
@ -90,15 +92,18 @@ public class InlineQueryResultVideo implements InlineQueryResult {
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
if (id.isEmpty()) {
throw new TelegramApiValidationException("ID parameter can't be empty", this);
}
if (videoUrl == null || videoUrl.isEmpty()) {
if (videoUrl.isEmpty()) {
throw new TelegramApiValidationException("VideoUrl parameter can't be empty", this);
}
if (parseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
}
if (thumbnailUrl != null && !"image/jpeg".equalsIgnoreCase(thumbnailUrl)) {
throw new TelegramApiValidationException("Thumbnail Url must be JPEG", this);
}
if (inputMessageContent != null) {
inputMessageContent.validate();
}
@ -106,4 +111,33 @@ public class InlineQueryResultVideo implements InlineQueryResult {
replyMarkup.validate();
}
}
/**
* @deprecated Use {{@link #getThumbnailUrl()}}
*/
@JsonIgnore
@Deprecated
public String getThumbUrl() {
return thumbnailUrl;
}
/**
* @deprecated Use {{@link #setThumbnailUrl(String)}}
*/
@JsonIgnore
@Deprecated
public void setThumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
}
public static class InlineQueryResultVideoBuilder {
@Tolerate
@Deprecated
public InlineQueryResultVideoBuilder thumbUrl(String thumbUrl) {
this.thumbnailUrl = thumbUrl;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.media;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
@ -8,6 +9,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -34,7 +36,7 @@ public class InputMediaAnimation extends InputMedia {
public static final String WIDTH_FIELD = "width";
public static final String HEIGHT_FIELD = "height";
public static final String DURATION_FIELD = "duration";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
public static final String HASSPOILER_FIELD = "has_spoiler";
@JsonProperty(WIDTH_FIELD)
@ -50,7 +52,7 @@ public class InputMediaAnimation extends InputMedia {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
/**
* Optional.
* Pass True if the animation must be covered with a spoiler animation
@ -69,12 +71,12 @@ public class InputMediaAnimation extends InputMedia {
@Builder
public InputMediaAnimation(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities,
boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream,
Integer width, Integer height, Integer duration, InputFile thumb, Boolean hasSpoiler) {
Integer width, Integer height, Integer duration, InputFile thumbnail, Boolean hasSpoiler) {
super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream);
this.width = width;
this.height = height;
this.duration = duration;
this.thumb = thumb;
this.thumbnail = thumbnail;
this.hasSpoiler = hasSpoiler;
}
@ -87,4 +89,32 @@ public class InputMediaAnimation extends InputMedia {
public void validate() throws TelegramApiValidationException {
super.validate();
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class InputMediaAnimationBuilder {
@Tolerate
@Deprecated
public InputMediaAnimation.InputMediaAnimationBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.media;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
@ -8,6 +9,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -34,7 +36,7 @@ public class InputMediaAudio extends InputMedia {
public static final String DURATION_FIELD = "duration";
public static final String PERFORMER_FIELD = "performer";
public static final String TITLE_FIELD = "title";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
@JsonProperty(DURATION_FIELD)
private Integer duration; ///< Optional. Duration of the audio in seconds
@ -49,7 +51,7 @@ public class InputMediaAudio extends InputMedia {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
public InputMediaAudio() {
super();
@ -60,12 +62,14 @@ public class InputMediaAudio extends InputMedia {
}
@Builder
public InputMediaAudio(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, Integer duration, String performer, String title, InputFile thumb) {
public InputMediaAudio(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities,
boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream,
Integer duration, String performer, String title, InputFile thumbnail) {
super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream);
this.duration = duration;
this.performer = performer;
this.title = title;
this.thumb = thumb;
this.thumbnail = thumbnail;
}
@Override
@ -77,4 +81,32 @@ public class InputMediaAudio extends InputMedia {
public void validate() throws TelegramApiValidationException {
super.validate();
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class InputMediaAudioBuilder {
@Tolerate
@Deprecated
public InputMediaAudio.InputMediaAudioBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.media;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
@ -8,6 +9,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -31,7 +33,7 @@ import java.util.List;
public class InputMediaDocument extends InputMedia {
private static final String TYPE = "document";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
public static final String DISABLECONTENTTYPEDETECTION_FIELD = "disable_content_type_detection";
/**
@ -41,7 +43,7 @@ public class InputMediaDocument extends InputMedia {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
private InputFile thumb;
private InputFile thumbnail;
/**
* Optional.
* Disables automatic server-side content type detection for files uploaded using multipart/form-data.
@ -59,9 +61,11 @@ public class InputMediaDocument extends InputMedia {
}
@Builder
public InputMediaDocument(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, InputFile thumb, Boolean disableContentTypeDetection) {
public InputMediaDocument(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities,
boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, InputFile thumbnail,
Boolean disableContentTypeDetection) {
super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream);
this.thumb = thumb;
this.thumbnail = thumbnail;
this.disableContentTypeDetection = disableContentTypeDetection;
}
@ -74,4 +78,32 @@ public class InputMediaDocument extends InputMedia {
public void validate() throws TelegramApiValidationException {
super.validate();
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class InputMediaDocumentBuilder {
@Tolerate
@Deprecated
public InputMediaDocument.InputMediaDocumentBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.media;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
@ -8,6 +9,7 @@ import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -35,7 +37,7 @@ public class InputMediaVideo extends InputMedia {
public static final String HEIGHT_FIELD = "height";
public static final String DURATION_FIELD = "duration";
public static final String SUPPORTSSTREAMING_FIELD = "supports_streaming";
public static final String THUMB_FIELD = "thumb";
public static final String THUMBNAIL_FIELD = "thumbnail";
public static final String HASSPOILER_FIELD = "has_spoiler";
@JsonProperty(WIDTH_FIELD)
@ -53,8 +55,8 @@ public class InputMediaVideo extends InputMedia {
* Thumbnails cant be reused and can be only uploaded as a new file, so you can pass attach://<file_attach_name>
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
@JsonProperty(THUMB_FIELD)
private InputFile thumb;
@JsonProperty(THUMBNAIL_FIELD)
private InputFile thumbnail;
/**
* Optional.
* Pass True if the video must be covered with a spoiler animation
@ -72,14 +74,14 @@ public class InputMediaVideo extends InputMedia {
@Builder
public InputMediaVideo(@NonNull String media, String caption, String parseMode, List<MessageEntity> entities,
boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream,
Integer width, Integer height, Integer duration, Boolean supportsStreaming, InputFile thumb,
Integer width, Integer height, Integer duration, Boolean supportsStreaming, InputFile thumbnail,
Boolean hasSpoiler) {
super(media, caption, parseMode, entities, isNewMedia, mediaName, newMediaFile, newMediaStream);
this.width = width;
this.height = height;
this.duration = duration;
this.supportsStreaming = supportsStreaming;
this.thumb = thumb;
this.thumbnail = thumbnail;
this.hasSpoiler = hasSpoiler;
}
@ -92,4 +94,32 @@ public class InputMediaVideo extends InputMedia {
public void validate() throws TelegramApiValidationException {
super.validate();
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public InputFile getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(InputFile)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(InputFile thumb) {
this.thumbnail = thumb;
}
public static class InputMediaVideoBuilder {
@Tolerate
@Deprecated
public InputMediaVideo.InputMediaVideoBuilder thumb(InputFile thumb) {
this.thumbnail = thumb;
return this;
}
}
}

View File

@ -42,8 +42,8 @@ public class InputMediaSerializer extends JsonSerializer<InputMedia> {
if (value instanceof InputMediaAudio) {
InputMediaAudio audio = (InputMediaAudio) value;
if (audio.getThumb() != null) {
gen.writeStringField(InputMediaAudio.THUMB_FIELD, audio.getThumb().getAttachName());
if (audio.getThumbnail() != null) {
gen.writeStringField(InputMediaAudio.THUMBNAIL_FIELD, audio.getThumbnail().getAttachName());
}
if (audio.getDuration() != null) {
gen.writeNumberField(InputMediaAudio.DURATION_FIELD, audio.getDuration());
@ -56,8 +56,8 @@ public class InputMediaSerializer extends JsonSerializer<InputMedia> {
}
} else if (value instanceof InputMediaAnimation) {
InputMediaAnimation animation = (InputMediaAnimation) value;
if (animation.getThumb() != null) {
gen.writeStringField(InputMediaAnimation.THUMB_FIELD, animation.getThumb().getAttachName());
if (animation.getThumbnail() != null) {
gen.writeStringField(InputMediaAnimation.THUMBNAIL_FIELD, animation.getThumbnail().getAttachName());
}
if (animation.getDuration() != null) {
gen.writeNumberField(InputMediaAnimation.DURATION_FIELD, animation.getDuration());
@ -73,8 +73,8 @@ public class InputMediaSerializer extends JsonSerializer<InputMedia> {
}
} else if (value instanceof InputMediaDocument) {
InputMediaDocument document = (InputMediaDocument) value;
if (document.getThumb() != null) {
gen.writeStringField(InputMediaDocument.THUMB_FIELD, document.getThumb().getAttachName());
if (document.getThumbnail() != null) {
gen.writeStringField(InputMediaDocument.THUMBNAIL_FIELD, document.getThumbnail().getAttachName());
}
} else if (value instanceof InputMediaPhoto) {
InputMediaPhoto photo = (InputMediaPhoto) value;
@ -83,8 +83,8 @@ public class InputMediaSerializer extends JsonSerializer<InputMedia> {
}
} else if (value instanceof InputMediaVideo) {
InputMediaVideo video = (InputMediaVideo) value;
if (video.getThumb() != null) {
gen.writeStringField(InputMediaVideo.THUMB_FIELD, video.getThumb().getAttachName());
if (video.getThumbnail() != null) {
gen.writeStringField(InputMediaVideo.THUMBNAIL_FIELD, video.getThumbnail().getAttachName());
}
if (video.getDuration() != null) {
gen.writeNumberField(InputMediaVideo.DURATION_FIELD, video.getDuration());

View File

@ -0,0 +1,87 @@
package org.telegram.telegrambots.meta.api.objects.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.util.List;
/**
* @author Ruben Bermudez
* @version 6.6
*
* This object describes a sticker to be added to a sticker set.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor(force = true)
@AllArgsConstructor
public class InputSticker implements BotApiObject, Validable {
private static final String STICKER_FIELD = "sticker";
private static final String EMOJI_LIST_FIELD = "emoji_list";
private static final String MASK_POSITION_FIELD = "mask_position";
private static final String KEYWORDS_FIELD = "keywords";
/**
* The added sticker.
* 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.
* Animated and video stickers can't be uploaded via HTTP URL.
*/
@JsonProperty(STICKER_FIELD)
@NonNull
private InputFile sticker;
/**
* List of 1-20 emoji associated with the sticker
*/
@JsonProperty(EMOJI_LIST_FIELD)
@Singular
private List<String> emojiList;
/**
* Optional.
* Position where the mask should be placed on faces. For mask stickers only.
*/
@JsonProperty(MASK_POSITION_FIELD)
private MaskPosition maskPosition;
/**
* Optional.
* List of 0-20 search keywords for the sticker with total length of up to 64 characters.
* For regular and custom_emoji stickers only.
*/
@JsonProperty(KEYWORDS_FIELD)
@Singular
private List<String> keywords;
@Override
public void validate() throws TelegramApiValidationException {
if (emojiList.isEmpty() || emojiList.size() > 20) {
throw new TelegramApiValidationException("Emoji list must have between 1 and 20 items", this);
}
if (keywords.size() > 20) {
throw new TelegramApiValidationException("Keywords list must have between 0 and 20 items", this);
}
if (maskPosition != null) {
maskPosition.validate();
}
sticker.validate();
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.stickers;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -29,7 +30,7 @@ public class Sticker implements BotApiObject {
private static final String TYPE_FIELD = "type";
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String THUMB_FIELD = "thumb";
private static final String THUMBNAIL_FIELD = "thumbnail";
private static final String FILESIZE_FIELD = "file_size";
private static final String EMOJI_FIELD = "emoji";
private static final String SETNAME_FIELD = "set_name";
@ -38,6 +39,7 @@ public class Sticker implements BotApiObject {
private static final String ISVIDEO_FIELD = "is_video";
private static final String PREMIUMANIMATION_FIELD = "premium_animation";
private static final String CUSTOMEMOJIID_FIELD = "custom_emoji_id";
private static final String NEEDS_REPAINTING_FIELD = "needs_repainting";
/**
* Identifier for this file, which can be used to download or reuse the file
@ -70,8 +72,8 @@ public class Sticker implements BotApiObject {
* Optional.
* Sticker thumbnail in .webp or .jpg format
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
/**
* Optional.
* File size
@ -119,4 +121,29 @@ public class Sticker implements BotApiObject {
@JsonProperty(CUSTOMEMOJIID_FIELD)
private String customEmojiId;
/**.
* Optional.
* True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge
* in emoji status, white color on chat photos, or another appropriate color in other places
*/
@JsonProperty(NEEDS_REPAINTING_FIELD)
private Boolean needsRepainting;
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
/**
* @deprecated Use {{@link #setThumbnail(PhotoSize)}}
*/
@JsonIgnore
@Deprecated
public void setThumb(PhotoSize thumb) {
this.thumbnail = thumb;
}
}

View File

@ -1,5 +1,6 @@
package org.telegram.telegrambots.meta.api.objects.stickers;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@ -31,7 +32,7 @@ public class StickerSet implements BotApiObject {
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";
public static final String THUMBNAIL_FIELD = "thumbnail";
/**
* Type of stickers in the set, currently one of regular, mask, custom_emoji
@ -75,8 +76,8 @@ public class StickerSet implements BotApiObject {
* Optional.
* Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
*/
@JsonProperty(THUMB_FIELD)
private PhotoSize thumb;
@JsonProperty(THUMBNAIL_FIELD)
private PhotoSize thumbnail;
public boolean isRegularSticker() {
return "regular".equals(stickerType);
@ -88,4 +89,14 @@ public class StickerSet implements BotApiObject {
public boolean isCustomEmoji() {
return "custom_emoji".equals(stickerType);
}
/**
* @deprecated Use {{@link #getThumbnail()}}
*/
@JsonIgnore
@Deprecated
public PhotoSize getThumb() {
return thumbnail;
}
}

View File

@ -168,7 +168,7 @@ public class ChatMemberTest {
" \"can_pin_messages\": true,\n" +
" \"is_member\": true,\n" +
" \"can_send_messages\": true,\n" +
" \"can_send_media_messages\": true,\n" +
" \"can_send_audios\": true,\n" +
" \"can_send_polls\": true,\n" +
" \"can_send_other_messages\": true,\n" +
" \"can_add_web_page_previews\": true,\n" +
@ -183,7 +183,7 @@ public class ChatMemberTest {
assertEquals(true, chatMemberRestricted.getCanInviteUsers());
assertEquals(true, chatMemberRestricted.getCanPinMessages());
assertEquals(true, chatMemberRestricted.getCanSendMessages());
assertEquals(true, chatMemberRestricted.getCanSendMediaMessages());
assertEquals(true, chatMemberRestricted.getCanSendAudios());
assertEquals(true, chatMemberRestricted.getCanSendPolls());
assertEquals(true, chatMemberRestricted.getCanSendOtherMessages());
assertEquals(true, chatMemberRestricted.getCanAddWebpagePreviews());

View File

@ -58,10 +58,10 @@ class TestDeserialization {
"\"message\":{\"message_id\":91,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154306,\"text\":\"/start\",\"entities\":[{\"offset\":0,\"length\":6,\"type\":\"bot_command\"}]}},{\"update_id\":79995146,\n" +
"\"message\":{\"message_id\":92,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154313,\"text\":\"/test\",\"entities\":[{\"offset\":0,\"length\":5,\"type\":\"bot_command\"}]}},{\"update_id\":79995147,\n" +
"\"message\":{\"message_id\":93,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154318,\"text\":\"@aaaa\"}},{\"update_id\":79995148,\n" +
"\"message\":{\"message_id\":94,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154326,\"game\":{\"title\":\"Brick Stacker\",\"description\":\"Play the game to see how many bricks you can stack, and contribute to the tower!\",\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":12663,\"width\":320,\"height\":180},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":35050,\"width\":640,\"height\":360}],\"animation\":{\"file_name\":\"video.mp4\",\"mime_type\":\"video/mp4\",\"duration\":6,\"width\":320,\"height\":180,\"thumb\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":6209,\"width\":320,\"height\":180},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":411406}},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Play Brick Stacker!\",\"callback_game\":{}}]]},\"via_bot\":{\"id\":280713127,\"is_bot\":true,\"first_name\":\"Gamee\",\"username\":\"gamee\"}}},{\"update_id\":79995149,\n" +
"\"message\":{\"message_id\":94,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154326,\"game\":{\"title\":\"Brick Stacker\",\"description\":\"Play the game to see how many bricks you can stack, and contribute to the tower!\",\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":12663,\"width\":320,\"height\":180},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":35050,\"width\":640,\"height\":360}],\"animation\":{\"file_name\":\"video.mp4\",\"mime_type\":\"video/mp4\",\"duration\":6,\"width\":320,\"height\":180,\"thumbnail\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":6209,\"width\":320,\"height\":180},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":411406}},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Play Brick Stacker!\",\"callback_game\":{}}]]},\"via_bot\":{\"id\":280713127,\"is_bot\":true,\"first_name\":\"Gamee\",\"username\":\"gamee\"}}},{\"update_id\":79995149,\n" +
"\"message\":{\"message_id\":95,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154339,\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":8291,\"width\":320,\"height\":180},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":25998,\"width\":800,\"height\":450},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":38407,\"width\":1200,\"height\":675}],\"via_bot\":{\"id\":114528005,\"is_bot\":true,\"first_name\":\"Yandex Image Search\",\"username\":\"pic\"}}},{\"update_id\":79995150,\n" +
"\"message\":{\"message_id\":96,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154347,\"location\":{\"latitude\":34.76437,\"longitude\":0.001983}}},{\"update_id\":79995151,\n" +
"\"message\":{\"message_id\":97,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154360,\"video_note\":{\"duration\":3,\"length\":240,\"thumb\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":6852,\"width\":240,\"height\":240},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":100544}}},{\"update_id\":79995152,\n" +
"\"message\":{\"message_id\":97,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154360,\"video_note\":{\"duration\":3,\"length\":240,\"thumbnail\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":6852,\"width\":240,\"height\":240},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":100544}}},{\"update_id\":79995152,\n" +
"\"message\":{\"message_id\":98,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154363,\"voice\":{\"duration\":1,\"mime_type\":\"audio/ogg\",\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":5198}}},{\"update_id\":79995153,\n" +
"\"message\":{\"message_id\":99,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"it\"},\"chat\":{\"id\":12345678,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"type\":\"private\"},\"date\":1604154371,\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":14395,\"width\":180,\"height\":320},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":52852,\"width\":450,\"height\":800},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":84493,\"width\":720,\"height\":1280}]}},{\"update_id\":79995154,\n" +
"\"message\":{\"message_id\":6,\"from\":{\"id\":1234567,\"is_bot\":false,\"first_name\":\"MyFirstName\",\"username\":\"MyUsername\",\"language_code\":\"en\"},\"chat\":{\"id\":-1556359722345678,\"title\":\"test group\",\"type\":\"supergroup\"},\"date\":1604163105,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing\",\"username\":\"TestingBot\"}]}}]}";
@ -116,7 +116,7 @@ class TestDeserialization {
"\"message\":{\"message_id\":109,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281720,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}]}},{\"update_id\":259894307,\n" +
"\"message\":{\"message_id\":110,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281763,\"migrate_to_chat_id\":-10011869112345}},{\"update_id\":259894308,\n" +
"\"message\":{\"message_id\":1,\"from\":{\"id\":12345678,\"is_bot\":true,\"first_name\":\"Group\",\"username\":\"GroupAnonymousBot\"},\"sender_chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281763,\"migrate_from_chat_id\":-10011869112345}},{\"update_id\":259894309,\n" +
"\"message\":{\"message_id\":2,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281985,\"sticker\":{\"width\":512,\"height\":512,\"emoji\":\"\\ud83e\\udd2c\",\"set_name\":\"ShadowKitty\",\"is_animated\":true,\"thumb\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":7546,\"width\":128,\"height\":128},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":13187}}},{\"update_id\":259894310,\n" +
"\"message\":{\"message_id\":2,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281985,\"sticker\":{\"width\":512,\"height\":512,\"emoji\":\"\\ud83e\\udd2c\",\"set_name\":\"ShadowKitty\",\"is_animated\":true,\"thumbnail\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":7546,\"width\":128,\"height\":128},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":13187}}},{\"update_id\":259894310,\n" +
"\"message\":{\"message_id\":3,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281993,\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"AQADL3I6J10AAzbcAQAB\",\"file_size\":15207,\"width\":148,\"height\":320},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":64579,\"width\":369,\"height\":800},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":93424,\"width\":591,\"height\":1280}]}},{\"update_id\":259894311,\n" +
"\"message\":{\"message_id\":4,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604282015,\"poll\":{\"id\":\"5834976086823272454\",\"question\":\"My test poll\",\"options\":[{\"text\":\"No option\",\"voter_count\":0},{\"text\":\"Yes option\",\"voter_count\":0}],\"total_voter_count\":0,\"is_closed\":false,\"is_anonymous\":true,\"type\":\"quiz\",\"allows_multiple_answers\":false}}},{\"update_id\":259894312,\n" +
"\"message\":{\"message_id\":5,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604282029,\"contact\":{\"phone_number\":\"618490765\",\"first_name\":\"FirstName\",\"last_name\":\"LASNAME\",\"vcard\":\"BEGIN:VCARD \\nVERSION:3.0\"}}},{\"update_id\":259894313,\n" +
@ -310,7 +310,7 @@ class TestDeserialization {
" \"status\": \"restricted\",\n" +
" \"until_date\": 0,\n" +
" \"can_send_messages\": false,\n" +
" \"can_send_media_messages\": false,\n" +
" \"can_send_audios\": false,\n" +
" \"can_send_polls\": false,\n" +
" \"can_send_other_messages\": false,\n" +
" \"can_add_web_page_previews\": false,\n" +
@ -334,7 +334,7 @@ class TestDeserialization {
assertEquals("restricted", chatMemberRestricted.getStatus());
assertEquals(0, chatMemberRestricted.getUntilDate());
assertFalse(chatMemberRestricted.getCanSendMessages());
assertFalse(chatMemberRestricted.getCanSendMediaMessages());
assertFalse(chatMemberRestricted.getCanSendAudios());
assertFalse(chatMemberRestricted.getCanSendPolls());
assertFalse(chatMemberRestricted.getCanSendOtherMessages());
assertFalse(chatMemberRestricted.getCanAddWebpagePreviews());

View File

@ -2,13 +2,17 @@ package org.telegram.telegrambots.meta.test;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.Data;
import org.junit.jupiter.api.Test;
import org.telegram.telegrambots.meta.api.methods.AnswerInlineQuery;
import org.telegram.telegrambots.meta.api.methods.send.SendLocation;
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputLocationMessageContent;
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResultArticle;
import java.time.OffsetTime;
import java.time.ZoneOffset;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -17,9 +21,33 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
* @version 1.0
*/
public class TestSerialization {
private ObjectMapper mapper;
private ObjectMapper mapper = new ObjectMapper();
@BeforeEach
static {
System.setProperty("user.timezone", "EST");
}
@Data
public static class MyClass {
public OffsetTime time;
}
@Test
public void test() throws JsonProcessingException {
String time = "{\"time\":\"14:30Z\"}";
mapper.registerModule(new JavaTimeModule());
OffsetTime now = OffsetTime.now().withHour(9).withMinute(0).withNano(0).withSecond(0);
OffsetTime myTime = mapper.readValue(time, MyClass.class).time;
System.err.println("Time: " + myTime.withOffsetSameInstant(ZoneOffset.UTC));
System.err.println("Now: " + now.withOffsetSameInstant(ZoneOffset.UTC));
// ahora antes que valor
System.err.println(now.isBefore(myTime));
}
//@BeforeEach
void setUp() {
mapper = new ObjectMapper();
}

View File

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

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>6.5.0</version>
<version>6.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>6.5.0</telegrambots.version>
<telegrambots.version>6.6.0</telegrambots.version>
<spring-boot.version>2.7.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>6.5.0</version>
<version>6.6.0</version>
</parent>
<artifactId>telegrambots</artifactId>
@ -91,7 +91,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

View File

@ -38,6 +38,7 @@ import org.telegram.telegrambots.meta.api.objects.media.InputMediaAnimation;
import org.telegram.telegrambots.meta.api.objects.media.InputMediaAudio;
import org.telegram.telegrambots.meta.api.objects.media.InputMediaDocument;
import org.telegram.telegrambots.meta.api.objects.media.InputMediaVideo;
import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker;
import org.telegram.telegrambots.meta.bots.AbsSender;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -50,6 +51,7 @@ import java.io.InputStream;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
@ -62,7 +64,7 @@ import static org.telegram.telegrambots.Constants.SOCKET_TIMEOUT;
* @version 1.0
* Implementation of all the methods needed to interact with Telegram Servers
*/
@SuppressWarnings({"unused"})
@SuppressWarnings({"unused", "SameParameterValue"})
@Slf4j
public abstract class DefaultAbsSender extends AbsSender {
private static final ContentType TEXT_PLAIN_CONTENT_TYPE = ContentType.create("text/plain", StandardCharsets.UTF_8);
@ -208,9 +210,9 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.addTextBody(SendDocument.CAPTION_ENTITIES_FIELD, objectMapper.writeValueAsString(sendDocument.getCaptionEntities()), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendDocument.getThumb() != null) {
addInputFile(builder, sendDocument.getThumb(), SendDocument.THUMB_FIELD, false);
builder.addTextBody(SendDocument.THUMB_FIELD, sendDocument.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
if (sendDocument.getThumbnail() != null) {
addInputFile(builder, sendDocument.getThumbnail(), SendDocument.THUMBNAIL_FIELD, false);
builder.addTextBody(SendDocument.THUMBNAIL_FIELD, sendDocument.getThumbnail().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
}
HttpEntity multipart = builder.build();
@ -324,9 +326,9 @@ public abstract class DefaultAbsSender extends AbsSender {
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);
if (sendVideo.getThumbnail() != null) {
addInputFile(builder, sendVideo.getThumbnail(), SendVideo.THUMBNAIL_FIELD, false);
builder.addTextBody(SendVideo.THUMBNAIL_FIELD, sendVideo.getThumbnail().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideo.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendVideo.ALLOWSENDINGWITHOUTREPLY_FIELD, sendVideo.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -383,9 +385,9 @@ public abstract class DefaultAbsSender extends AbsSender {
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);
if (sendVideoNote.getThumbnail() != null) {
addInputFile(builder, sendVideoNote.getThumbnail(), SendVideoNote.THUMBNAIL_FIELD, false);
builder.addTextBody(SendVideoNote.THUMBNAIL_FIELD, sendVideoNote.getThumbnail().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideoNote.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendVideoNote.ALLOWSENDINGWITHOUTREPLY_FIELD, sendVideoNote.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -433,6 +435,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendSticker.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendSticker.ALLOWSENDINGWITHOUTREPLY_FIELD, sendSticker.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendSticker.getEmoji() != null) {
builder.addTextBody(SendSticker.EMOJI_FIELD, sendSticker.getEmoji(), TEXT_PLAIN_CONTENT_TYPE);
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -443,9 +448,9 @@ public abstract class DefaultAbsSender extends AbsSender {
}
/**
* Sends a file using Send Audio method (https://core.telegram.org/bots/api#sendaudio)
* Sends a file using Send Audio method (<a href="https://core.telegram.org/bots/api#sendaudio">sendAudio</a>)
* @param sendAudio Information to send
* @return If success, the sent Message is returned
* @return If success, the Message sent is returned
* @throws TelegramApiException If there is any error sending the audio
*/
@Override
@ -488,9 +493,9 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.addTextBody(SendAudio.PARSEMODE_FIELD, sendAudio.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
if (sendAudio.getThumb() != null) {
addInputFile(builder, sendAudio.getThumb(), SendAudio.THUMB_FIELD, false);
builder.addTextBody(SendAudio.THUMB_FIELD, sendAudio.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
if (sendAudio.getThumbnail() != null) {
addInputFile(builder, sendAudio.getThumbnail(), SendAudio.THUMBNAIL_FIELD, false);
builder.addTextBody(SendAudio.THUMBNAIL_FIELD, sendAudio.getThumbnail().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAudio.getAllowSendingWithoutReply() != null) {
builder.addTextBody(SendAudio.ALLOWSENDINGWITHOUTREPLY_FIELD, sendAudio.getAllowSendingWithoutReply().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -513,10 +518,10 @@ public abstract class DefaultAbsSender extends AbsSender {
}
/**
* Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice)
* Sends a voice note using Send Voice method (<a href="https://core.telegram.org/bots/api#sendvoice">sendVoice</a>)
* For this to work, your audio must be in an .ogg file encoded with OPUS
* @param sendVoice Information to send
* @return If success, the sent Message is returned
* @return If success, the Message sent is returned
* @throws TelegramApiException If there is any error sending the audio
*/
@Override
@ -584,13 +589,11 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.setLaxMode();
builder.setCharset(StandardCharsets.UTF_8);
builder.addTextBody(SetChatPhoto.CHATID_FIELD, setChatPhoto.getChatId(), TEXT_PLAIN_CONTENT_TYPE);
if (setChatPhoto.getPhoto() != null) {
InputFile photo = setChatPhoto.getPhoto();
if (photo.getNewMediaFile() != null) {
builder.addBinaryBody(SetChatPhoto.PHOTO_FIELD, photo.getNewMediaFile());
} else if (photo.getNewMediaStream() != null) {
builder.addBinaryBody(SetChatPhoto.PHOTO_FIELD, photo.getNewMediaStream(), ContentType.APPLICATION_OCTET_STREAM, photo.getMediaName());
}
InputFile photo = setChatPhoto.getPhoto();
if (photo.getNewMediaFile() != null) {
builder.addBinaryBody(SetChatPhoto.PHOTO_FIELD, photo.getNewMediaFile());
} else if (photo.getNewMediaStream() != null) {
builder.addBinaryBody(SetChatPhoto.PHOTO_FIELD, photo.getNewMediaStream(), ContentType.APPLICATION_OCTET_STREAM, photo.getMediaName());
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -655,17 +658,23 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.setCharset(StandardCharsets.UTF_8);
builder.addTextBody(AddStickerToSet.USERID_FIELD, addStickerToSet.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(AddStickerToSet.NAME_FIELD, addStickerToSet.getName(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
if (addStickerToSet.getPngSticker() != null) {
addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
} 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) {
builder.addTextBody(AddStickerToSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(addStickerToSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE);
if (addStickerToSet.getSticker() != null) {
addStickers(builder, Collections.singletonList(addStickerToSet.getSticker()), AddStickerToSet.STICKER_FIELD);
} else {
// Support Deprecated
builder.addTextBody(AddStickerToSet.EMOJIS_FIELD, addStickerToSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
if (addStickerToSet.getPngSticker() != null) {
addInputFile(builder, addStickerToSet.getPngSticker(), AddStickerToSet.PNGSTICKER_FIELD, true);
} 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) {
builder.addTextBody(AddStickerToSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(addStickerToSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE);
}
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -713,8 +722,17 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.addTextBody(CreateNewStickerSet.USERID_FIELD, createNewStickerSet.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(CreateNewStickerSet.NAME_FIELD, createNewStickerSet.getName(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(CreateNewStickerSet.TITLE_FIELD, createNewStickerSet.getTitle(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(CreateNewStickerSet.EMOJIS_FIELD, createNewStickerSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(CreateNewStickerSet.STICKER_FORMAT_FIELD, createNewStickerSet.getStickerFormat(), TEXT_PLAIN_CONTENT_TYPE);
builder.addTextBody(CreateNewStickerSet.STICKERTYPE_FIELD, createNewStickerSet.getStickerType(), TEXT_PLAIN_CONTENT_TYPE);
if (createNewStickerSet.getNeedsRepainting() != null) {
builder.addTextBody(CreateNewStickerSet.NEEDS_REPAINTING_FIELD, createNewStickerSet.getNeedsRepainting().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (!createNewStickerSet.getStickers().isEmpty()) {
addStickers(builder, createNewStickerSet.getStickers(), CreateNewStickerSet.STICKERS_FIELD);
}
// Support Deprecated
builder.addTextBody(CreateNewStickerSet.EMOJIS_FIELD, createNewStickerSet.getEmojis(), TEXT_PLAIN_CONTENT_TYPE);
if (createNewStickerSet.getPngSticker() != null) {
addInputFile(builder, createNewStickerSet.getPngSticker(), CreateNewStickerSet.PNGSTICKER_FIELD, true);
} else if (createNewStickerSet.getTgsSticker() != null) {
@ -722,10 +740,10 @@ public abstract class DefaultAbsSender extends AbsSender {
} else {
addInputFile(builder, createNewStickerSet.getWebmSticker(), CreateNewStickerSet.WEBMSTICKER_FIELD, true);
}
if (createNewStickerSet.getMaskPosition() != null) {
builder.addTextBody(CreateNewStickerSet.MASKPOSITION_FIELD, objectMapper.writeValueAsString(createNewStickerSet.getMaskPosition()), TEXT_PLAIN_CONTENT_TYPE);
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -746,7 +764,8 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.setLaxMode();
builder.setCharset(StandardCharsets.UTF_8);
builder.addTextBody(UploadStickerFile.USERID_FIELD, uploadStickerFile.getUserId().toString(), TEXT_PLAIN_CONTENT_TYPE);
addInputFile(builder, uploadStickerFile.getPngSticker(), UploadStickerFile.PNGSTICKER_FIELD, true);
builder.addTextBody(UploadStickerFile.STICKER_FORMAT_FIELD, uploadStickerFile.getStickerFormat(), TEXT_PLAIN_CONTENT_TYPE);
addInputFile(builder, uploadStickerFile.getSticker(), UploadStickerFile.STICKER_FIELD, true);
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -822,9 +841,9 @@ public abstract class DefaultAbsSender extends AbsSender {
if (sendAnimation.getHeight() != null) {
builder.addTextBody(SendAnimation.HEIGHT_FIELD, sendAnimation.getHeight().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAnimation.getThumb() != null) {
addInputFile(builder, sendAnimation.getThumb(), SendAnimation.THUMB_FIELD, false);
builder.addTextBody(SendAnimation.THUMB_FIELD, sendAnimation.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
if (sendAnimation.getThumbnail() != null) {
addInputFile(builder, sendAnimation.getThumbnail(), SendAnimation.THUMBNAIL_FIELD, false);
builder.addTextBody(SendAnimation.THUMBNAIL_FIELD, sendAnimation.getThumbnail().getAttachName(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendAnimation.getCaption() != null) {
@ -1104,8 +1123,8 @@ public abstract class DefaultAbsSender extends AbsSender {
private void configureHttpContext() {
if (options.getProxyType() != DefaultBotOptions.ProxyType.NO_PROXY) {
InetSocketAddress socksaddr = new InetSocketAddress(options.getProxyHost(), options.getProxyPort());
options.getHttpContext().setAttribute("socketAddress", socksaddr);
InetSocketAddress socketAddress = new InetSocketAddress(options.getProxyHost(), options.getProxyPort());
options.getHttpContext().setAttribute("socketAddress", socketAddress);
}
if (options.getProxyType() == DefaultBotOptions.ProxyType.SOCKS4) {
@ -1149,23 +1168,23 @@ public abstract class DefaultAbsSender extends AbsSender {
if (media instanceof InputMediaAudio) {
InputMediaAudio audio = (InputMediaAudio) media;
if (audio.getThumb() != null) {
addInputFile(builder, audio.getThumb(), InputMediaAudio.THUMB_FIELD, false);
if (audio.getThumbnail() != null) {
addInputFile(builder, audio.getThumbnail(), InputMediaAudio.THUMBNAIL_FIELD, false);
}
} else if (media instanceof InputMediaDocument) {
InputMediaDocument document = (InputMediaDocument) media;
if (document.getThumb() != null) {
addInputFile(builder, document.getThumb(), InputMediaDocument.THUMB_FIELD, false);
if (document.getThumbnail() != null) {
addInputFile(builder, document.getThumbnail(), InputMediaDocument.THUMBNAIL_FIELD, false);
}
} else if (media instanceof InputMediaVideo) {
InputMediaVideo video = (InputMediaVideo) media;
if (video.getThumb() != null) {
addInputFile(builder, video.getThumb(), InputMediaVideo.THUMB_FIELD, false);
if (video.getThumbnail() != null) {
addInputFile(builder, video.getThumbnail(), InputMediaVideo.THUMBNAIL_FIELD, false);
}
} else if (media instanceof InputMediaAnimation) {
InputMediaAnimation animation = (InputMediaAnimation) media;
if (animation.getThumb() != null) {
addInputFile(builder, animation.getThumb(), InputMediaAnimation.THUMB_FIELD, false);
if (animation.getThumbnail() != null) {
addInputFile(builder, animation.getThumbnail(), InputMediaAnimation.THUMBNAIL_FIELD, false);
}
}
@ -1182,6 +1201,14 @@ public abstract class DefaultAbsSender extends AbsSender {
builder.addTextBody(mediaField, objectMapper.writeValueAsString(media), TEXT_PLAIN_CONTENT_TYPE);
}
private void addStickers(MultipartEntityBuilder builder, List<InputSticker> stickers, String stickersField) throws JsonProcessingException {
for (InputSticker sticker : stickers) {
addInputFile(builder, sticker.getSticker(), null, false);
}
builder.addTextBody(stickersField, objectMapper.writeValueAsString(stickers), TEXT_PLAIN_CONTENT_TYPE);
}
private void addInputFile(MultipartEntityBuilder builder, InputFile file, String fileField, boolean addField) {
if (file.isNew()) {
if (file.getNewMediaFile() != null) {

View File

@ -15,7 +15,7 @@ public abstract class TelegramLongPollingBot extends DefaultAbsSender implements
* If this is used getBotToken has to be overridden in order to return the bot token!
* @deprecated Overwriting the getBotToken() method is deprecated. Use the constructor instead
*/
@Deprecated()
@Deprecated
public TelegramLongPollingBot() {
this(new DefaultBotOptions());
}
@ -24,7 +24,7 @@ public abstract class TelegramLongPollingBot extends DefaultAbsSender implements
* If this is used getBotToken has to be overridden in order to return the bot token!
* @deprecated Overwriting the getBotToken() method is deprecated. Use the constructor instead
*/
@Deprecated()
@Deprecated
public TelegramLongPollingBot(DefaultBotOptions options) {
super(options);
}

View File

@ -258,9 +258,9 @@ public final class BotApiMethodHelperFactory {
.url("Url")
.hideUrl(false)
.description("Description")
.thumbUrl("ThumbUrl")
.thumbWidth(10)
.thumbHeight(20)
.thumbnailUrl("ThumbUrl")
.thumbnailWidth(10)
.thumbnailHeight(20)
.inputMessageContent(getInputMessageContent())
.replyMarkup(getInlineKeyboardMarkup())
.build();
@ -274,7 +274,7 @@ public final class BotApiMethodHelperFactory {
.photoWidth(10)
.photoHeight(20)
.mimeType("image/jpg")
.thumbUrl("ThumbUrl")
.thumbnailUrl("ThumbUrl")
.title("Title")
.description("Description")
.caption("Caption")

View File

@ -54,7 +54,7 @@ public class ServerlessWebhookTest {
BotApiMethod<?> result = serverlessWebhook.updateReceived(webhookBot.getBotPath(), getUpdate());
assertEquals("{\"inline_query_id\":\"id\",\"results\":[{\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumb_url\":\"ThumbUrl\",\"thumb_width\":10,\"thumb_height\":20},{\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumb_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"caption_entities\":[]}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}",
assertEquals("{\"inline_query_id\":\"id\",\"results\":[{\"type\":\"article\",\"id\":\"0\",\"title\":\"Title\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"url\":\"Url\",\"hide_url\":false,\"description\":\"Description\",\"thumbnail_url\":\"ThumbUrl\",\"thumbnail_width\":10,\"thumbnail_height\":20},{\"type\":\"photo\",\"id\":\"1\",\"photo_url\":\"PhotoUrl\",\"mime_type\":\"image/jpg\",\"photo_width\":10,\"photo_height\":20,\"thumbnail_url\":\"ThumbUrl\",\"title\":\"Title\",\"description\":\"Description\",\"caption\":\"Caption\",\"input_message_content\":{\"message_text\":\"Text\",\"parse_mode\":\"Markdown\"},\"reply_markup\":{\"inline_keyboard\":[[{\"text\":\"Button1\",\"callback_data\":\"Callback\"}]]},\"caption_entities\":[]}],\"cache_time\":100,\"is_personal\":true,\"next_offset\":\"3\",\"switch_pm_text\":\"pmText\",\"switch_pm_parameter\":\"PmParameter\",\"method\":\"answerInlineQuery\"}",
map(result));
}