diff --git a/README.md b/README.md index 30a50ce2..d9a7d39b 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,18 @@ Just import add the library to your project with one of these options: org.telegram telegrambots - 6.5.0 + 6.8.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambots:6.5.0' + implementation 'org.telegram:telegrambots:6.8.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.8.0) + 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.8.0) In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`. diff --git a/TelegramBots.wiki/Changelog.md b/TelegramBots.wiki/Changelog.md index 56ab80f3..631d2a56 100644 --- a/TelegramBots.wiki/Changelog.md +++ b/TelegramBots.wiki/Changelog.md @@ -1,4 +1,16 @@ -### 6.4.0 ### +### 6.8.0 ### +1. Update Api version [6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) +2. Fix #1254 + +### 6.7.0 ### +1. Update Api version [6.7](https://core.telegram.org/bots/api-changelog#april-21-2023) + +**[[How to update to version 6.7.0|How-To-Update#6.7.0]]** + +### 6.6.0 ### +1. Update Api version [6.6](https://core.telegram.org/bots/api-changelog#march-9-2023) + +### 6.5.0 ### 1. Update Api version [6.5](https://core.telegram.org/bots/api-changelog#february-3-2023) ### 6.4.0 ### diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md index cab5cdb7..9b19c2d0 100644 --- a/TelegramBots.wiki/Getting-Started.md +++ b/TelegramBots.wiki/Getting-Started.md @@ -11,13 +11,13 @@ First you need to acquire the library and add it to your project. There are seve org.telegram telegrambots - 6.5.0 + 6.8.0 ``` * With **Gradle**: ```gradle - implementation 'org.telegram:telegrambots:6.5.0' + implementation 'org.telegram:telegrambots:6.8.0' ``` 2. Don't like the **Maven Central Repository**? It can also be grabbed from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots). diff --git a/TelegramBots.wiki/How-To-Update.md b/TelegramBots.wiki/How-To-Update.md index edff83fd..3a10b2e7 100644 --- a/TelegramBots.wiki/How-To-Update.md +++ b/TelegramBots.wiki/How-To-Update.md @@ -1,3 +1,10 @@ +### To version 6.8.0 ### +1. Api methods with thumbnails have changed the field, use getThumbnail()/setThumbnail() instead of getThumb()/setThumb() +2. In `AddStickerToSet`/`CreateNewStickerSet`/`UploadStickerFile`/etc, use field `sticker` instead of the deprecated fields. +3. `ChatMember` has more details permissions, use those instead of the legacy general ones. +4. All classes with mandatory fields will lose the default no-arg constructor in the future. +5. In `AnswerInlineQuery`, start using the `button` field instead of deprecated parameters. + ### To version 6.1.0 ### 1. As per API guidelines, FileSize can now have 64 bits size, hence they are now using Long datatype instead of Integer. 2. Methods accept chatId as Long or String. diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md index c5d46c78..f1e796e5 100644 --- a/TelegramBots.wiki/abilities/Simple-Example.md +++ b/TelegramBots.wiki/abilities/Simple-Example.md @@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies. org.telegram telegrambots-abilities - 6.5.0 + 6.8.0 ``` * **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.5.0' + implementation 'org.telegram:telegrambots-abilities:6.8.0' ``` * [JitPack](https://jitpack.io/#rubenlagus/TelegramBots) diff --git a/pom.xml b/pom.xml index 02c89496..3b489515 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.warp bots pom - 6.5.0 + 6.8.0 telegrambots @@ -72,12 +72,12 @@ 5.9.1 4.8.1 4.8.1 - 2.14.0 - 2.14.0 + 2.14.2 + 2.14.2 2.0.3 2.1.1 - 1.18.24 - 31.1-jre + 1.18.28 + 32.0.0-jre 3.12.0 diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md index c2c5d439..fa315de8 100644 --- a/telegrambots-abilities/README.md +++ b/telegrambots-abilities/README.md @@ -18,14 +18,14 @@ Usage org.telegram telegrambots-abilities - 6.5.0 + 6.8.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-abilities:6.5.0' + implementation 'org.telegram:telegrambots-abilities:6.8.0' ``` **JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1) diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml index e0e069eb..eeccbfee 100644 --- a/telegrambots-abilities/pom.xml +++ b/telegrambots-abilities/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambots-abilities @@ -86,7 +86,7 @@ org.warp telegrambots - 6.5.0 + 6.8.0 org.apache.commons diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java index ef74a500..c7e6118d 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java @@ -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); diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Flag.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Flag.java index 8b2303b5..37fd8fc7 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Flag.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Flag.java @@ -3,7 +3,7 @@ package org.telegram.abilitybots.api.objects; import org.telegram.abilitybots.api.objects.Ability.AbilityBuilder; import org.telegram.telegrambots.meta.api.objects.Update; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.function.Predicate; import static java.util.Objects.nonNull; @@ -11,7 +11,7 @@ import static java.util.Objects.nonNull; /** * Flags are an conditions that are applied on an {@link Update}. *

- * They can be used on {@link AbilityBuilder#flag(Predicate[])} and on the post conditions in {@link AbilityBuilder#reply(Consumer, Predicate[])}. + * They can be used on {@link AbilityBuilder#flag(Predicate[])} and on the post conditions in {@link AbilityBuilder#reply(BiConsumer, Predicate[])}. * * @author Abbas Abou Daya */ diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java index 8ba939ab..3cbb47d0 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Objects; import java.util.function.BiConsumer; import java.util.function.BiFunction; -import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; @@ -18,7 +17,7 @@ import static com.google.common.collect.Lists.newArrayList; /** * A reply consists of update conditionals and an action to be applied on the update. *

- * If an update satisfies the {@link Reply#conditions} set by the reply, then it's safe to {@link Reply#actOn(Update)}. + * If an update satisfies the {@link Reply#conditions} set by the reply, then it's safe to {@link Reply#actOn(BaseAbilityBot, Update)}. * * @author Abbas Abou Daya */ diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java index d2148464..8eeda9e4 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; -import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java index 95a049e5..b3ba74bc 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java +++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java @@ -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; diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/sender/SilentSenderTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/sender/SilentSenderTest.java index 884cf72d..219fbea4 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/sender/SilentSenderTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/sender/SilentSenderTest.java @@ -14,7 +14,10 @@ import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.only; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; class SilentSenderTest { private SilentSender silent; @@ -55,7 +58,7 @@ class SilentSenderTest { verify(sender, only()).executeAsync(methodObject, callback); } - private class NoOpCallback implements SentCallback { + private static class NoOpCallback implements SentCallback { @Override public void onResult(BotApiMethod method, Message response) { @@ -72,6 +75,4 @@ class SilentSenderTest { } } - - ; } \ No newline at end of file diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/toggle/CustomToggleTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/toggle/CustomToggleTest.java index e2b131f3..5ae9a0d1 100644 --- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/toggle/CustomToggleTest.java +++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/toggle/CustomToggleTest.java @@ -7,12 +7,14 @@ import org.telegram.abilitybots.api.bot.DefaultAbilities; import org.telegram.abilitybots.api.bot.DefaultBot; import org.telegram.abilitybots.api.db.DBContext; -import java.io.FileInputStream; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; import static org.apache.commons.lang3.StringUtils.EMPTY; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.telegram.abilitybots.api.db.MapDBContext.offlineInstance; class CustomToggleTest { @@ -55,7 +57,7 @@ class CustomToggleTest { public void canTurnOffAbilitiesThroughProperties() { Properties properties = new Properties(); try { - properties.load(new FileInputStream(filename)); + properties.load(Files.newInputStream(Paths.get(filename))); toggle = new CustomToggle().config(properties); } catch (IOException e) { System.out.println("No such file"); @@ -71,7 +73,7 @@ class CustomToggleTest { public void canProcessAbilitiesThroughProperties() { Properties properties = new Properties(); try { - properties.load(new FileInputStream(filename)); + properties.load(Files.newInputStream(Paths.get(filename))); toggle = new CustomToggle().config(properties); } catch (IOException e) { System.out.println("No such file"); diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md index debf98e8..db497f32 100644 --- a/telegrambots-chat-session-bot/README.md +++ b/telegrambots-chat-session-bot/README.md @@ -15,14 +15,14 @@ Usage org.telegram telegrambots-chat-session-bot - 6.5.0 + 6.8.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-chat-session-bot:6.5.0' + implementation 'org.telegram:telegrambots-chat-session-bot:6.8.0' ``` Motivation diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml index 1c5641b8..b9840120 100644 --- a/telegrambots-chat-session-bot/pom.xml +++ b/telegrambots-chat-session-bot/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambots-chat-session-bot @@ -86,7 +86,7 @@ org.warp telegrambots - 6.5.0 + 6.8.0 diff --git a/telegrambots-chat-session-bot/src/main/java/org/telegram/telegrambots/session/DefaultChatIdConverter.java b/telegrambots-chat-session-bot/src/main/java/org/telegram/telegrambots/session/DefaultChatIdConverter.java index 5e5dd571..726ab4ff 100644 --- a/telegrambots-chat-session-bot/src/main/java/org/telegram/telegrambots/session/DefaultChatIdConverter.java +++ b/telegrambots-chat-session-bot/src/main/java/org/telegram/telegrambots/session/DefaultChatIdConverter.java @@ -20,7 +20,7 @@ public class DefaultChatIdConverter implements ChatIdConverter { @Override public void setSessionId(Serializable sessionId){ this.sessionId = (long) sessionId; - }; + } @Override public Serializable getSessionId() { diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md index 3c3a33a2..3cdcae43 100644 --- a/telegrambots-extensions/README.md +++ b/telegrambots-extensions/README.md @@ -16,12 +16,12 @@ Just import add the library to your project with one of these options: org.telegram telegrambotsextensions - 6.5.0 + 6.8.0 ``` 2. Using Gradle: ```gradle - implementation 'org.telegram:telegrambotsextensions:6.5.0' + implementation 'org.telegram:telegrambotsextensions:6.8.0' ``` \ No newline at end of file diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml index bfcb5360..6e587693 100644 --- a/telegrambots-extensions/pom.xml +++ b/telegrambots-extensions/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambotsextensions @@ -77,7 +77,7 @@ org.warp telegrambots - 6.5.0 + 6.8.0 diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java index d55a4fe4..d3644316 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java @@ -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()) { diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java index cddf610a..a2f0bc81 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java @@ -42,7 +42,7 @@ public class HelpCommand extends ManCommand { * @return a formatted String containing command and description for all supplied commands */ public static String getHelpText(Collection botCommands) { - return getHelpText(botCommands.toArray(new IBotCommand[botCommands.size()])); + return getHelpText(botCommands.toArray(new IBotCommand[0])); } /** diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml index 7e831097..1ba6d436 100644 --- a/telegrambots-meta/pom.xml +++ b/telegrambots-meta/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambots-meta @@ -97,6 +97,13 @@ lombok provided + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.14.2 + + diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java index 8109182a..ab87c0d4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBool @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java index 73c6429e..bd7af115 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java @@ -11,8 +11,10 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.Singular; import lombok.ToString; +import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult; +import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResultsButton; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; import java.util.List; @@ -27,9 +29,10 @@ import java.util.regex.Pattern; @Getter @Setter @ToString -@NoArgsConstructor @RequiredArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor +@Jacksonized @Builder public class AnswerInlineQuery extends BotApiMethodBoolean { public static final String PATH = "answerInlineQuery"; @@ -41,6 +44,7 @@ public class AnswerInlineQuery extends BotApiMethodBoolean { private static final String NEXTOFFSET_FIELD = "next_offset"; private static final String SWITCH_PM_TEXT_FIELD = "switch_pm_text"; private static final String SWITCH_PM_PARAMETER_FIELD = "switch_pm_parameter"; + private static final String BUTTON_FIELD = "button"; @JsonProperty(INLINEQUERYID_FIELD) @NonNull @@ -55,19 +59,39 @@ public class AnswerInlineQuery extends BotApiMethodBoolean { private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query @JsonProperty(NEXTOFFSET_FIELD) private String nextOffset; ///< Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. + + /** + * Optional. + * If passed, clients will display a button with specified text that switches the user to a private chat with the + * bot and sends the bot a start message with the parameter switch_pm_parameter + * + * @deprecated Use {@link #setButton(InlineQueryResultsButton)} + */ @JsonProperty(SWITCH_PM_TEXT_FIELD) - private String switchPmText; ///< Optional. If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter + @Deprecated + private String switchPmText; + /** + * Optional. + * Parameter for the start message sent to the bot when user presses the switch button + * + * @deprecated Use {@link #setButton(InlineQueryResultsButton)} + */ @JsonProperty(SWITCH_PM_PARAMETER_FIELD) - private String switchPmParameter; ///< Optional. Parameter for the start message sent to the bot when user presses the switch button + @Deprecated + private String switchPmParameter; + + /** + * Optional. + * A JSON serialized object describing a button to be shown above inline query results + */ + @JsonProperty(BUTTON_FIELD) + private InlineQueryResultsButton button; @Override public void validate() throws TelegramApiValidationException { - if (inlineQueryId == null || inlineQueryId.isEmpty()) { + if (inlineQueryId.isEmpty()) { throw new TelegramApiValidationException("InlineQueryId can't be empty", this); } - if (results == null) { - throw new TelegramApiValidationException("Results array can't be null", this); - } if (switchPmText != null) { if (switchPmText.isEmpty()) { throw new TelegramApiValidationException("SwitchPmText can't be empty", this); @@ -85,6 +109,10 @@ public class AnswerInlineQuery extends BotApiMethodBoolean { for (InlineQueryResult result : results) { result.validate(); } + + if (button != null) { + button.validate(); + } } @Override diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java index a5d09487..3d69ac95 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java @@ -28,7 +28,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java index 7b361105..47524f21 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java @@ -30,7 +30,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java index 7a1c6a13..e53c7f1d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java @@ -35,7 +35,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class CopyMessage extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java index 19848fe2..913041d7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java index 0976e08e..609a568a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetFile extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java index 6209dd3e..1ea3c852 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java @@ -22,7 +22,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java index 63ad12eb..4fdbc4ea 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java @@ -27,7 +27,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetPassportDataErrors extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java index 6f95f271..ef56766a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java @@ -28,7 +28,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetMyCommands extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyDescription.java new file mode 100644 index 00000000..57754a4f --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyDescription.java @@ -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 { + 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; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyShortDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyShortDescription.java new file mode 100644 index 00000000..a7f89c75 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/GetMyShortDescription.java @@ -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 { + 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; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyDescription.java new file mode 100644 index 00000000..05f2b712 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyDescription.java @@ -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; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyShortDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyShortDescription.java new file mode 100644 index 00000000..34eadbf1 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/description/SetMyShortDescription.java @@ -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; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java index b7fa583d..81a78d4f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class CloseForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java index 57ae59b5..e486de55 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class CloseGeneralForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java index 6173f6d0..0b1e1a7a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java index d926bc5e..682bab69 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class DeleteForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java index d1c18042..fd3d2b8f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java index 7a830846..db485195 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditGeneralForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java index 6a7506fd..2a90452f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class HideGeneralForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java index 3b762c37..09d92801 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ReopenForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java index 00962027..e56fa1d5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ReopenGeneralForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java index 5cde1ef2..ba31a215 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnhideGeneralForumTopic extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java index 1275e9cd..0aadd941 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnpinAllForumTopicMessages extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java new file mode 100644 index 00000000..c0b8cacf --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java @@ -0,0 +1,70 @@ +package org.telegram.telegrambots.meta.api.methods.forum; + +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.Setter; +import lombok.ToString; +import lombok.experimental.Tolerate; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 6.8 + * Use this method to clear the list of pinned messages in a General forum topic. + * The bot must be an administrator in the chat for this to work and must have the + * can_pin_messages administrator right in the supergroup. + * + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor(force = true) +@AllArgsConstructor +@Builder +public class UnpinAllGeneralForumTopicMessages extends BotApiMethodBoolean { + public static final String PATH = "unpinAllGeneralForumTopicMessages"; + + private static final String CHAT_ID_FIELD = "chat_id"; + + /** + * Unique identifier for the target chat or username + * of the target supergroup (in the format @supergroupusername) + */ + @JsonProperty(CHAT_ID_FIELD) + @NonNull + private String chatId; + + @Tolerate + public void setChatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + } + + @Override + public void validate() throws TelegramApiValidationException { + if (chatId.isEmpty()) { + throw new TelegramApiValidationException("ChatId can't be empty", this); + } + } + + @Override + public String getMethod() { + return PATH; + } + + public static class UnpinAllGeneralForumTopicMessagesBuilder { + + @Tolerate + public UnpinAllGeneralForumTopicMessagesBuilder chatId(@NonNull Long chatId) { + this.chatId = chatId.toString(); + return this; + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java index 6fbb016a..581aeb56 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java @@ -51,7 +51,7 @@ import java.util.ArrayList; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java index a1efedc2..cb065e6d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java @@ -48,7 +48,7 @@ import java.io.Serializable; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java index 24d8b7b7..73e5c0e4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @Builder public class ApproveChatJoinRequest extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java index a8d30025..95982b31 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java @@ -34,7 +34,7 @@ import java.time.ZonedDateTime; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java index b659d190..7e06c58b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java @@ -32,7 +32,7 @@ import java.time.ZonedDateTime; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java index c27e82aa..b1e909e7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java @@ -30,7 +30,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @RequiredArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java index 76f4985c..5408b02e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @Builder public class DeclineChatJoinRequest extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java index c7d5315c..4d85471c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class DeleteChatPhoto extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java index ccf2276d..b82d9998 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class DeleteChatStickerSet extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java index 3683bd3a..88028bfe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java @@ -31,7 +31,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @RequiredArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java index c7ba134c..98440620 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java @@ -32,7 +32,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ExportChatInviteLink extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java index 06fafe24..5b7d824e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetChat extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java index f5b2e9c1..c19b87f9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java @@ -30,7 +30,7 @@ import java.util.ArrayList; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetChatAdministrators extends BotApiMethod> { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java index ff1cea72..d39ef395 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetChatMember extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java index 8f963947..4e2fdd3d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java @@ -23,7 +23,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetChatMemberCount extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java index 5965781e..681015f1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java @@ -22,7 +22,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class LeaveChat extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java index b7986a9f..f2cfa74b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PromoteChatMember extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java index 0983d526..97926a6b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java @@ -33,7 +33,7 @@ import java.time.ZonedDateTime; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java index 8fddc94c..65f48adc 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java @@ -32,7 +32,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class RevokeChatInviteLink extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java index 078269a1..2f8bf42f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java @@ -23,7 +23,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatAdministratorCustomTitle extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java index d12d168a..7f22c0db 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java index 1b3cf57c..0055aefd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatPermissions extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java index cc63c7e3..69cfb9cd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatPhoto extends PartialBotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java index 181f00fb..08cce0d5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatStickerSet extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java index 759ead41..f16add03 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatTitle extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java index dd73a150..65cd2307 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java @@ -31,7 +31,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnbanChatMember extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java index 63d8b33a..dceda175 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnbanChatSenderChat extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java index 4db139cf..d2b3e5c8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java @@ -30,7 +30,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class CreateInvoiceLink extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java index 599d9c65..2535a38e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java @@ -30,7 +30,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendInvoice extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java index 9548f1ac..df9169d8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetChatMenuButton extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/GetMyName.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/GetMyName.java new file mode 100644 index 00000000..ac92a901 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/GetMyName.java @@ -0,0 +1,50 @@ +package org.telegram.telegrambots.meta.api.methods.name; + +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.name.BotName; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; + +/** + * @author Ruben Bermudez + * @version 6.7 + * Use this method to get the current bot name for the given user language. + * + * Returns BotName on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class GetMyName extends BotApiMethod { + public static final String PATH = "getMyDescription"; + + private static final String LANGUAGE_CODE_FIELD = "language_code"; + + /** + * Optional + * A two-letter ISO 639-1 language code or an empty string + */ + @JsonProperty(LANGUAGE_CODE_FIELD) + private String languageCode; + + @Override + public BotName deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, BotName.class); + } + + @Override + public String getMethod() { + return PATH; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/SetMyName.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/SetMyName.java new file mode 100644 index 00000000..5887266e --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/name/SetMyName.java @@ -0,0 +1,51 @@ +package org.telegram.telegrambots.meta.api.methods.name; + +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.7 + * Use this method to change the bot's name. Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SetMyName extends BotApiMethodBoolean { + public static final String PATH = "setMyName"; + + private static final String NAME_FIELD = "name"; + private static final String LANGUAGE_CODE_FIELD = "language_code"; + + /** + * Optional + * New bot name; 0-64 characters. + * Pass an empty string to remove the dedicated name for the given language. + */ + @JsonProperty(NAME_FIELD) + private String name; + + /** + * Optional + * A two-letter ISO 639-1 language code. + * If empty, the name will be shown to all users for whose language there is no dedicated name. + */ + @JsonProperty(LANGUAGE_CODE_FIELD) + private String languageCode; + + @Override + public String getMethod() { + return PATH; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java index e6553492..526d7c92 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java @@ -28,7 +28,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PinChatMessage extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java index c1d10542..5bd89ecf 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnpinAllChatMessages extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java index e946536a..f2836829 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java @@ -29,7 +29,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class UnpinChatMessage extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java index 207a02d7..2ac43c44 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java @@ -33,7 +33,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendPoll extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java index 1929920e..bce83e02 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class StopPoll extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java index 106064a7..d31d322c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java @@ -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 { @@ -50,7 +51,7 @@ public class SendAnimation extends SendMediaBotMethod { 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 { * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - private InputFile thumb; + private InputFile thumbnail; @Singular private List 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 { if (replyMarkup != null) { replyMarkup.validate(); } - if (thumb != null) { - thumb.validate(); + if (thumbnail != null) { + thumbnail.validate(); } } @@ -151,6 +152,24 @@ public class SendAnimation extends SendMediaBotMethod { 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 { this.chatId = chatId.toString(); return this; } + + @Tolerate + @Deprecated + public SendAnimationBuilder thumb(InputFile thumb) { + this.thumbnail = thumb; + return this; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java index 32c0fcc3..6cf60abe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java @@ -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 { @@ -51,7 +52,7 @@ public class SendAudio extends SendMediaBotMethod { 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"; @@ -111,7 +112,7 @@ public class SendAudio extends SendMediaBotMethod { * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass * “attach://” if the thumbnail was uploaded using multipart/form-data under . */ - private InputFile thumb; + private InputFile thumbnail; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode */ @@ -156,8 +157,8 @@ public class SendAudio extends SendMediaBotMethod { audio.validate(); - if (thumb != null) { - thumb.validate(); + if (thumbnail != null) { + thumbnail.validate(); } if (replyMarkup != null) { @@ -180,6 +181,24 @@ public class SendAudio extends SendMediaBotMethod { 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 @@ -187,5 +206,12 @@ public class SendAudio extends SendMediaBotMethod { this.chatId = chatId.toString(); return this; } + + @Tolerate + @Deprecated + public SendAudioBuilder thumb(InputFile thumb) { + this.thumbnail = thumb; + return this; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java index ffdb4420..e0dda56c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendChatAction extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java index b2bd8e7f..66c39e84 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendContact extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java index f0cb4eea..4a2b00e8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java @@ -29,7 +29,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendDice extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java index a4e39b3d..4ccd96fe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java @@ -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 { @@ -44,7 +45,7 @@ public class SendDocument extends SendMediaBotMethod { 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"; @@ -93,7 +94,7 @@ public class SendDocument extends SendMediaBotMethod { * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - private InputFile thumb; + private InputFile thumbnail; /** * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode */ @@ -142,8 +143,8 @@ public class SendDocument extends SendMediaBotMethod { document.validate(); - if (thumb != null) { - thumb.validate(); + if (thumbnail != null) { + thumbnail.validate(); } if (replyMarkup != null) { @@ -166,6 +167,24 @@ public class SendDocument extends SendMediaBotMethod { 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 @@ -173,5 +192,12 @@ public class SendDocument extends SendMediaBotMethod { this.chatId = chatId.toString(); return this; } + + @Tolerate + @Deprecated + public SendDocumentBuilder thumb(InputFile thumb) { + this.thumbnail = thumb; + return this; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java index 6efb06bf..a8eeec42 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java @@ -42,7 +42,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendGame extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendInvoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendInvoice.java index 36556f6d..42dfa89b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendInvoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendInvoice.java @@ -32,7 +32,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder @Deprecated diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java index c1b1a4ab..36381442 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendLocation extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java index cf0984cc..5f95413a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java @@ -36,7 +36,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendMediaGroup extends PartialBotApiMethod> { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java index 74c3ace2..9d4b0c2e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java @@ -31,7 +31,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendMessage extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java index d4457b3d..63f39367 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java @@ -31,7 +31,7 @@ import java.util.Objects; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendPhoto extends SendMediaBotMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java index f37fad72..a94f7fd1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java @@ -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 { @@ -41,6 +41,7 @@ public class SendSticker extends SendMediaBotMethod { 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 { * 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 { 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(); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java index e030d526..3e4a94d5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendVenue extends BotApiMethodMessage { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java index ef03bd1a..51a69596 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java @@ -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 { @@ -49,7 +50,7 @@ public class SendVideo extends SendMediaBotMethod { 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 { * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - private InputFile thumb; + private InputFile thumbnail; @Singular private List 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 { 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 { 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 { this.chatId = chatId.toString(); return this; } + + @Tolerate + @Deprecated + public SendVideoBuilder thumb(InputFile thumb) { + this.thumbnail = thumb; + return this; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java index 337300bd..a3841684 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java @@ -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 { @@ -42,7 +43,7 @@ public class SendVideoNote extends SendMediaBotMethod { 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 { * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - 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 { 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 { 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 { this.chatId = chatId.toString(); return this; } + + @Tolerate + @Deprecated + public SendVideoNoteBuilder thumb(InputFile thumb) { + this.thumbnail = thumb; + return this; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java index eeabce00..3b78d84d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java @@ -32,7 +32,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SendVoice extends SendMediaBotMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java index 1dd41b30..29f84eae 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java @@ -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 { @@ -36,18 +37,38 @@ public class AddStickerToSet extends PartialBotApiMethod { 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 { * 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 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 for technical requirements */ + @Deprecated private InputFile webmSticker; @Override @@ -89,33 +113,38 @@ public class AddStickerToSet extends PartialBotApiMethod { 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(); + } } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java index c2ea8ad5..ecf4f31d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java @@ -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 { 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_". 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 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/ URLs. * Can contain only english letters, digits and underscores. @@ -65,11 +114,9 @@ public class CreateNewStickerSet extends PartialBotApiMethod { * 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 { * 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 { * 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 { * 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 { 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 { 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(); + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java index 38a81400..18a89892 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java @@ -21,7 +21,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class DeleteStickerFromSet extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetCustomEmojiStickers.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetCustomEmojiStickers.java index 8980eeb7..0a65ed3c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetCustomEmojiStickers.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetCustomEmojiStickers.java @@ -1,10 +1,15 @@ package org.telegram.telegrambots.meta.api.methods.stickers; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.Singular; +import lombok.ToString; import org.telegram.telegrambots.meta.api.methods.BotApiMethod; -import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; -import org.telegram.telegrambots.meta.api.objects.games.GameHighScore; import org.telegram.telegrambots.meta.api.objects.stickers.Sticker; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java index cdb56ff0..519cad9f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java @@ -23,7 +23,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class GetStickerSet extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java new file mode 100644 index 00000000..06034f2c --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java @@ -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); + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java index f15c04ce..1cbb7507 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java @@ -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 { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java index ea6f5c38..161017fe 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumb.java @@ -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; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java index 8954fd21..1411525d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java @@ -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 { 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 for technical requirements. + */ + @NonNull + private InputFile sticker; ///< New sticker file @Override public String getMethod() { @@ -52,12 +62,43 @@ public class UploadStickerFile extends PartialBotApiMethod { 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; + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java index 57e087c2..de0758ef 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java @@ -33,7 +33,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class SetWebhook extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java index ee611efe..492b2285 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java @@ -31,7 +31,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class DeleteMessage extends BotApiMethodBoolean { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java index 46872d05..f3f897cd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java @@ -29,7 +29,7 @@ import java.io.Serializable; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditMessageLiveLocation extends BotApiMethodSerializable { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java index 0b1ceb05..bc0036b8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java @@ -38,7 +38,7 @@ import java.io.Serializable; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditMessageMedia extends PartialBotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java index b1a45a41..761ce371 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java @@ -33,7 +33,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditMessageText extends BotApiMethodSerializable { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java index 8efdadb9..37f124af 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java @@ -29,7 +29,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class AnswerWebAppQuery extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java index 8b469c4d..91cd28cf 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java index 17c0d6bc..61c017ad 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java @@ -25,7 +25,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class Chat implements BotApiObject { @@ -57,6 +57,7 @@ public class Chat implements BotApiObject { private static final String EMOJISTATUSCUSTOMEMOJIID_FIELD = "emoji_status_custom_emoji_id"; private static final String HASAGGRESSIVEANTISPAMENABLED_FIELD = "has_aggressive_anti_spam_enabled"; private static final String HASHIDDENMEMBERS_FIELD = "has_hidden_members"; + private static final String EMOJI_STATUS_EXPIRATION_DATE_FIELD = "emoji_status_expiration_date"; private static final String USERCHATTYPE = "private"; private static final String GROUPCHATTYPE = "group"; @@ -262,6 +263,13 @@ public class Chat implements BotApiObject { */ @JsonProperty(HASHIDDENMEMBERS_FIELD) private Boolean hasHiddenMembers; + /** + * Optional. + * Expiration date of the emoji status of the other party in a private chat, if any. + * Returned only in getChat. + */ + @JsonProperty(EMOJI_STATUS_EXPIRATION_DATE_FIELD) + private Boolean emojiStatusExpirationDate; /** * Optional. Extra. diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java index 52dfe1e4..4513259f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java @@ -25,9 +25,10 @@ public class ChatMemberUpdated implements BotApiObject { private static final String CHAT_FIELD = "chat"; private static final String FROM_FIELD = "from"; private static final String DATE_FIELD = "date"; - private static final String OLDCHATMEMBER_FIELD = "old_chat_member"; - private static final String NEWCHATMEMBER_FIELD = "new_chat_member"; - private static final String INVITELINK_FIELD = "invite_link"; + private static final String OLD_CHAT_MEMBER_FIELD = "old_chat_member"; + private static final String NEW_CHAT_MEMBER_FIELD = "new_chat_member"; + private static final String INVITE_LINK_FIELD = "invite_link"; + private static final String VIA_CHAT_FOLDER_INVITE_LINK_FIELD = "via_chat_folder_invite_link"; /** * Chat the user belongs to @@ -47,18 +48,25 @@ public class ChatMemberUpdated implements BotApiObject { /** * Previous information about the chat member */ - @JsonProperty(OLDCHATMEMBER_FIELD) + @JsonProperty(OLD_CHAT_MEMBER_FIELD) private ChatMember oldChatMember; /** * New information about the chat member */ - @JsonProperty(NEWCHATMEMBER_FIELD) + @JsonProperty(NEW_CHAT_MEMBER_FIELD) private ChatMember newChatMember; /** * Optional. * Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */ - @JsonProperty(INVITELINK_FIELD) + @JsonProperty(INVITE_LINK_FIELD) private ChatInviteLink inviteLink; + /** + * Optional. + * True, if the user joined the chat via a chat folder invite link + */ + @JsonProperty(VIA_CHAT_FOLDER_INVITE_LINK_FIELD) + private Boolean viaChatFolderInviteLink; + } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java index 74e3f28a..db8a963c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java index c80530ef..bdb9161a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Location.java @@ -20,7 +20,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; @Setter @ToString @AllArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) public class Location implements BotApiObject { private static final String LONGITUDE_FIELD = "longitude"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java index dffdbab9..1e275c70 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java @@ -27,7 +27,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java index 0b5f681d..d1c0203f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java @@ -23,6 +23,7 @@ import org.telegram.telegrambots.meta.api.objects.payments.SuccessfulPayment; import org.telegram.telegrambots.meta.api.objects.polls.Poll; import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup; import org.telegram.telegrambots.meta.api.objects.stickers.Sticker; +import org.telegram.telegrambots.meta.api.objects.stories.Story; import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatEnded; import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatParticipantsInvited; import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatScheduled; @@ -115,6 +116,7 @@ public class Message implements BotApiObject { private static final String HASMEDIASPOILER_FIELD = "has_media_spoiler"; private static final String USERSHARED_FIELD = "user_shared"; private static final String CHATSHARED_FIELD = "chat_shared"; + private static final String STORY_FIELD = "story"; private static final String VIEWS_FIELD = "views"; private static final String OUTGOING_FIELD = "outgoing"; @@ -558,6 +560,12 @@ public class Message implements BotApiObject { */ @JsonProperty(CHATSHARED_FIELD) private ChatShared chatShared; + /** + * Optional. + * Message is a forwarded story + */ + @JsonProperty(STORY_FIELD) + private Story story; @JsonProperty(OUTGOING_FIELD) private Boolean outgoing; ///< Optional. Extra. @@ -786,4 +794,9 @@ public class Message implements BotApiObject { private boolean hasChatShared() { return chatShared != null; } + + @JsonIgnore + private boolean hasStory() { + return story != null; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java index 53244081..ea37b6df 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java @@ -32,7 +32,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class MessageEntity implements BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java index 074a9e63..6fe0792c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java @@ -20,7 +20,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @RequiredArgsConstructor public class User implements BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java index a71a3f62..f0380c88 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java index a075b3db..3506af7f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java index 9c835e96..3ed2a83c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java @@ -1,5 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -9,7 +10,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; /** * This object represents a service message about a user allowing a bot added to the attachment menu to write messages. - * Currently holds no information. + * * @author Ruben Bermudez * @version 6.4 */ @@ -19,4 +20,13 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; @ToString @AllArgsConstructor public class WriteAccessAllowed implements BotApiObject { + + private static final String WEB_APP_NAME_FIELD = "web_app_name"; + + /** + * Optional. + * Name of the Web App which was launched from a link + */ + @JsonProperty(WEB_APP_NAME_FIELD) + private String webAppName; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java index 80c4cd03..9225fc41 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java @@ -14,7 +14,7 @@ import org.telegram.telegrambots.meta.api.interfaces.Validable; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ChatAdministratorRights implements BotApiObject, Validable { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java index d9ba0ce7..3768be61 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java @@ -22,7 +22,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class BotCommand implements BotApiObject, Validable { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChat.java index d91e5a05..5bd59313 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChat.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class BotCommandScopeChat implements BotCommandScope { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatAdministrators.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatAdministrators.java index f6558e20..1f73887e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatAdministrators.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatAdministrators.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class BotCommandScopeChatAdministrators implements BotCommandScope { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatMember.java index 769f7d96..fe1ce7b3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/scope/BotCommandScopeChatMember.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class BotCommandScopeChatMember implements BotCommandScope { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotDescription.java new file mode 100644 index 00000000..aec59727 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotDescription.java @@ -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; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotShortDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotShortDescription.java new file mode 100644 index 00000000..95418e97 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/description/BotShortDescription.java @@ -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; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java index 05fff5d4..2d05a482 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java index 1a8a4ff2..39cad63e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Game.java @@ -42,7 +42,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class Game implements BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java index 6d99f768..2cf2d9f3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/GameHighScore.java @@ -37,7 +37,7 @@ import org.telegram.telegrambots.meta.api.objects.User; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class GameHighScore implements BotApiObject { private static final String POSITION_FIELD = "position"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java index 54a2d168..1ab3ca2f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/ChosenInlineQuery.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.api.objects.User; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ChosenInlineQuery implements BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java index ff96ed46..96647894 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/InlineQuery.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.api.objects.User; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQuery implements BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java index d4cf28e3..3fd5dd36 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputContactMessageContent.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InputContactMessageContent implements InputMessageContent { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputInvoiceMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputInvoiceMessageContent.java index e381c948..2f6e1d1a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputInvoiceMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputInvoiceMessageContent.java @@ -29,7 +29,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InputInvoiceMessageContent implements InputMessageContent { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java index ebd6fbfd..be1f98ca 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputLocationMessageContent.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InputLocationMessageContent implements InputMessageContent { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java index 16447111..22fb15d2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputTextMessageContent.java @@ -27,7 +27,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InputTextMessageContent implements InputMessageContent { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java index 38173904..12558569 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InputVenueMessageContent implements InputMessageContent { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResult.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResult.java index c7b028e6..5f597aae 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResult.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResult.java @@ -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 VALIDTHUMBTYPES = Collections.unmodifiableList(Arrays.asList("image/jpeg", "image/gif", "video/mp4")); + } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultArticle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultArticle.java index 2a862217..b1793081 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultArticle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultArticle.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultAudio.java index 84e50485..04969f28 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultAudio.java @@ -35,7 +35,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultAudio implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultContact.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultContact.java index ab3fd78e..bf02a627 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultContact.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultContact.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultDocument.java index bbe8bb8d..0e0339b6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultDocument.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGame.java index 597eed96..675f27ee 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGame.java @@ -46,7 +46,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultGame implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGif.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGif.java index 21e349a5..63991016 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGif.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultGif.java @@ -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 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; + } + + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultLocation.java index b6fc7e53..94decdae 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultLocation.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java index 585be270..dd8f5459 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultMpeg4Gif.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java index 6477c768..f6ea542a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultPhoto.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVenue.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVenue.java index f9dc8827..bbe89576 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVenue.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVenue.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVideo.java index c39086c1..30696b88 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVideo.java @@ -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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVoice.java index c080e696..5a97b1b6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultVoice.java @@ -35,7 +35,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultVoice implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultsButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultsButton.java new file mode 100644 index 00000000..bf84ff20 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/InlineQueryResultsButton.java @@ -0,0 +1,89 @@ +package org.telegram.telegrambots.meta.api.objects.inlinequery.result; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +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.interfaces.BotApiObject; +import org.telegram.telegrambots.meta.api.interfaces.Validable; +import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import java.util.regex.Pattern; + +/** + * @author Ruben Bermudez + * @version 6.7 + * This object represents a button to be shown above inline query results. + * + * You must use exactly one of the optional fields. + */ +@JsonDeserialize +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@NoArgsConstructor(force = true) +@AllArgsConstructor +@Builder +public class InlineQueryResultsButton implements Validable, BotApiObject { + + private static final String TEXT_FIELD = "text"; + private static final String WEB_APP_FIELD = "web_app"; + private static final String START_PARAMETER_FIELD = "start_parameter"; + + /** + * Label text on the button + */ + @NonNull + @JsonProperty(TEXT_FIELD) + private String text; + /** + * Optional. + * Description of the Web App that will be launched when the user presses the button. + * The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. + */ + @JsonProperty(WEB_APP_FIELD) + private WebAppInfo webApp; + + /** + * Optional. + * Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, + * only A-Z, a-z, 0-9, _ and - are allowed. + */ + @JsonProperty(START_PARAMETER_FIELD) + private String startParameter; + + @Override + public void validate() throws TelegramApiValidationException { + if (text.isEmpty()) { + throw new TelegramApiValidationException("Text can't be empty", this); + + } + + if (startParameter != null && webApp != null) { + throw new TelegramApiValidationException("Only one of Start Parameter or Web App is allowed", this); + } + + if (startParameter != null) { + if (startParameter.isEmpty() || startParameter.length() > 64) { + throw new TelegramApiValidationException("SwitchPmParameter can't be longer than 64 chars", this); + } + if (!Pattern.matches("[A-Za-z0-9_\\-]+", startParameter.trim())) { + throw new TelegramApiValidationException("SwitchPmParameter only allows A-Z, a-z, 0-9, _ and - characters", this); + } + } + + if (webApp != null) { + webApp.validate(); + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedAudio.java index 85bc8cfb..70a7367d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedAudio.java @@ -35,7 +35,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedAudio implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedDocument.java index a461c13d..c54a7425 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedDocument.java @@ -37,7 +37,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedDocument implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedGif.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedGif.java index 508ba30e..689f34e9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedGif.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedGif.java @@ -36,7 +36,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedGif implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedMpeg4Gif.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedMpeg4Gif.java index 1d00f30b..02884c48 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedMpeg4Gif.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedMpeg4Gif.java @@ -34,7 +34,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedPhoto.java index 452f29c3..ab37b05e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedPhoto.java @@ -34,7 +34,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedPhoto implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedSticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedSticker.java index 50949114..1b81e2f0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedSticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedSticker.java @@ -32,7 +32,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedSticker implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVideo.java index 9ff70b89..757a0bde 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVideo.java @@ -34,7 +34,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedVideo implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVoice.java index e59cdd5d..0de4fedd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/result/cached/InlineQueryResultCachedVoice.java @@ -36,7 +36,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineQueryResultCachedVoice implements InlineQueryResult { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMedia.java index b2150eab..0e0c924d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMedia.java @@ -36,7 +36,7 @@ import java.util.List; @Setter @ToString @RequiredArgsConstructor -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public abstract class InputMedia implements Validable, BotApiObject { public static final String TYPE_FIELD = "type"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java index e9f76c98..86ab7eb2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAnimation.java @@ -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 can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - 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 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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAudio.java index 813bd247..e75ece3d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaAudio.java @@ -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 can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - 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 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 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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaDocument.java index de4f4240..959def30 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaDocument.java @@ -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 can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - 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 entities, boolean isNewMedia, String mediaName, File newMediaFile, InputStream newMediaStream, InputFile thumb, Boolean disableContentTypeDetection) { + public InputMediaDocument(@NonNull String media, String caption, String parseMode, List 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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java index b7ddc040..a2ae3eca 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/InputMediaVideo.java @@ -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 can’t be reused and can be only uploaded as a new file, so you can pass “attach://” * if the thumbnail was uploaded using multipart/form-data under . */ - @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 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; + } + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java index c3f5319b..fd365f98 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/serialization/InputMediaSerializer.java @@ -42,8 +42,8 @@ public class InputMediaSerializer extends JsonSerializer { 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 { } } 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 { } } 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 { } } 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()); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/name/BotName.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/name/BotName.java new file mode 100644 index 00000000..d6d70865 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/name/BotName.java @@ -0,0 +1,31 @@ +package org.telegram.telegrambots.meta.api.objects.name; + +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.7 + * This object represents the bot's name. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@Builder +public class BotName implements BotApiObject { + private static final String NAME_FIELD = "name"; + + /** + * The bot's name + */ + @JsonProperty(NAME_FIELD) + private String name; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorDataField.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorDataField.java index d2c562d9..25b98a8d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorDataField.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorDataField.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorDataField implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFile.java index b914afe9..cf6eb21e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFile.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorFile implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFiles.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFiles.java index cacb04c5..c3e9fb3b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFiles.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFiles.java @@ -27,7 +27,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorFiles implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFrontSide.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFrontSide.java index 4ff2dd54..17bb42bf 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFrontSide.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorFrontSide.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorFrontSide implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorReverseSide.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorReverseSide.java index 16775565..a2716b56 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorReverseSide.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorReverseSide.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorReverseSide implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorSelfie.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorSelfie.java index 413c922e..5e64efa9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorSelfie.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorSelfie.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorSelfie implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java index 60da8efc..9104c5c0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFile.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorTranslationFile implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java index 61212a33..f313588a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorTranslationFiles.java @@ -27,7 +27,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorTranslationFiles implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java index 77357707..68a3d86c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/passport/dataerror/PassportElementErrorUnspecified.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class PassportElementErrorUnspecified implements PassportElementError { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java index 904bde8e..df93caf3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java @@ -22,7 +22,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class LabeledPrice implements Validable, BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/ShippingOption.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/ShippingOption.java index 1e3a16e8..0900a948 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/ShippingOption.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/ShippingOption.java @@ -26,7 +26,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class ShippingOption implements Validable, BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java index ee5edd0a..01c669d1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/polls/PollAnswer.java @@ -8,6 +8,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; +import org.telegram.telegrambots.meta.api.objects.Chat; import org.telegram.telegrambots.meta.api.objects.User; import java.util.List; @@ -25,14 +26,31 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor public class PollAnswer implements BotApiObject { - private static final String POLLID_FIELD = "poll_id"; + private static final String POLL_ID_FIELD = "poll_id"; private static final String USER_FIELD = "user"; - private static final String OPTIONIDS_FIELD = "option_ids"; + private static final String OPTION_IDS_FIELD = "option_ids"; + private static final String VOTER_CHAT_FIELD = "voter_chat"; - @JsonProperty(POLLID_FIELD) - private String pollId; ///< Unique poll identifier + /** + * Unique poll identifier + */ + @JsonProperty(POLL_ID_FIELD) + private String pollId; + /** + * The user, who changed the answer to the poll + */ @JsonProperty(USER_FIELD) - private User user; ///< The user, who changed the answer to the poll - @JsonProperty(OPTIONIDS_FIELD) - private List optionIds; ///< 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. + private User user; + /** + * Optional. + * The chat that changed the answer to the poll, if the voter is anonymous + */ + @JsonProperty(OPTION_IDS_FIELD) + private List optionIds; + /** + * Optional. + * The chat that changed the answer to the poll, if the voter is anonymous + */ + @JsonProperty(VOTER_CHAT_FIELD) + private Chat voterChat; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/InlineKeyboardMarkup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/InlineKeyboardMarkup.java index 2ed56cd4..4d5de8af 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/InlineKeyboardMarkup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/InlineKeyboardMarkup.java @@ -27,7 +27,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class InlineKeyboardMarkup implements ReplyKeyboard { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java index 0f503e46..8037a63f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardMarkup.java @@ -27,7 +27,7 @@ import java.util.List; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardRemove.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardRemove.java index 9098684d..25d4724c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardRemove.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/ReplyKeyboardRemove.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java index 86e6d2e4..351c5ec4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java @@ -29,7 +29,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java index b4025b16..1d2ed8c4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java @@ -33,7 +33,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java index ba6833d7..1e6bca1c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java @@ -26,7 +26,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder @@ -40,6 +40,7 @@ public class KeyboardButtonRequestChat implements Validable, BotApiObject { private static final String USERADMINISTRATORRIGHTS_FIELD = "user_administrator_rights"; private static final String BOTADMINISTRATORRIGHTS_FIELD = "bot_administrator_rights"; private static final String BOTISMEMBER_FIELD = "bot_is_member"; + private static final String SWITCH_INLINE_QUERY_CHOSEN_CHAT_FIELD = "switch_inline_query_chosen_chat"; /** * Signed 32-bit identifier of the request @@ -96,6 +97,13 @@ public class KeyboardButtonRequestChat implements Validable, BotApiObject { */ @JsonProperty(BOTISMEMBER_FIELD) private Boolean botIsMember; + /** + * Optional. + * If set, pressing the button will prompt the user to select one of their chats of the specified type, + * open that chat and insert the bot's username and the specified inline query in the input field + */ + @JsonProperty(SWITCH_INLINE_QUERY_CHOSEN_CHAT_FIELD) + private SwitchInlineQueryChosenChat switchInlineQueryChosenChat; @Override @@ -109,5 +117,8 @@ public class KeyboardButtonRequestChat implements Validable, BotApiObject { if (botAdministratorRights != null) { botAdministratorRights.validate(); } + if (switchInlineQueryChosenChat != null) { + switchInlineQueryChosenChat.validate(); + } } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java index e238f864..7359244b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java @@ -25,7 +25,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @RequiredArgsConstructor @AllArgsConstructor @Builder diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/SwitchInlineQueryChosenChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/SwitchInlineQueryChosenChat.java new file mode 100644 index 00000000..a266da18 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/SwitchInlineQueryChosenChat.java @@ -0,0 +1,70 @@ +package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons; + +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.interfaces.BotApiObject; +import org.telegram.telegrambots.meta.api.interfaces.Validable; + +/** + * @author Ruben Bermudez + * @version 6.7 + * + * This object represents an inline button that switches the current user to inline mode in a chosen chat, + * with an optional default inline query. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor(force = true) +@RequiredArgsConstructor +@AllArgsConstructor +@Builder +public class SwitchInlineQueryChosenChat implements Validable, BotApiObject { + private static final String QUERY_FIELD = "query"; + private static final String ALLOW_USER_CHATS_FIELD = "allow_user_chats"; + private static final String ALLOW_BOT_CHATS_FIELD = "allow_bot_chats"; + private static final String ALLOW_GROUP_CHATS_FIELD = "allow_group_chats"; + private static final String ALLOW_CHANNEL_CHATS_FIELD = "allow_channel_chats"; + + /** + * Optional. + * The default inline query to be inserted in the input field. + * If left empty, only the bot's username will be inserted + */ + @JsonProperty(QUERY_FIELD) + private String requestId; + /** + * Optional. + * True, if private chats with users can be chosen + */ + @JsonProperty(ALLOW_USER_CHATS_FIELD) + @NonNull + private Boolean allowUserChats; + /** + * Optional. + * True, if private chats with bots can be chosen + */ + @JsonProperty(ALLOW_BOT_CHATS_FIELD) + private Boolean allowBotChats; + /** + * Optional. + * True, if group and supergroup chats can be chosen + */ + @JsonProperty(ALLOW_GROUP_CHATS_FIELD) + private Boolean allowGroupChats; + /** + * Optional. + * True, if channel chats can be chosen + */ + @JsonProperty(ALLOW_CHANNEL_CHATS_FIELD) + private Boolean allowChannelChats; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/InputSticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/InputSticker.java new file mode 100644 index 00000000..c8e51476 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/InputSticker.java @@ -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 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 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(); + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java index a946749d..e4ed66b3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java @@ -24,7 +24,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class MaskPosition implements Validable, BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java index d32f058f..a75b8665 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/Sticker.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java index b8d39ac5..5a2af2e7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java @@ -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; + } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stories/Story.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stories/Story.java new file mode 100644 index 00000000..f968dcae --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stories/Story.java @@ -0,0 +1,18 @@ +package org.telegram.telegrambots.meta.api.objects.stories; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@NoArgsConstructor +@Builder +public class Story implements BotApiObject { +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java index c88ea86e..3360f28a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java @@ -13,15 +13,15 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class VideoChatScheduled implements BotApiObject { - private static final String STARTDATE_FIELD = "start_date"; + private static final String START_DATE_FIELD = "start_date"; /** * Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator */ - @JsonProperty(STARTDATE_FIELD) + @JsonProperty(START_DATE_FIELD) @NonNull private Integer startDate; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java index 1b051134..37493282 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java @@ -1,11 +1,14 @@ package org.telegram.telegrambots.meta.api.objects.webapp; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; -import org.telegram.telegrambots.meta.api.interfaces.Validable; -import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** * @author Ruben Bermudez @@ -16,7 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class SentWebAppMessage implements BotApiObject { private static final String INLINEMESSAGEID_FIELD = "inline_message_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java index 9afb8871..5330f1eb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java @@ -1,10 +1,14 @@ package org.telegram.telegrambots.meta.api.objects.webapp; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; -import org.telegram.telegrambots.meta.api.interfaces.Validable; -import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** * Contains data sent from a web app to the bot. @@ -15,11 +19,11 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor public class WebAppData implements BotApiObject { private static final String DATA_FIELD = "data"; - private static final String BUTTONTEXT_FIELD = "button_text"; + private static final String BUTTON_TEXT_FIELD = "button_text"; /** * The data @@ -30,7 +34,7 @@ public class WebAppData implements BotApiObject { /** * Text of the web_app keyboard button, from which the web app was opened */ - @JsonProperty(BUTTONTEXT_FIELD) + @JsonProperty(BUTTON_TEXT_FIELD) @NonNull private String buttonText; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java index 2e1bbf8f..dcb260a6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java @@ -1,8 +1,14 @@ package org.telegram.telegrambots.meta.api.objects.webapp; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @@ -16,7 +22,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @Getter @Setter @ToString -@NoArgsConstructor +@NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class WebAppInfo implements Validable, BotApiObject { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java index 8add108b..b56d4add 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java @@ -23,8 +23,6 @@ import org.slf4j.LoggerFactory; import org.telegram.telegrambots.meta.api.objects.ApiResponse; import org.telegram.telegrambots.meta.api.objects.ResponseParameters; -import java.io.IOException; - /** * @author Ruben Bermudez diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java index e4e93ccd..08d4943c 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java @@ -1,11 +1,12 @@ package org.telegram.telegrambots.meta.api.methods.adminrights; import org.junit.jupiter.api.Test; -import org.telegram.telegrambots.meta.api.methods.groupadministration.PromoteChatMember; import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; /** diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java index 296967f3..05f87732 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java @@ -1,15 +1,17 @@ package org.telegram.telegrambots.meta.api.methods.webapp; import org.junit.jupiter.api.Test; -import org.telegram.telegrambots.meta.api.methods.groupadministration.PromoteChatMember; import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent; -import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult; import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResultArticle; import org.telegram.telegrambots.meta.api.objects.webapp.SentWebAppMessage; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Ruben Bermudez diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java index bd781a6b..6f2806c3 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java @@ -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()); diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java index 2ae05698..b61cbea8 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java @@ -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()); diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestSerialization.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestSerialization.java index 9a39328a..7b6ed6c5 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestSerialization.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestSerialization.java @@ -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(); } diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java index f4e4ad23..60a7bbd9 100644 --- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java +++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/apimethods/TestAnswerInlineQuery.java @@ -18,7 +18,7 @@ class TestAnswerInlineQuery { @BeforeEach void setUp() { - answerInlineQuery = new AnswerInlineQuery(); + answerInlineQuery = new AnswerInlineQuery("", new ArrayList<>()); } @Test diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md index b23762b3..4364752b 100644 --- a/telegrambots-spring-boot-starter/README.md +++ b/telegrambots-spring-boot-starter/README.md @@ -18,14 +18,14 @@ Usage org.telegram telegrambots-spring-boot-starter - 6.5.0 + 6.8.0 ``` **Gradle** ```gradle - implementation 'org.telegram:telegrambots-spring-boot-starter:6.5.0' + implementation 'org.telegram:telegrambots-spring-boot-starter:6.8.0' ``` Motivation diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml index 708aa06c..c5a7169c 100644 --- a/telegrambots-spring-boot-starter/pom.xml +++ b/telegrambots-spring-boot-starter/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambots-spring-boot-starter @@ -72,8 +72,8 @@ UTF-8 UTF-8 - 6.5.0 - 2.7.5 + 6.8.0 + 2.7.12 1.6 1.6.13 diff --git a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/SpringWebhookBot.java b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/SpringWebhookBot.java index 20d2a163..51babf15 100644 --- a/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/SpringWebhookBot.java +++ b/telegrambots-spring-boot-starter/src/main/java/org/telegram/telegrambots/starter/SpringWebhookBot.java @@ -47,7 +47,7 @@ public abstract class SpringWebhookBot extends TelegramWebhookBot { return setWebhook; } - public class TestSpringWebhookBot extends SpringWebhookBot { + public static class TestSpringWebhookBot extends SpringWebhookBot { public TestSpringWebhookBot(SetWebhook setWebhook) { super(setWebhook, null); diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml index 1ee1e2d5..799784ba 100644 --- a/telegrambots/pom.xml +++ b/telegrambots/pom.xml @@ -7,7 +7,7 @@ org.warp bots - 6.5.0 + 6.8.0 telegrambots @@ -93,7 +93,7 @@ org.warp telegrambots-meta - 6.5.0 + 6.8.0 org.projectlombok diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java index 9806745b..b1c8c6a3 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java @@ -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); @@ -212,9 +214,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(); @@ -328,9 +330,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); @@ -387,9 +389,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); @@ -437,6 +439,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); @@ -447,9 +452,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 (sendAudio) * @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 @@ -492,9 +497,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); @@ -517,10 +522,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 (sendVoice) * 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 @@ -588,13 +593,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); @@ -659,17 +662,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); @@ -717,19 +726,28 @@ 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) { addInputFile(builder, createNewStickerSet.getTgsSticker(), CreateNewStickerSet.TGSSTICKER_FIELD, true); - } else { + } else if (createNewStickerSet.getWebmSticker() != null) { 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); @@ -750,7 +768,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); @@ -826,9 +845,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) { @@ -1108,8 +1127,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) { @@ -1153,23 +1172,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); } } @@ -1186,6 +1205,14 @@ public abstract class DefaultAbsSender extends AbsSender { builder.addTextBody(mediaField, objectMapper.writeValueAsString(media), TEXT_PLAIN_CONTENT_TYPE); } + private void addStickers(MultipartEntityBuilder builder, List 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) { diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingBot.java b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingBot.java index ecc9d755..0cb4aeb3 100644 --- a/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingBot.java +++ b/telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingBot.java @@ -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); } diff --git a/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java b/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java index 56501d96..f3387591 100644 --- a/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java +++ b/telegrambots/src/test/java/org/telegram/telegrambots/test/BotApiMethodHelperFactory.java @@ -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") diff --git a/telegrambots/src/test/java/org/telegram/telegrambots/test/ServerlessWebhookTest.java b/telegrambots/src/test/java/org/telegram/telegrambots/test/ServerlessWebhookTest.java index 41571f07..e517a1c9 100644 --- a/telegrambots/src/test/java/org/telegram/telegrambots/test/ServerlessWebhookTest.java +++ b/telegrambots/src/test/java/org/telegram/telegrambots/test/ServerlessWebhookTest.java @@ -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)); }