diff --git a/README.md b/README.md
index 22ef1b08..6dd58284 100644
--- a/README.md
+++ b/README.md
@@ -27,16 +27,16 @@ Just import add the library to your project with one of these options:
org.telegram
telegrambots
- 4.9.2
+ 5.0.0
```
```gradle
- compile "org.telegram:telegrambots:4.9.2"
+ compile "org.telegram:telegrambots:5.0.0"
```
- 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/4.9.2)
- 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/4.9.2)
+ 2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.0.0)
+ 3. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.0.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 62d825b8..1358a72a 100644
--- a/TelegramBots.wiki/Changelog.md
+++ b/TelegramBots.wiki/Changelog.md
@@ -1,3 +1,12 @@
+### 5.0.0 ###
+1. Update Api version [5.0](https://core.telegram.org/bots/api-changelog#june-4-2020)
+2. Added Builders for many of the API methods and objects
+3. Some setters/getters may have change name. They no longer return a refence to itself, use Builder for that.
+4. Simplified methods to set files in methods. Only InputFile is available now (this class contains constructors for all the cases)
+5. Locations now use Double instead of Float to avoid rounding.
+6. When registering a Webhook Bot, a SetWebhook object must be provided.
+7. When using Webhook with Spring, extends class SpringWebhookBot instead of WebhookBot
+
### 4.9.2 ###
1. Bug fixing: #792, #801, #804, #810, #812, #813, #820 and #814
diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md
index d86c611d..ec56403d 100644
--- a/TelegramBots.wiki/Getting-Started.md
+++ b/TelegramBots.wiki/Getting-Started.md
@@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
org.telegram
telegrambots
- 4.9.2
+ 5.0.0
```
* With **Gradle**:
```groovy
- compile group: 'org.telegram', name: 'telegrambots', version: '4.9.2'
+ compile group: 'org.telegram', name: 'telegrambots', version: '5.0.0'
```
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md
index c687f25e..0a4e2567 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
- 4.9.2
+ 5.0.0
```
* **Gradle**
```groovy
- implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '4.9.2'
+ implementation group: 'org.telegram', name: 'telegrambots-abilities', version: '5.0.0'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
diff --git a/pom.xml b/pom.xml
index 7899d19a..37b23037 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
pom
- 4.9.2
+ 5.0.0
telegrambots
@@ -67,12 +67,12 @@
${java.version}
${java.version}
- 5.6.2
- 3.1.0
- 3.1.0
- 2.10.1
- 2.10.1
- 1.7.29
+ 5.7.0
+ 3.6.0
+ 3.6.0
+ 2.11.3
+ 2.11.3
+ 1.7.30
1.3.5
1.18.16
diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md
index c7455741..6c58330e 100644
--- a/telegrambots-abilities/README.md
+++ b/telegrambots-abilities/README.md
@@ -18,19 +18,19 @@ Usage
org.telegram
telegrambots-abilities
- 4.9.2
+ 5.0.0
```
**Gradle**
```gradle
- compile "org.telegram:telegrambots-abilities:4.9.2"
+ compile "org.telegram:telegrambots-abilities:5.0.0"
```
-**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v4.9.2)
+**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.0)
-**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v4.9.2)
+**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v5.0.0)
Motivation
----------
diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml
index a52cfb24..7d4b10fb 100644
--- a/telegrambots-abilities/pom.xml
+++ b/telegrambots-abilities/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.9.2
+ 5.0.0
telegrambots-abilities
@@ -76,15 +76,15 @@
UTF-8
UTF-8
- 3.9
- 3.0.7
+ 3.11
+ 3.0.8
org.telegram
telegrambots
- 4.9.2
+ 5.0.0
org.apache.commons
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityWebhookBot.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityWebhookBot.java
index a50aa81d..acbb9f25 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityWebhookBot.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityWebhookBot.java
@@ -3,11 +3,12 @@ package org.telegram.abilitybots.api.bot;
import org.telegram.abilitybots.api.db.DBContext;
import org.telegram.abilitybots.api.toggle.AbilityToggle;
import org.telegram.abilitybots.api.toggle.DefaultToggle;
-import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.bots.TelegramWebhookBot;
-import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
+import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
+import org.telegram.telegrambots.meta.api.objects.Update;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.meta.generics.WebhookBot;
import org.telegram.telegrambots.util.WebhookUtils;
@@ -63,8 +64,8 @@ public abstract class AbilityWebhookBot extends BaseAbilityBot implements Webhoo
}
@Override
- public void setWebhook(String url, String publicCertificatePath) throws TelegramApiRequestException {
- WebhookUtils.setWebhook(this, url, publicCertificatePath);
+ public void setWebhook(SetWebhook setWebhook) throws TelegramApiException {
+ WebhookUtils.setWebhook(this, setWebhook);
}
@Override
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 ce6d5cb5..f8beaab1 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
@@ -258,7 +258,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
}
public boolean isGroupAdmin(long chatId, int id) {
- GetChatAdministrators admins = new GetChatAdministrators().setChatId(chatId);
+ GetChatAdministrators admins = GetChatAdministrators.builder().chatId(Long.toString(chatId)).build();
return silent.execute(admins)
.orElse(new ArrayList<>()).stream()
.anyMatch(member -> member.getUser().getId() == id);
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/DefaultAbilities.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/DefaultAbilities.java
index 6e1139bb..0c9f6707 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/DefaultAbilities.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/DefaultAbilities.java
@@ -14,6 +14,7 @@ import org.telegram.abilitybots.api.util.AbilityUtils;
import org.telegram.abilitybots.api.util.Pair;
import org.telegram.telegrambots.meta.api.methods.GetFile;
import org.telegram.telegrambots.meta.api.methods.send.SendDocument;
+import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.User;
@@ -221,9 +222,10 @@ public final class DefaultAbilities implements AbilityExtension {
try (PrintStream printStream = new PrintStream(backup)) {
printStream.print(bot.db.backup());
- bot.sender.sendDocument(new SendDocument()
- .setDocument(backup)
- .setChatId(ctx.chatId())
+ bot.sender.sendDocument(SendDocument.builder()
+ .document(new InputFile(backup))
+ .chatId(ctx.chatId().toString())
+ .build()
);
} catch (FileNotFoundException e) {
log.error("Error while fetching backup", e);
@@ -472,6 +474,6 @@ public final class DefaultAbilities implements AbilityExtension {
}
protected File downloadFileWithId(String fileId) throws TelegramApiException {
- return bot.sender.downloadFile(bot.sender.execute(new GetFile().setFileId(fileId)));
+ return bot.sender.downloadFile(bot.sender.execute(GetFile.builder().fileId(fileId).build()));
}
}
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java
index 0e3aeb6c..4c677875 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/SilentSender.java
@@ -38,7 +38,7 @@ public class SilentSender {
public Optional forceReply(String message, long id) {
SendMessage msg = new SendMessage();
msg.setText(message);
- msg.setChatId(id);
+ msg.setChatId(Long.toString(id));
msg.setReplyMarkup(new ForceReplyKeyboard());
return execute(msg);
@@ -64,7 +64,7 @@ public class SilentSender {
private Optional doSendMessage(String txt, long groupId, boolean format) {
SendMessage smsg = new SendMessage();
- smsg.setChatId(groupId);
+ smsg.setChatId(Long.toString(groupId));
smsg.setText(txt);
smsg.enableMarkdown(format);
diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java
index c69daef3..9fedf218 100644
--- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java
+++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/AbilityBotTest.java
@@ -702,6 +702,7 @@ public class AbilityBotTest {
Message botMessage = mock(Message.class);
Document document = mock(Document.class);
+ when(document.getFileId()).thenReturn("FAKEFILEID");
when(message.getFrom()).thenReturn(CREATOR);
when(update.getMessage()).thenReturn(message);
when(message.getDocument()).thenReturn(document);
diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md
index 479c1d5c..5cfd0cf7 100644
--- a/telegrambots-chat-session-bot/README.md
+++ b/telegrambots-chat-session-bot/README.md
@@ -15,7 +15,7 @@ Usage
org.telegram
telegrambots-chat-session-bot
- 4.9.2
+ 5.0.0
```
diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml
index e5e0138a..00b9368f 100644
--- a/telegrambots-chat-session-bot/pom.xml
+++ b/telegrambots-chat-session-bot/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.9.2
+ 5.0.0
telegrambots-chat-session-bot
@@ -76,7 +76,7 @@
UTF-8
UTF-8
- 1.4.2
+ 1.7.0
@@ -84,7 +84,7 @@
org.telegram
telegrambots
- 4.9.2
+ 5.0.0
diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md
index 91fa288b..e56cf766 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
- 4.9.2
+ 5.0.0
```
2. Using Gradle:
```gradle
- compile "org.telegram:telegrambotsextensions:4.9.2"
+ compile "org.telegram:telegrambotsextensions:5.0.0"
```
\ No newline at end of file
diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml
index 0b16870d..4dd00ed0 100644
--- a/telegrambots-extensions/pom.xml
+++ b/telegrambots-extensions/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.9.2
+ 5.0.0
telegrambotsextensions
@@ -75,7 +75,7 @@
org.telegram
telegrambots
- 4.9.2
+ 5.0.0
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 65344615..39f7c291 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
@@ -98,14 +98,14 @@ public class HelpCommand extends ManCommand {
IBotCommand command = registry.getRegisteredCommand(arguments[0]);
String reply = getManText(command);
try {
- absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
+ absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
} catch (TelegramApiException e) {
e.printStackTrace();
}
} else {
String reply = getHelpText(registry);
try {
- absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
+ absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
} catch (TelegramApiException e) {
e.printStackTrace();
}
diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml
index 7d3ffc4e..0410cf24 100644
--- a/telegrambots-meta/pom.xml
+++ b/telegrambots-meta/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 4.9.2
+ 5.0.0
telegrambots-meta
@@ -70,8 +70,8 @@
UTF-8
UTF-8
4.2.3
- 2.10.1
- 2.10.1
+ 2.11.3
+ 2.11.3
20180813
30.0-jre
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java
index 04f5b694..bd574a87 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java
@@ -1,5 +1,7 @@
package org.telegram.telegrambots.meta;
+import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.generics.BotSession;
import org.telegram.telegrambots.meta.generics.LongPollingBot;
@@ -11,8 +13,7 @@ import java.text.MessageFormat;
/**
* @author Ruben Bermudez
* @version 1.0
- * @brief Bots manager
- * @date 14 of January of 2016
+ * Bots manager
*/
public class TelegramBotsApi {
private static final String webhookUrlFormat = "{0}callback/";
@@ -130,12 +131,13 @@ public class TelegramBotsApi {
/**
* Register a bot in the api that will receive updates using webhook method
* @param bot Bot to register
+ * @param setWebhook Set webhook request to initialize the bot
*/
- public void registerBot(WebhookBot bot) throws TelegramApiRequestException {
+ public void registerBot(WebhookBot bot, SetWebhook setWebhook) throws TelegramApiException {
if (useWebhook) {
bot.onRegister();
webhook.registerWebhook(bot);
- bot.setWebhook(externalUrl + bot.getBotPath(), pathToCertificate);
+ bot.setWebhook(setWebhook);
}
}
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 1f9790ae..6ce34521 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
@@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -16,10 +24,18 @@ import java.io.IOException;
* will be displayed to the user as a notification at the top of the chat screen or as an alert. On
* success, True is returned.
*
- * @note Alternatively, the user can be redirected to the specified URL. For this option to work,
+ * @apiNote Alternatively, the user can be redirected to the specified URL. For this option to work,
* you must enable /setcustomurls for your bot via BotFather and accept the terms.
*
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class AnswerCallbackQuery extends BotApiMethod {
public static final String PATH = "answercallbackquery";
@@ -30,6 +46,7 @@ public class AnswerCallbackQuery extends BotApiMethod {
private static final String CACHETIME_FIELD = "cache_time";
@JsonProperty(CALLBACKQUERYID_FIELD)
+ @NonNull
private String callbackQueryId; ///< Unique identifier for the query to be answered
@JsonProperty(TEXT_FIELD)
private String text; ///< Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
@@ -47,60 +64,11 @@ public class AnswerCallbackQuery extends BotApiMethod {
* Optional The maximum amount of time in seconds that the result of the callback query
* may be cached client-side.
*
- * @note Telegram apps will support caching starting in version 3.14. Defaults to 0.
+ * @apiNote Telegram apps will support caching starting in version 3.14. Defaults to 0.
*/
@JsonProperty(CACHETIME_FIELD)
private Integer cacheTime;
- public AnswerCallbackQuery() {
- super();
- }
-
- public String getCallbackQueryId() {
- return this.callbackQueryId;
- }
-
- public AnswerCallbackQuery setCallbackQueryId(String callbackQueryId) {
- this.callbackQueryId = callbackQueryId;
- return this;
- }
-
- public String getText() {
- return this.text;
- }
-
- public AnswerCallbackQuery setText(String text) {
- this.text = text;
- return this;
- }
-
- public Boolean getShowAlert() {
- return this.showAlert;
- }
-
- public AnswerCallbackQuery setShowAlert(Boolean showAlert) {
- this.showAlert = showAlert;
- return this;
- }
-
- public String getUrl() {
- return url;
- }
-
- public AnswerCallbackQuery setUrl(String url) {
- this.url = url;
- return this;
- }
-
- public Integer getCacheTime() {
- return cacheTime;
- }
-
- public AnswerCallbackQuery setCacheTime(Integer cacheTime) {
- this.cacheTime = cacheTime;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -127,15 +95,4 @@ public class AnswerCallbackQuery extends BotApiMethod {
throw new TelegramApiValidationException("CallbackQueryId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "AnswerCallbackQuery{" +
- "callbackQueryId='" + callbackQueryId + '\'' +
- ", text='" + text + '\'' +
- ", showAlert=" + showAlert +
- ", url='" + url + '\'' +
- ", cacheTime=" + cacheTime +
- '}';
- }
}
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 ee9a685e..649add7e 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
@@ -1,16 +1,23 @@
package org.telegram.telegrambots.meta.api.methods;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
-import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
@@ -19,6 +26,14 @@ import java.util.regex.Pattern;
* @version 1.0
* Use this method to send answers to an inline query. On success, True is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class AnswerInlineQuery extends BotApiMethod {
public static final String PATH = "answerInlineQuery";
@@ -31,8 +46,11 @@ public class AnswerInlineQuery extends BotApiMethod {
private static final String SWITCH_PM_PARAMETER_FIELD = "switch_pm_parameter";
@JsonProperty(INLINEQUERYID_FIELD)
+ @NonNull
private String inlineQueryId; ///< Unique identifier for answered query
@JsonProperty(RESULTS_FIELD)
+ @Singular
+ @NonNull
private List results; ///< A JSON-serialized array of results for the inline query
@JsonProperty(CACHETIME_FIELD)
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
@@ -45,79 +63,6 @@ public class AnswerInlineQuery extends BotApiMethod {
@JsonProperty(SWITCH_PM_PARAMETER_FIELD)
private String switchPmParameter; ///< Optional. Parameter for the start message sent to the bot when user presses the switch button
- public AnswerInlineQuery() {
- super();
- }
-
- public String getInlineQueryId() {
- return inlineQueryId;
- }
-
- public AnswerInlineQuery setInlineQueryId(String inlineQueryId) {
- this.inlineQueryId = inlineQueryId;
- return this;
- }
-
- public List getResults() {
- return results;
- }
-
- public AnswerInlineQuery setResults(List results) {
- this.results = results;
- return this;
- }
-
- @JsonIgnore
- public AnswerInlineQuery setResults(InlineQueryResult... results) {
- this.results = Arrays.asList(results);
- return this;
- }
-
- public Integer getCacheTime() {
- return cacheTime;
- }
-
- public AnswerInlineQuery setCacheTime(Integer cacheTime) {
- this.cacheTime = cacheTime;
- return this;
- }
-
- public Boolean isPersonal() {
- return isPersonal;
- }
-
- public AnswerInlineQuery setPersonal(Boolean personal) {
- isPersonal = personal;
- return this;
- }
-
- public String getNextOffset() {
- return nextOffset;
- }
-
- public AnswerInlineQuery setNextOffset(String nextOffset) {
- this.nextOffset = nextOffset;
- return this;
- }
-
- public String getSwitchPmText() {
- return switchPmText;
- }
-
- public AnswerInlineQuery setSwitchPmText(String switchPmText) {
- this.switchPmText = switchPmText;
- return this;
- }
-
- public String getSwitchPmParameter() {
- return switchPmParameter;
- }
-
- public AnswerInlineQuery setSwitchPmParameter(String switchPmParameter) {
- this.switchPmParameter = switchPmParameter;
- return this;
- }
-
@Override
public void validate() throws TelegramApiValidationException {
if (inlineQueryId == null || inlineQueryId.isEmpty()) {
@@ -164,17 +109,4 @@ public class AnswerInlineQuery extends BotApiMethod {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public String toString() {
- return "AnswerInlineQuery{" +
- "inlineQueryId='" + inlineQueryId + '\'' +
- ", results=" + results +
- ", cacheTime=" + cacheTime +
- ", isPersonal=" + isPersonal +
- ", switchPmText=" + switchPmText +
- ", switchPmParameter=" + switchPmParameter +
- ", nextOffset='" + nextOffset + '\'' +
- '}';
- }
}
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 3519c0da..5679fdfa 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
@@ -2,14 +2,21 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 1.0
@@ -21,6 +28,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* @apiNote The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class AnswerPreCheckoutQuery extends BotApiMethod {
public static final String PATH = "answerPreCheckoutQuery";
@@ -29,56 +44,14 @@ public class AnswerPreCheckoutQuery extends BotApiMethod {
private static final String ERROR_MESSAGE_FIELD = "error_message";
@JsonProperty(PRE_CHECKOUT_QUERY_ID_FIELD)
+ @NonNull
private String preCheckoutQueryId; ///< Unique identifier for the query to be answered
@JsonProperty(OK_FIELD)
+ @NonNull
private Boolean ok; ///< Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
@JsonProperty(ERROR_MESSAGE_FIELD)
private String errorMessage; ///< Optional. Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout
- /**
- * Creates an empty answer pre-checkout query
- */
- public AnswerPreCheckoutQuery() {
- super();
- }
-
- /**
- * Creates an answer pre-checkout query with mandatory parameters
- * @param preCheckoutQueryId Unique identifier for the query to be answered
- * @param ok Specify True if delivery to the specified address is possible and False if there are any problems
- */
- public AnswerPreCheckoutQuery(String preCheckoutQueryId, Boolean ok) {
- this.preCheckoutQueryId = checkNotNull(preCheckoutQueryId);
- this.ok = checkNotNull(ok);
- }
-
- public String getPreCheckoutQueryId() {
- return preCheckoutQueryId;
- }
-
- public AnswerPreCheckoutQuery setPreCheckoutQueryId(String preCheckoutQueryId) {
- this.preCheckoutQueryId = checkNotNull(preCheckoutQueryId);
- return this;
- }
-
- public Boolean getOk() {
- return ok;
- }
-
- public AnswerPreCheckoutQuery setOk(Boolean ok) {
- this.ok = checkNotNull(ok);
- return this;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public AnswerPreCheckoutQuery setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- return this;
- }
-
@Override
public void validate() throws TelegramApiValidationException {
if (preCheckoutQueryId == null || preCheckoutQueryId.isEmpty()) {
@@ -113,13 +86,4 @@ public class AnswerPreCheckoutQuery extends BotApiMethod {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public String toString() {
- return "AnswerPreCheckoutQuery{" +
- "preCheckoutQueryId='" + preCheckoutQueryId + '\'' +
- ", ok=" + ok +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
- }
}
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 d4af9fcf..07f77125 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
@@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-import org.telegram.telegrambots.meta.api.objects.payments.ShippingOption;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.payments.ShippingOption;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 1.0
@@ -22,6 +29,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* On success, True is returned
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class AnswerShippingQuery extends BotApiMethod {
public static final String PATH = "answerShippingQuery";
@@ -31,67 +46,16 @@ public class AnswerShippingQuery extends BotApiMethod {
private static final String ERROR_MESSAGE_FIELD = "error_message";
@JsonProperty(SHIPPING_QUERY_ID_FIELD)
+ @NonNull
private String shippingQueryId; ///< Unique identifier for the query to be answered
@JsonProperty(OK_FIELD)
+ @NonNull
private Boolean ok; ///< Specify True if delivery to the specified address is possible and False if there are any problems
@JsonProperty(SHIPPING_OPTIONS_FIELD)
private List shippingOptions; ///< Optional. Required if ok is True. A JSON-serialized array of available shipping options.
@JsonProperty(ERROR_MESSAGE_FIELD)
private String errorMessage; ///< Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable').
- /**
- * Creates an empty answer shipping query
- */
- public AnswerShippingQuery() {
- super();
- }
-
- /**
- * Creates an answer shipping query with mandatory parameters
- * @param shippingQueryId Unique identifier for the query to be answered
- * @param ok Specify True if delivery to the specified address is possible and False if there are any problems
- */
- public AnswerShippingQuery(String shippingQueryId, Boolean ok) {
- this.shippingQueryId = checkNotNull(shippingQueryId);
- this.ok = checkNotNull(ok);
- }
-
- public String getShippingQueryId() {
- return shippingQueryId;
- }
-
- public AnswerShippingQuery setShippingQueryId(String shippingQueryId) {
- this.shippingQueryId = checkNotNull(shippingQueryId);
- return this;
- }
-
- public Boolean getOk() {
- return ok;
- }
-
- public AnswerShippingQuery setOk(Boolean ok) {
- this.ok = checkNotNull(ok);
- return this;
- }
-
- public List getShippingOptions() {
- return shippingOptions;
- }
-
- public AnswerShippingQuery setShippingOptions(List shippingOptions) {
- this.shippingOptions = shippingOptions;
- return this;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public AnswerShippingQuery setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- return this;
- }
-
@Override
public void validate() throws TelegramApiValidationException {
if (shippingQueryId == null || shippingQueryId.isEmpty()) {
@@ -133,14 +97,4 @@ public class AnswerShippingQuery extends BotApiMethod {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public String toString() {
- return "AnswerShippingQuery{" +
- "shippingQueryId='" + shippingQueryId + '\'' +
- ", ok=" + ok +
- ", shippingOptions=" + shippingOptions +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
- }
}
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
new file mode 100644
index 00000000..4f2fef63
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java
@@ -0,0 +1,158 @@
+package org.telegram.telegrambots.meta.api.methods;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
+import org.telegram.telegrambots.meta.api.objects.MessageId;
+import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author Ruben Bermudez
+ * @version 1.0
+ * Use this method to copy messages of any kind. The method is analogous to the method forwardMessages,
+ * but the copied message doesn't have a link to the original message.
+ * Returns the MessageId of the sent message on success.
+ */
+@SuppressWarnings("unused")
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class CopyMessage extends BotApiMethod {
+ public static final String PATH = "copyMessage";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String FROMCHATID_FIELD = "from_chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
+ private static final String CAPTION_FIELD = "caption";
+ private static final String PARSEMODE_FIELD = "parse_mode";
+ private static final String CAPTIONENTITIES_FIELD = "caption_entities";
+ private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ private static final String REPLYMARKUP_FIELD = "reply_markup";
+
+ @JsonProperty(CHATID_FIELD)
+ @NonNull
+ private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ @JsonProperty(FROMCHATID_FIELD)
+ @NonNull
+ private String fromChatId; ///< Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
+ @JsonProperty(MESSAGEID_FIELD)
+ @NonNull
+ private Integer messageId; ///< Message identifier in the chat specified in from_chat_id
+ @JsonProperty(CAPTION_FIELD)
+ private String caption; ///< Optional. New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
+ @JsonProperty(PARSEMODE_FIELD)
+ private String parseMode; ///< Optional. Mode for parsing entities in the new caption. See formatting options for more details.
+ @JsonProperty(CAPTIONENTITIES_FIELD)
+ private List captionEntities; ///< Optional. List of special entities that appear in the new caption, which can be specified instead of parse_mode
+ @JsonProperty(DISABLENOTIFICATION_FIELD)
+ private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
+ @JsonProperty(REPLYTOMESSAGEID_FIELD)
+ private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
+ /**
+ * Optional.
+ *
+ * Additional interface options.
+ * A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or
+ * to force a reply from the user.
+ */
+ @JsonProperty(REPLYMARKUP_FIELD)
+ @JsonDeserialize()
+ private ReplyKeyboard replyMarkup;
+
+ public void enableNotification() {
+ this.disableNotification = null;
+ }
+
+ public void disableNotification() {
+ this.disableNotification = true;
+ }
+
+ public void enableMarkdown(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.MARKDOWN;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ public void enableHtml(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.HTML;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ public void enableMarkdownV2(boolean enable) {
+ if (enable) {
+ this.parseMode = ParseMode.MARKDOWNV2;
+ } else {
+ this.parseMode = null;
+ }
+ }
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public MessageId deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error copying message", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (chatId == null) {
+ throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
+ }
+ if (fromChatId == null) {
+ throw new TelegramApiValidationException("FromChatId parameter can't be empty", this);
+ }
+ if (messageId == null) {
+ throw new TelegramApiValidationException("MessageId 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 (replyMarkup != null) {
+ replyMarkup.validate();
+ }
+ }
+}
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 f8e5580c..dfb76e4e 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
@@ -2,20 +2,35 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
-import org.telegram.telegrambots.meta.api.objects.Message;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send text messages. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class ForwardMessage extends BotApiMethod {
public static final String PATH = "forwardmessage";
@@ -25,10 +40,13 @@ public class ForwardMessage extends BotApiMethod {
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (or username for channels)
@JsonProperty(FROMCHATID_FIELD)
+ @NonNull
private String fromChatId; ///< Unique identifier for the chat where the original message was sent — User or GroupChat id
@JsonProperty(MESSAGEID_FIELD)
+ @NonNull
private Integer messageId; ///< Unique message identifier
/**
* Optional. Sends the message silently.
@@ -39,99 +57,6 @@ public class ForwardMessage extends BotApiMethod {
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification;
- public ForwardMessage() {
- super();
- }
-
- public ForwardMessage(String chatId, String fromChatId, Integer messageId) {
- this();
- Objects.requireNonNull(chatId);
- Objects.requireNonNull(fromChatId);
- this.chatId = chatId;
- this.fromChatId = fromChatId;
- this.messageId = messageId;
- }
-
- public ForwardMessage(String chatId, Long fromChatId, Integer messageId) {
- this();
- Objects.requireNonNull(chatId);
- Objects.requireNonNull(fromChatId);
- this.chatId = chatId;
- this.fromChatId = fromChatId.toString();
- this.messageId = messageId;
- }
-
- public ForwardMessage(Long chatId, String fromChatId, Integer messageId) {
- this();
- Objects.requireNonNull(chatId);
- Objects.requireNonNull(fromChatId);
- this.chatId = chatId.toString();
- this.fromChatId = fromChatId;
- this.messageId = messageId;
- }
-
- public ForwardMessage(Long chatId, Long fromChatId, Integer messageId) {
- this();
- Objects.requireNonNull(chatId);
- Objects.requireNonNull(fromChatId);
- this.chatId = chatId.toString();
- this.fromChatId = fromChatId.toString();
- this.messageId = messageId;
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public ForwardMessage setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public ForwardMessage setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getFromChatId() {
- return fromChatId;
- }
-
- public ForwardMessage setFromChatId(String fromChatId) {
- this.fromChatId = fromChatId;
- return this;
- }
-
- public ForwardMessage setFromChatId(Long fromChatId) {
- Objects.requireNonNull(fromChatId);
- this.fromChatId = fromChatId.toString();
- return this;
- }
-
- public Integer getMessageId() {
- return messageId;
- }
-
- public ForwardMessage setMessageId(Integer messageId) {
- this.messageId = messageId;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public ForwardMessage enableNotification() {
- this.disableNotification = false;
- return this;
- }
-
- public ForwardMessage disableNotification() {
- this.disableNotification = true;
- return this;
- }
-
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
@@ -164,14 +89,4 @@ public class ForwardMessage extends BotApiMethod {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public String toString() {
- return "ForwardMessage{" +
- "chatId='" + chatId + '\'' +
- ", fromChatId='" + fromChatId + '\'' +
- ", messageId=" + messageId +
- ", disableNotification=" + disableNotification +
- '}';
- }
}
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 9b587833..8a089155 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
@@ -2,9 +2,16 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
-import org.telegram.telegrambots.meta.api.objects.File;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.File;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -21,27 +28,22 @@ import java.io.IOException;
* It is guaranteed that the link will be valid for at least 1 hour.
* When the link expires, a new one can be requested by calling getFile again.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetFile extends BotApiMethod {
public static final String PATH = "getFile";
private static final String FILEID_FIELD = "file_id";
@JsonProperty(FILEID_FIELD)
+ @NonNull
private String fileId; ///< File identifier to get info about
- public GetFile() {
- super();
- }
-
- public String getFileId() {
- return fileId;
- }
-
- public GetFile setFileId(String fileId) {
- this.fileId = fileId;
- return this;
- }
-
@Override
public void validate() throws TelegramApiValidationException {
if (fileId == null) {
@@ -68,11 +70,4 @@ public class GetFile extends BotApiMethod {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public String toString() {
- return "GetFile{" +
- "fileId='" + fileId + '\'' +
- '}';
- }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetMe.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetMe.java
index 26969574..fee2b8bc 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetMe.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetMe.java
@@ -1,9 +1,14 @@
package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.core.type.TypeReference;
-
-import org.telegram.telegrambots.meta.api.objects.User;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.User;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -15,13 +20,15 @@ import java.io.IOException;
* A simple method for testing your bot's auth token. Requires no parameters.
* Returns basic information about the bot in form of a User object
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@AllArgsConstructor
+@Builder
public class GetMe extends BotApiMethod {
public static final String PATH = "getme";
- public GetMe() {
- super();
- }
-
@Override
public String getMethod() {
return PATH;
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 b0495dfa..b1c3ae5d 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
@@ -3,6 +3,15 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.objects.UserProfilePhotos;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@@ -15,6 +24,14 @@ import java.io.IOException;
* @version 1.0
* Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetUserProfilePhotos extends BotApiMethod {
public static final String PATH = "getuserprofilephotos";
@@ -23,9 +40,10 @@ public class GetUserProfilePhotos extends BotApiMethod {
private static final String LIMIT_FIELD = "limit";
@JsonProperty(USERID_FIELD)
+ @NonNull
private Integer userId; ///< Unique identifier of the target user
/**
- * Sequential number of the first photo to be returned. By default, all photos are returned.
+ * Optional. Sequential number of the first photo to be returned. By default, all photos are returned.
*/
@JsonProperty(OFFSET_FIELD)
private Integer offset;
@@ -35,37 +53,6 @@ public class GetUserProfilePhotos extends BotApiMethod {
@JsonProperty(LIMIT_FIELD)
private Integer limit;
- public GetUserProfilePhotos() {
- super();
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public GetUserProfilePhotos setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public Integer getOffset() {
- return offset;
- }
-
- public GetUserProfilePhotos setOffset(Integer offset) {
- this.offset = offset;
- return this;
- }
-
- public Integer getLimit() {
- return limit;
- }
-
- public GetUserProfilePhotos setLimit(Integer limit) {
- this.limit = limit;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -92,13 +79,4 @@ public class GetUserProfilePhotos extends BotApiMethod {
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "GetUserProfilePhotos{" +
- "userId=" + userId +
- ", offset=" + offset +
- ", limit=" + limit +
- '}';
- }
}
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 c78fef8d..c8a5eeb3 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
@@ -2,17 +2,23 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-import org.telegram.telegrambots.meta.api.objects.passport.dataerror.PassportElementError;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.passport.dataerror.PassportElementError;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 4.0.0
@@ -20,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Informs a user that some Telegram Passport data contains errors.
* The user will not be able to resend data, until the errors are fixed
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetPassportDataErrors extends BotApiMethod {
public static final String PATH = "setPassportDataErrors";
@@ -27,47 +40,13 @@ public class SetPassportDataErrors extends BotApiMethod {
private static final String ERRORS_FIELD = "errors";
@JsonProperty(USERID_FIELD)
+ @NonNull
private Integer userId; ///< User identifier
@JsonProperty(ERRORS_FIELD)
+ @NonNull
+ @Singular
private List errors; ///< A JSON-serialized array describing the errors
- public SetPassportDataErrors(Integer userId, List errors) {
- super();
- this.userId = checkNotNull(userId);
- this.errors = checkNotNull(errors);
- }
-
- public SetPassportDataErrors() {
- super();
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public SetPassportDataErrors setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public List getErrors() {
- return errors;
- }
-
- public SetPassportDataErrors setErrors(List errors) {
- this.errors = errors;
- return this;
- }
-
- public SetPassportDataErrors addError(PassportElementError error) {
- error = checkNotNull(error);
- if (this.errors == null) {
- this.errors = new ArrayList<>();
- }
- this.errors.add(error);
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/StopMessageLiveLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/StopMessageLiveLocation.java
index 1f042017..bbddfcb1 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/StopMessageLiveLocation.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/StopMessageLiveLocation.java
@@ -2,8 +2,15 @@ package org.telegram.telegrambots.meta.api.methods;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-import org.telegram.telegrambots.meta.api.objects.Message;
+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.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -18,6 +25,13 @@ import java.io.Serializable;
* before live_period expires. On success, if the message was sent by the bot, the sent Message is returned,
* otherwise True is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class StopMessageLiveLocation extends BotApiMethod {
public static final String PATH = "stopMessageLiveLocation";
@@ -45,51 +59,6 @@ public class StopMessageLiveLocation extends BotApiMethod {
@JsonProperty(REPLYMARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
- public StopMessageLiveLocation() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public StopMessageLiveLocation setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public StopMessageLiveLocation setChatId(Long chatId) {
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getMessageId() {
- return messageId;
- }
-
- public StopMessageLiveLocation setMessageId(Integer messageId) {
- this.messageId = messageId;
- return this;
- }
-
- public String getInlineMessageId() {
- return inlineMessageId;
- }
-
- public StopMessageLiveLocation setInlineMessageId(String inlineMessageId) {
- this.inlineMessageId = inlineMessageId;
- return this;
- }
-
- public InlineKeyboardMarkup getReplyMarkup() {
- return replyMarkup;
- }
-
- public StopMessageLiveLocation setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -142,14 +111,4 @@ public class StopMessageLiveLocation extends BotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "StopMessageLiveLocation{" +
- "chatId='" + chatId + '\'' +
- ", messageId=" + messageId +
- ", inlineMessageId='" + inlineMessageId + '\'' +
- ", replyMarkup=" + replyMarkup +
- '}';
- }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java
index a1347bc3..ea339716 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/GetMyCommands.java
@@ -1,6 +1,12 @@
package org.telegram.telegrambots.meta.api.methods.commands;
import com.fasterxml.jackson.core.type.TypeReference;
+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.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.commands.BotCommand;
@@ -17,13 +23,15 @@ import java.util.ArrayList;
* Requires no parameters.
* Returns Array of BotCommand on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@Builder
public class GetMyCommands extends BotApiMethod> {
public static final String PATH = "getMyCommands";
- public GetMyCommands() {
- super();
- }
-
@Override
public String getMethod() {
return PATH;
@@ -47,9 +55,4 @@ public class GetMyCommands extends BotApiMethod> {
@Override
public void validate() throws TelegramApiValidationException {
}
-
- @Override
- public String toString() {
- return "GetMyCommands{}";
- }
}
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 4828e0db..83aa2d1a 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
@@ -2,6 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.commands;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.commands.BotCommand;
@@ -11,13 +20,18 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 4.7
* Use this method to change the list of the bot's commands. Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetMyCommands extends BotApiMethod {
public static final String PATH = "setMyCommands";
@@ -28,25 +42,10 @@ public class SetMyCommands extends BotApiMethod {
* At most 100 commands can be specified.
*/
@JsonProperty(COMMANDS_FIELD)
+ @Singular
+ @NonNull
private List commands;
- public SetMyCommands() {
- super();
- }
-
- public SetMyCommands(List commands) {
- this.commands = checkNotNull(commands);
- }
-
- public List getCommands() {
- return commands;
- }
-
- public SetMyCommands setCommands(List commands) {
- this.commands = checkNotNull(commands);
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -79,11 +78,4 @@ public class SetMyCommands extends BotApiMethod {
command.validate();
}
}
-
- @Override
- public String toString() {
- return "SetMyCommands{" +
- "commands=" + commands +
- '}';
- }
}
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 2671ffdf..03422be2 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
@@ -19,6 +19,15 @@ package org.telegram.telegrambots.meta.api.methods.games;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@@ -35,12 +44,20 @@ import java.util.ArrayList;
* Will return the score of the specified user and several of his neighbors in a game.
* On success, returns an Array of GameHighScore objects.
*
- * @note This method will currently return scores for the target user,
+ * @apiNote This method will currently return scores for the target user,
* plus two of his closest neighbors on each side. Will also return the top three users
* if the user and his neighbors are not among them.
* Please note that this behavior is subject to change.
*
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetGameHighScores extends BotApiMethod> {
public static final String PATH = "getGameHighScores";
@@ -56,53 +73,9 @@ public class GetGameHighScores extends BotApiMethod> {
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
private String inlineMessageId; ///< Optional Required if chat_id and message_id are not specified. Identifier of the inline message
@JsonProperty(USER_ID_FIELD)
+ @NonNull
private Integer userId; ///> {
}
}
}
-
- @Override
- public String toString() {
- return "GetGameHighScores{" +
- "chatId='" + chatId + '\'' +
- ", messageId=" + messageId +
- ", inlineMessageId='" + inlineMessageId + '\'' +
- ", userId=" + userId +
- '}';
- }
}
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 c7c7c48a..d0999a94 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
@@ -20,6 +20,15 @@ package org.telegram.telegrambots.meta.api.methods.games;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@@ -39,6 +48,14 @@ import java.io.Serializable;
* Returns an error, if the new score is not greater than the user's current score in
* the chat and force is False.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetGameScore extends BotApiMethod {
public static final String PATH = "setGameScore";
@@ -59,84 +76,14 @@ public class SetGameScore extends BotApiMethod {
@JsonProperty(DISABLEEDITMESSAGE_FIELD)
private Boolean disableEditMessage; ///< Optional Pass True, if the game message should not be automatically edited to include the current scoreboard. Defaults to False
@JsonProperty(USER_ID_FIELD)
+ @NonNull
private Integer userId; ///< User identifier
@JsonProperty(SCORE_FIELD)
+ @NonNull
private Integer score; ///< New score, must be positive
@JsonProperty(FORCE_FIELD)
private Boolean force; ///< Optional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
- public SetGameScore() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public Integer getMessageId() {
- return messageId;
- }
-
- public String getInlineMessageId() {
- return inlineMessageId;
- }
-
- public Boolean getDisableEditMessage() {
- return disableEditMessage;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public Integer getScore() {
- return score;
- }
-
- public Boolean getForce() {
- return force;
- }
-
- public SetGameScore setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetGameScore setChatId(Long chatId) {
- this.chatId = chatId.toString();
- return this;
- }
-
- public SetGameScore setMessageId(Integer messageId) {
- this.messageId = messageId;
- return this;
- }
-
- public SetGameScore setInlineMessageId(String inlineMessageId) {
- this.inlineMessageId = inlineMessageId;
- return this;
- }
-
- public SetGameScore setDisableEditMessage(Boolean disableEditMessage) {
- this.disableEditMessage = disableEditMessage;
- return this;
- }
-
- public SetGameScore setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public SetGameScore setScore(Integer score) {
- this.score = score;
- return this;
- }
-
- public SetGameScore setForce(Boolean force) {
- this.force = force;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -192,17 +139,4 @@ public class SetGameScore extends BotApiMethod {
}
}
}
-
- @Override
- public String toString() {
- return "SetGameScore{" +
- "chatId='" + chatId + '\'' +
- ", messageId=" + messageId +
- ", inlineMessageId='" + inlineMessageId + '\'' +
- ", disableEditMessage=" + disableEditMessage +
- ", userId=" + userId +
- ", score=" + score +
- ", force=" + force +
- '}';
- }
}
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 8ee13e40..4b17550c 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -21,43 +26,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DeleteChatPhoto extends BotApiMethod {
public static final String PATH = "deleteChatPhoto";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- public DeleteChatPhoto() {
- super();
- }
-
- public DeleteChatPhoto(String chatId) {
- super();
- this.chatId = checkNotNull(chatId);
- }
-
- public DeleteChatPhoto(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public DeleteChatPhoto setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public DeleteChatPhoto setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -84,11 +68,4 @@ public class DeleteChatPhoto extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "DeleteChatPhoto{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 60d5fdff..bcda48fd 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -20,43 +25,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DeleteChatStickerSet extends BotApiMethod {
public static final String PATH = "deleteChatStickerSet";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public DeleteChatStickerSet() {
- super();
- }
-
- public DeleteChatStickerSet(String chatId) {
- super();
- this.chatId = checkNotNull(chatId);
- }
-
- public DeleteChatStickerSet(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public DeleteChatStickerSet setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public DeleteChatStickerSet setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -83,11 +67,4 @@ public class DeleteChatStickerSet extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "DeleteChatStickerSet{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 41a49474..3f58b587 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -18,43 +23,22 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the
* chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class ExportChatInviteLink extends BotApiMethod {
public static final String PATH = "exportChatInviteLink";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public ExportChatInviteLink() {
- super();
- }
-
- public ExportChatInviteLink(String chatId) {
- super();
- this.chatId = checkNotNull(chatId);
- }
-
- public ExportChatInviteLink(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public ExportChatInviteLink setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public ExportChatInviteLink setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -81,11 +65,4 @@ public class ExportChatInviteLink extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "ExportChatInviteLink{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 30887fab..7c746df2 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
@@ -2,60 +2,43 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Chat;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Chat;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to get information about the chat. Returns Chat object on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetChat extends BotApiMethod {
public static final String PATH = "getChat";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public GetChat() {
- super();
- }
-
- public GetChat(String chatId) {
- super();
- this.chatId = checkNotNull(chatId);
- }
-
- public GetChat(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public GetChat setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public GetChat setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -82,11 +65,4 @@ public class GetChat extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "GetChat{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 a77c0006..71a33493 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
@@ -2,16 +2,22 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.ChatMember;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.ChatMember;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Objects;
/**
* @author Ruben Bermudez
@@ -22,33 +28,22 @@ import java.util.Objects;
* If the chat is a group or a supergroup and no administrators were appointed,
* only the creator will be returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetChatAdministrators extends BotApiMethod> {
public static final String PATH = "getChatAdministrators";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public GetChatAdministrators() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public GetChatAdministrators setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public GetChatAdministrators setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -75,11 +70,4 @@ public class GetChatAdministrators extends BotApiMethod> {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "GetChatAdministrators{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 7e54179e..d42252d5 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
@@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.ChatMember;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.ChatMember;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
@@ -18,6 +24,13 @@ import java.util.Objects;
* Use this method to get information about a member of a chat.
* Returns a ChatMember object on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetChatMember extends BotApiMethod {
public static final String PATH = "getChatMember";
@@ -25,38 +38,12 @@ public class GetChatMember extends BotApiMethod {
private static final String USERID_FIELD = "user_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(USERID_FIELD)
+ @NonNull
private Integer userId; ///< Unique identifier of the target user
- public GetChatMember() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public GetChatMember setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public GetChatMember setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public GetChatMember setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -86,12 +73,4 @@ public class GetChatMember extends BotApiMethod {
throw new TelegramApiValidationException("UserId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "GetChatMember{" +
- "chatId='" + chatId + '\'' +
- ", userId='" + userId + '\'' +
- '}';
- }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java
index 6461f195..f8ea4861 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java
@@ -2,46 +2,42 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to get the number of members in a chat. Returns Int on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetChatMembersCount extends BotApiMethod {
public static final String PATH = "getChatMembersCount";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public GetChatMembersCount() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public GetChatMembersCount setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public GetChatMembersCount setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -68,11 +64,4 @@ public class GetChatMembersCount extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "GetChatMembersCount{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java
index b3b574a1..86ca18a8 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java
@@ -3,7 +3,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@@ -13,9 +21,6 @@ import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -28,6 +33,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* group. Otherwise members may only be removed by the group's creator or by the member that added
* them.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class KickChatMember extends BotApiMethod {
public static final String PATH = "kickchatmember";
@@ -36,72 +49,27 @@ public class KickChatMember extends BotApiMethod {
private static final String UNTILDATE_FIELD = "until_date";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(USER_ID_FIELD)
+ @NonNull
private Integer userId; ///< Required. Unique identifier of the target user
@JsonProperty(UNTILDATE_FIELD)
- private Integer untilDate; ///< Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
+ private Integer untilDate; ///< Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
- public KickChatMember() {
- super();
- }
-
- public KickChatMember(String chatId, Integer userId) {
- this.chatId = checkNotNull(chatId);
- this.userId = checkNotNull(userId);
- }
-
- public KickChatMember(Long chatId, Integer userId) {
- this.chatId = checkNotNull(chatId).toString();
- this.userId = checkNotNull(userId);
- }
-
-
- public String getChatId() {
- return chatId;
- }
-
- public KickChatMember setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public KickChatMember setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public KickChatMember setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public Integer getUntilDate() {
- return untilDate;
- }
-
- public KickChatMember setUntilDate(Integer untilDateInSeconds) {
- this.untilDate = untilDateInSeconds;
- return this;
+ @JsonIgnore
+ public void setUntilDateInstant(Instant instant) {
+ setUntilDate((int) instant.getEpochSecond());
}
@JsonIgnore
- public KickChatMember setUntilDate(Instant instant) {
- return setUntilDate((int) instant.getEpochSecond());
+ public void setUntilDateDateTime(ZonedDateTime date) {
+ setUntilDateInstant(date.toInstant());
}
@JsonIgnore
- public KickChatMember setUntilDate(ZonedDateTime date) {
- return setUntilDate(date.toInstant());
- }
-
- public KickChatMember forTimePeriod(Duration duration) {
- return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
+ public void forTimePeriodDuration(Duration duration) {
+ setUntilDateInstant(Instant.now().plusMillis(duration.toMillis()));
}
@Override
@@ -133,13 +101,4 @@ public class KickChatMember extends BotApiMethod {
throw new TelegramApiValidationException("UserId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "KickChatMember{" +
- "chatId='" + chatId + '\'' +
- ", userId=" + userId +
- ", untilDate=" + untilDate +
- '}';
- }
}
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 ea4d9a9d..b3ac05a8 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
@@ -2,47 +2,42 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class LeaveChat extends BotApiMethod {
public static final String PATH = "leaveChat";
private static final String CHATID_FIELD = "chat_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
- public LeaveChat() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public LeaveChat setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public LeaveChat setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -69,11 +64,4 @@ public class LeaveChat extends BotApiMethod {
throw new TelegramApiValidationException("ChatId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "LeaveChat{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 94932ba9..ad8f5116 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
@@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -20,6 +26,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Pass False for all boolean parameters to demote a user. Returns True on success.
*
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class PromoteChatMember extends BotApiMethod {
public static final String PATH = "promoteChatMember";
@@ -33,137 +47,32 @@ public class PromoteChatMember extends BotApiMethod {
private static final String CANRESTRICTMEMBERS_FIELD = "can_restrict_members";
private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members";
+ private static final String ISANONYMOUS_FIELD = "is_anonymous";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(USER_ID_FIELD)
+ @NonNull
private Integer userId; ///< Required. Unique identifier of the target user
@JsonProperty(CANCHANGEINFORMATION_FIELD)
- private Boolean canChangeInformation; ///< Pass True, if the administrator can change chat title, photo and other settings
+ private Boolean canChangeInformation; ///< Optional. Pass True, if the administrator can change chat title, photo and other settings
@JsonProperty(CANPOSTMESSAGES_FIELD)
- private Boolean canPostMessages; ///< Pass True, if the administrator can create channel posts, channels only
+ private Boolean canPostMessages; ///< Optional. Pass True, if the administrator can create channel posts, channels only
@JsonProperty(CANEDITMESSAGES_FIELD)
- private Boolean canEditMessages; ///< Pass True, if the administrator can edit messages of other users, channels only
+ private Boolean canEditMessages; ///< Optional. Pass True, if the administrator can edit messages of other users, channels only
@JsonProperty(CANDELETEMESSAGES_FIELD)
- private Boolean canDeleteMessages; ///< Pass True, if the administrator can delete messages of other users
+ private Boolean canDeleteMessages; ///< Optional. Pass True, if the administrator can delete messages of other users
@JsonProperty(CANINVITEUSERS_FIELD)
- private Boolean canInviteUsers; ///< Pass True, if the administrator can invite new users to the chat
+ private Boolean canInviteUsers; ///< Optional. Pass True, if the administrator can invite new users to the chat
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
- private Boolean canRestrictMembers; ///< Pass True, if the administrator can restrict, ban or unban chat members
+ private Boolean canRestrictMembers; ///< Optional. Pass True, if the administrator can restrict, ban or unban chat members
@JsonProperty(CANPINMESSAGES_FIELD)
- private Boolean canPinMessages; ///< Pass True, if the administrator can pin messages
+ private Boolean canPinMessages; ///< Optional. Pass True, if the administrator can pin messages
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
- private Boolean canPromoteMembers; ///< Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administators that were appointed by the him)
-
- public PromoteChatMember() {
- super();
- }
-
- public PromoteChatMember(String chatId, Integer userId) {
- this.chatId = checkNotNull(chatId);
- this.userId = checkNotNull(userId);
- }
-
- public PromoteChatMember(Long chatId, Integer userId) {
- this.chatId = checkNotNull(chatId).toString();
- this.userId = checkNotNull(userId);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public PromoteChatMember setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public PromoteChatMember setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public PromoteChatMember setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public Boolean getCanChangeInformation() {
- return canChangeInformation;
- }
-
- public PromoteChatMember setCanChangeInformation(Boolean canChangeInformation) {
- this.canChangeInformation = canChangeInformation;
- return this;
- }
-
- public Boolean getCanPostMessages() {
- return canPostMessages;
- }
-
- public PromoteChatMember setCanPostMessages(Boolean canPostMessages) {
- this.canPostMessages = canPostMessages;
- return this;
- }
-
- public Boolean getCanEditMessages() {
- return canEditMessages;
- }
-
- public PromoteChatMember setCanEditMessages(Boolean canEditMessages) {
- this.canEditMessages = canEditMessages;
- return this;
- }
-
- public Boolean getCanDeleteMessages() {
- return canDeleteMessages;
- }
-
- public PromoteChatMember setCanDeleteMessages(Boolean canDeleteMessages) {
- this.canDeleteMessages = canDeleteMessages;
- return this;
- }
-
- public Boolean getCanInviteUsers() {
- return canInviteUsers;
- }
-
- public PromoteChatMember setCanInviteUsers(Boolean canInviteUsers) {
- this.canInviteUsers = canInviteUsers;
- return this;
- }
-
- public Boolean getCanRestrictMembers() {
- return canRestrictMembers;
- }
-
- public PromoteChatMember setCanRestrictMembers(Boolean canRestrictMembers) {
- this.canRestrictMembers = canRestrictMembers;
- return this;
- }
-
- public Boolean getCanPinMessages() {
- return canPinMessages;
- }
-
- public PromoteChatMember setCanPinMessages(Boolean canPinMessages) {
- this.canPinMessages = canPinMessages;
- return this;
- }
-
- public Boolean getCanPromoteMembers() {
- return canPromoteMembers;
- }
-
- public PromoteChatMember setCanPromoteMembers(Boolean canPromoteMembers) {
- this.canPromoteMembers = canPromoteMembers;
- return this;
- }
+ private Boolean canPromoteMembers; ///< Optional. Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administators that were appointed by the him)
+ @JsonProperty(ISANONYMOUS_FIELD)
+ private Boolean isAnonymous; ///< Optional. Pass True, if the administrator's presence in the chat is hidden
@Override
public String getMethod() {
@@ -195,20 +104,4 @@ public class PromoteChatMember extends BotApiMethod {
throw new TelegramApiValidationException("UserId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "PromoteChatMember{" +
- "chatId='" + chatId + '\'' +
- ", userId=" + userId +
- ", canChangeInformation=" + canChangeInformation +
- ", canPostMessages=" + canPostMessages +
- ", canEditMessages=" + canEditMessages +
- ", canDeleteMessages=" + canDeleteMessages +
- ", canInviteUsers=" + canInviteUsers +
- ", canRestrictMembers=" + canRestrictMembers +
- ", canPinMessages=" + canPinMessages +
- ", canPromoteMembers=" + canPromoteMembers +
- '}';
- }
}
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 137c66bb..d4f8acee 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
@@ -3,6 +3,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
@@ -13,9 +22,6 @@ import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -26,6 +32,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
*/
@SuppressWarnings("WeakerAccess")
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class RestrictChatMember extends BotApiMethod {
public static final String PATH = "restrictchatmember";
@@ -39,19 +53,11 @@ public class RestrictChatMember extends BotApiMethod {
private static final String PERMISSIONS_FIELD = "permissions";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(USER_ID_FIELD)
+ @NonNull
private Integer userId; ///< Required. Unique identifier of the target user
- @JsonProperty(UNTILDATE_FIELD)
- private Integer untilDate; ///< Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
- @JsonProperty(CANSENDMESSAGES_FIELD)
- private Boolean canSendMessages; ///< Pass True, if the user can send text messages, contacts, locations and venues
- @JsonProperty(CANSENDMEDIAMESSAGES_FIELD)
- private Boolean canSendMediaMessages; ///< Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
- @JsonProperty(CANSENDOTHERMESSAGES_FIELD)
- private Boolean canSendOtherMessages; ///< Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
- @JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
- private Boolean canAddWebPagePreviews; ///< Pass True, if the user may add web page previews to their messages, implies can_send_messages
/**
* Optional
* Date when restrictions will be lifted for the user, unix time.
@@ -59,76 +65,24 @@ public class RestrictChatMember extends BotApiMethod {
* from the current time, they are considered to be restricted forever
*/
@JsonProperty(PERMISSIONS_FIELD)
+ @NonNull
private ChatPermissions permissions;
+ @JsonProperty(UNTILDATE_FIELD)
+ private Integer untilDate; ///< Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
- public RestrictChatMember() {
- super();
- }
-
- public RestrictChatMember(String chatId, Integer userId) {
- this.chatId = checkNotNull(chatId);
- this.userId = checkNotNull(userId);
- }
-
- public RestrictChatMember(Long chatId, Integer userId) {
- this.chatId = checkNotNull(chatId).toString();
- this.userId = checkNotNull(userId);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public RestrictChatMember setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public RestrictChatMember setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public RestrictChatMember setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public Integer getUntilDate() {
- return untilDate;
- }
-
- public RestrictChatMember setUntilDate(Integer untilDateInSeconds) {
- this.untilDate = untilDateInSeconds;
- return this;
+ @JsonIgnore
+ public void setUntilDateInstant(Instant instant) {
+ setUntilDate((int) instant.getEpochSecond());
}
@JsonIgnore
- public RestrictChatMember setUntilDate(Instant instant) {
- return setUntilDate((int) instant.getEpochSecond());
+ public void setUntilDateDateTime(ZonedDateTime date) {
+ setUntilDateInstant(date.toInstant());
}
@JsonIgnore
- public RestrictChatMember setUntilDate(ZonedDateTime date) {
- return setUntilDate(date.toInstant());
- }
-
- @JsonIgnore
- public RestrictChatMember forTimePeriod(Duration duration) {
- return setUntilDate(Instant.now().plusMillis(duration.toMillis()));
- }
-
- public ChatPermissions getPermissions() {
- return permissions;
- }
-
- public void setPermissions(ChatPermissions permissions) {
- this.permissions = permissions;
+ public void forTimePeriodDuration(Duration duration) {
+ setUntilDateInstant(Instant.now().plusMillis(duration.toMillis()));
}
@Override
@@ -163,18 +117,4 @@ public class RestrictChatMember extends BotApiMethod {
throw new TelegramApiValidationException("Permissions can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "RestrictChatMember{" +
- "chatId='" + chatId + '\'' +
- ", userId=" + userId +
- ", untilDate=" + untilDate +
- ", canSendMessages=" + canSendMessages +
- ", canSendMediaMessages=" + canSendMediaMessages +
- ", canSendOtherMessages=" + canSendOtherMessages +
- ", canAddWebPagePreviews=" + canAddWebPagePreviews +
- ", permissions=" + permissions +
- '}';
- }
}
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 c88a3d54..05e5c7ae 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -18,6 +23,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatAdministratorCustomTitle extends BotApiMethod {
public static final String PATH = "setChatAdministratorCustomTitle";
@@ -26,65 +38,15 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod {
private static final String CUSTOMTITLE_FIELD = "custom_title";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(USERID_FIELD)
+ @NonNull
private Integer userId; ///< Unique identifier of the target user
@JsonProperty(CUSTOMTITLE_FIELD)
+ @NonNull
private String customTitle; ///< New custom title for the administrator; 0-16 characters, emoji are not allowed
- public SetChatAdministratorCustomTitle() {
- super();
- }
-
- public SetChatAdministratorCustomTitle(String chatId, Integer userId, String customTitle) {
- super();
- this.chatId = checkNotNull(chatId);
- this.userId = checkNotNull(userId);
- this.customTitle = checkNotNull(customTitle);
- }
-
- public SetChatAdministratorCustomTitle(Long chatId, Integer userId, String customTitle) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.userId = checkNotNull(userId);
- this.customTitle = checkNotNull(customTitle);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatAdministratorCustomTitle setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatAdministratorCustomTitle setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public SetChatAdministratorCustomTitle setUserId(Integer userId) {
- checkNotNull(userId);
- this.userId = userId;
- return this;
- }
-
- public String getCustomTitle() {
- return customTitle;
- }
-
- public SetChatAdministratorCustomTitle setCustomTitle(String customTitle) {
- checkNotNull(customTitle);
- this.customTitle = customTitle;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -117,13 +79,4 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod {
throw new TelegramApiValidationException("CustomTitle can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatDescription{" +
- "chatId='" + chatId + '\'' +
- "userId='" + userId + '\'' +
- ", customTitle='" + customTitle + '\'' +
- '}';
- }
}
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 fc2a3754..57c5ec35 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
@@ -2,15 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -19,6 +25,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatDescription extends BotApiMethod {
public static final String PATH = "setChatDescription";
@@ -26,50 +40,10 @@ public class SetChatDescription extends BotApiMethod {
private static final String DESCRIPTION_FIELD = "description";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(DESCRIPTION_FIELD)
- private String description; ///< New chat description, 0-255 characters
-
- public SetChatDescription() {
- super();
- }
-
- public SetChatDescription(String chatId, String description) {
- super();
- this.chatId = checkNotNull(chatId);
- this.description = checkNotNull(description);
- }
-
- public SetChatDescription(Long chatId, String description) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.description = checkNotNull(description);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatDescription setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatDescription setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public SetChatDescription setDescription(String description) {
- Objects.requireNonNull(description);
- this.description = description;
- return this;
- }
+ private String description; ///< Optional. New chat description, 0-255 characters
@Override
public String getMethod() {
@@ -100,12 +74,4 @@ public class SetChatDescription extends BotApiMethod {
throw new TelegramApiValidationException("Description can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatDescription{" +
- "chatId='" + chatId + '\'' +
- ", description='" + description + '\'' +
- '}';
- }
}
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 790c172d..f92a7791 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
@@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
@@ -9,9 +17,6 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* The bot must be an administrator in the group or a supergroup
* for this to work and must have the can_restrict_members admin rights.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatPermissions extends BotApiMethod {
public static final String PATH = "setChatPermissions";
@@ -27,51 +39,12 @@ public class SetChatPermissions extends BotApiMethod {
private static final String PERMISSIONS_FIELD = "permissions";
@JsonProperty(CHAT_ID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
@JsonProperty(PERMISSIONS_FIELD)
+ @NonNull
private ChatPermissions permissions; ///< New default chat permissions
- public SetChatPermissions() {
- super();
- }
-
- public SetChatPermissions(String chatId, ChatPermissions permissions) {
- super();
- this.chatId = checkNotNull(chatId);
- this.permissions = checkNotNull(permissions);
- }
-
- public SetChatPermissions(Long chatId, ChatPermissions permissions) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.permissions = checkNotNull(permissions);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatPermissions setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatPermissions setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public ChatPermissions getPermissions() {
- return permissions;
- }
-
- public SetChatPermissions setPermissions(ChatPermissions permissions) {
- Objects.requireNonNull(permissions);
- this.permissions = permissions;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -101,12 +74,4 @@ public class SetChatPermissions extends BotApiMethod {
throw new TelegramApiValidationException("Permissions can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatPermissions{" +
- "chatId='" + chatId + '\'' +
- ", permissions=" + permissions +
- '}';
- }
}
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 5d47a4f1..f8497edd 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
@@ -1,17 +1,21 @@
package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -22,87 +26,23 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatPhoto extends PartialBotApiMethod {
public static final String PATH = "setChatPhoto";
public static final String CHATID_FIELD = "chat_id";
public static final String PHOTO_FIELD = "photo";
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
- private String photoName; ///< Name of new chat photo
- private InputStream photoStream; ///< New chat photo as InputStream, uploaded using multipart/form-data
- private File photo; ///< New chat photo as File, uploaded using multipart/form-data
-
- public SetChatPhoto() {
- super();
- }
-
- public SetChatPhoto(String chatId, File photo) {
- super();
- this.chatId = checkNotNull(chatId);
- this.photo = checkNotNull(photo);
- }
-
- public SetChatPhoto(String chatId, InputStream photoStream, String photoName) {
- super();
- this.chatId = checkNotNull(chatId);
- this.photoStream = checkNotNull(photoStream);
- this.photoName = checkNotNull(photoName);
- }
-
-
- public SetChatPhoto(Long chatId, File photo) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.photo = checkNotNull(photo);
- }
-
- public SetChatPhoto(Long chatId, InputStream photoStream, String photoName) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.photoStream = checkNotNull(photoStream);
- this.photoName = checkNotNull(photoName);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatPhoto setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatPhoto setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public SetChatPhoto setPhoto(File file) {
- this.photo = file;
- return this;
- }
-
- public SetChatPhoto setNewPhoto(String photoName, InputStream inputStream) {
- Objects.requireNonNull(photoName, "photoName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.photoName = photoName;
- this.photoStream = inputStream;
- return this;
- }
-
- public String getPhotoName() {
- return photoName;
- }
-
- public InputStream getPhotoStream() {
- return photoStream;
- }
-
- public File getPhoto() {
- return photo;
- }
+ @NonNull
+ private InputFile photo; ///< New chat photo as InputStream, uploaded using multipart/form-data
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
@@ -124,22 +64,8 @@ public class SetChatPhoto extends PartialBotApiMethod {
if (chatId == null || chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
- if (photo == null) {
- if (photoStream == null) {
- throw new TelegramApiValidationException("Photo parameter is required", this);
- } else if (photoName == null || photoName.isEmpty()){
- throw new TelegramApiValidationException("Photo name can't be empty", this);
- }
+ if (photo == null || !photo.isNew()) {
+ throw new TelegramApiValidationException("Photo parameter is required and must be a new file to upload", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatPhoto{" +
- "chatId='" + chatId + '\'' +
- ", photoName='" + photoName + '\'' +
- ", photoStream=" + photoStream +
- ", photo=" + photo +
- '}';
- }
}
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 12044405..6aefd939 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatStickerSet extends BotApiMethod {
public static final String PATH = "setChatStickerSet";
@@ -27,50 +39,12 @@ public class SetChatStickerSet extends BotApiMethod {
private static final String STICKERSETNAME_FIELD = "sticker_set_name";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(STICKERSETNAME_FIELD)
+ @NonNull
private String stickerSetName; ///< Name of the sticker set to be set as the group sticker set
- public SetChatStickerSet() {
- super();
- }
-
- public SetChatStickerSet(String chatId, String stickerSetName) {
- super();
- this.chatId = checkNotNull(chatId);
- this.stickerSetName = checkNotNull(stickerSetName);
- }
-
- public SetChatStickerSet(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatStickerSet setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatStickerSet setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getStickerSetName() {
- return stickerSetName;
- }
-
- public SetChatStickerSet setStickerSetName(String stickerSetName) {
- Objects.requireNonNull(stickerSetName);
- this.stickerSetName = stickerSetName;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -100,12 +74,4 @@ public class SetChatStickerSet extends BotApiMethod {
throw new TelegramApiValidationException("StickerSetName can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatStickerSet{" +
- "chatId='" + chatId + '\'' +
- ", stickerSetName='" + stickerSetName + '\'' +
- '}';
- }
}
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 aad15419..5138a561 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
@@ -2,15 +2,20 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -21,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* @apiNote In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetChatTitle extends BotApiMethod {
public static final String PATH = "setChatTitle";
@@ -28,51 +40,12 @@ public class SetChatTitle extends BotApiMethod {
private static final String TITLE_FIELD = "title";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(TITLE_FIELD)
+ @NonNull
private String title; ///< Required. New chat title, 1-255 characters
- public SetChatTitle() {
- super();
- }
-
- public SetChatTitle(String chatId, String title) {
- super();
- this.chatId = checkNotNull(chatId);
- this.title = checkNotNull(title);
- }
-
- public SetChatTitle(Long chatId, String title) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.title = checkNotNull(title);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SetChatTitle setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SetChatTitle setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getTitle() {
- return title;
- }
-
- public SetChatTitle setTitle(String title) {
- Objects.requireNonNull(title);
- this.title = title;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -102,12 +75,4 @@ public class SetChatTitle extends BotApiMethod {
throw new TelegramApiValidationException("Title can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "SetChatTitle{" +
- "chatId='" + chatId + '\'' +
- ", title='" + title + '\'' +
- '}';
- }
}
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 adfd5202..f3b31ea1 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
@@ -2,74 +2,58 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
- * Use this method to unban a previously kicked user in a supergroup. The user will not
- * return to the group automatically, but will be able to join via link, etc. The bot must be an
- * administrator in the group for this to work. Returns True on success.
+ * Use this method to unban a previously kicked user in a supergroup or channel.
+ * Returns True on success.
+ *
+ * @apiNote The user will not return to the group or channel automatically, but will be able to join via link, etc.
+ * @apiNote The bot must be an administrator for this to work.
+ * @apiNote By default, this method guarantees that after the call the user is not a member of the chat,
+ * but will be able to join it.
+ * @apiNote So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class UnbanChatMember extends BotApiMethod {
public static final String PATH = "unbanchatmember";
private static final String CHATID_FIELD = "chat_id";
- private static final String USER_ID_FIELD = "user_id";
+ private static final String USERID_FIELD = "user_id";
+ private static final String ONLYISBANNED_FIELD = "only_if_banned";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
- @JsonProperty(USER_ID_FIELD)
+ @JsonProperty(USERID_FIELD)
+ @NonNull
private Integer userId; ///< Required. Unique identifier of the target user
+ @JsonProperty(ONLYISBANNED_FIELD)
+ private Boolean onlyIfBanned; ///< Optional. Do nothing if the user is not banned
- public UnbanChatMember() {
- super();
- }
-
- public UnbanChatMember(String chatId, Integer userId) {
- super();
- this.chatId = checkNotNull(chatId);
- this.userId = checkNotNull(userId);
- }
-
- public UnbanChatMember(Long chatId, Integer userId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.userId = checkNotNull(userId);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public UnbanChatMember setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public UnbanChatMember setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public UnbanChatMember setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
@Override
public String getMethod() {
@@ -100,12 +84,4 @@ public class UnbanChatMember extends BotApiMethod {
throw new TelegramApiValidationException("UserId can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "UnbanChatMember{" +
- "chatId='" + chatId + '\'' +
- ", userId='" + userId +
- '}';
- }
}
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 cfbf0bd1..dd5c5ae0 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
@@ -2,24 +2,39 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 3.1
- * Use this method to pin a message in a group, a supergroup or a channel.
- * The bot must be an administrator in the chat for this to work and must
- * have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
- * admin right in the channel. Returns True on success.
+ * Use this method to add a message to the list of pinned messages in a chat.
+ * Returns True on success.
+ *
+ * @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must
+ * have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class PinChatMessage extends BotApiMethod {
public static final String PATH = "pinChatMessage";
@@ -28,8 +43,10 @@ public class PinChatMessage extends BotApiMethod {
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(MESSAGEID_FIELD)
+ @NonNull
private Integer messageId; ///< Required. Identifier of a message to pin
/**
* Pass True, if it is not necessary to send a notification to all chat members about the new pinned message.
@@ -38,56 +55,6 @@ public class PinChatMessage extends BotApiMethod {
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification;
- public PinChatMessage() {
- super();
- }
-
- public PinChatMessage(String chatId, Integer messageId) {
- super();
- this.chatId = checkNotNull(chatId);
- this.messageId = checkNotNull(messageId);
- }
-
- public PinChatMessage(Long chatId, Integer messageId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.messageId = checkNotNull(messageId);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public PinChatMessage setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public PinChatMessage setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getMessageId() {
- return messageId;
- }
-
- public PinChatMessage setMessageId(Integer messageId) {
- Objects.requireNonNull(messageId);
- this.messageId = messageId;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public PinChatMessage setDisableNotification(Boolean disableNotification) {
- this.disableNotification = disableNotification;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -117,13 +84,4 @@ public class PinChatMessage extends BotApiMethod {
throw new TelegramApiValidationException("MessageId parameter can't be null", this);
}
}
-
- @Override
- public String toString() {
- return "PinChatMessage{" +
- "chatId='" + chatId + '\'' +
- ", messageId=" + messageId +
- ", disableNotification=" + disableNotification +
- '}';
- }
}
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
new file mode 100644
index 00000000..e63ee5a7
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java
@@ -0,0 +1,72 @@
+package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 3.1
+ * Use this method to clear the list of pinned messages in a chat.
+ * Returns True on success.
+ *
+ * @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to
+ * work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin
+ * right in a channel.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class UnpinAllChatMessages extends BotApiMethod {
+ public static final String PATH = "unpinAllChatMessages";
+
+ private static final String CHATID_FIELD = "chat_id";
+
+ @JsonProperty(CHATID_FIELD)
+ @NonNull
+ private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error unpinning chat message", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (chatId == null || chatId.isEmpty()) {
+ throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
+ }
+ }
+}
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 b489a2f4..c5a44bce 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
@@ -2,60 +2,57 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 3.1
- * Use this method to unpin a message in a group, a supergroup or a channel.
- * The bot must be an administrator in the chat for this to work and must have
- * the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
- * admin right in the channel. Returns True on success.
+ * Use this method to remove a message from the list of pinned messages in a chat.
+ * Returns True on success.
+ *
+ * @apiNote If the chat is not a private chat, the bot must be an administrator in the chat for this to work
+ * and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages'
+ * admin right in a channel.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class UnpinChatMessage extends BotApiMethod {
public static final String PATH = "unpinChatMessage";
private static final String CHATID_FIELD = "chat_id";
+ private static final String MESSAGEID_FIELD = "message_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
-
- public UnpinChatMessage() {
- super();
- }
-
- public UnpinChatMessage(String chatId) {
- super();
- this.chatId = checkNotNull(chatId);
- }
-
- public UnpinChatMessage(Long chatId) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public UnpinChatMessage setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public UnpinChatMessage setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
+ /**
+ * Optional.
+ * Identifier of a message to unpin.
+ *
+ * @apiNote If not specified, the most recent pinned message (by send date) will be unpinned.
+ */
+ @JsonProperty(MESSAGEID_FIELD)
+ private Integer messageId;
@Override
public String getMethod() {
@@ -83,11 +80,4 @@ public class UnpinChatMessage extends BotApiMethod {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "UnpinChatMessage{" +
- "chatId='" + chatId + '\'' +
- '}';
- }
}
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 8a6dd3a9..b4c6e24a 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
@@ -3,19 +3,26 @@ package org.telegram.telegrambots.meta.api.methods.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -25,6 +32,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendPoll extends BotApiMethod {
public static final String PATH = "sendPoll";
@@ -43,17 +58,23 @@ public class SendPoll extends BotApiMethod {
private static final String CLOSEDATE_FIELD = "close_date";
private static final String EXPLANATION_FIELD = "explanation";
private static final String EXPLANATIONPARSEMODE_FIELD = "explanation_parse_mode";
+ private static final String EXPLANATION_ENTITIES_FIELD = "explanation_entities";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername).
* A native poll can't be sent to a private chat.
*/
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(QUESTION_FIELD)
- private String question; ///< Poll question, 1-255 characters
+ @NonNull
+ private String question; ///< Poll question, 1-300 characters
@JsonProperty(OPTIONS_FIELD)
- private List options = new ArrayList<>(); ///< List of answer options, 2-10 strings 1-100 characters each
+ @Singular
+ @NonNull
+ private List options; ///< List of answer options, 2-10 strings 1-100 characters each
@JsonProperty(ISANONYMOUS_FIELD)
private Boolean isAnonymous; ///< Optional True, if the poll needs to be anonymous, defaults to True
@JsonProperty(TYPE_FIELD)
@@ -79,168 +100,18 @@ public class SendPoll extends BotApiMethod {
private String explanation; ///< Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
@JsonProperty(EXPLANATIONPARSEMODE_FIELD)
private String explanationParseMode; ///< Optional. Mode for parsing entities in the explanation. See formatting options for more details.
+ @JsonProperty(EXPLANATION_ENTITIES_FIELD)
+ @Singular
+ private List captionEntities; ///< Optional. List of special entities that appear in the poll explanation, which can be specified instead of parse_mode
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendPoll() {
- super();
- }
-
- public SendPoll(String chatId, String question, List options) {
- this.chatId = checkNotNull(chatId);
- this.question = checkNotNull(question);
- this.options = checkNotNull(options);
- }
-
- public SendPoll(Long chatId, String question, List options) {
- this.chatId = checkNotNull(chatId).toString();
- this.question = checkNotNull(question);
- this.options = checkNotNull(options);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendPoll setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendPoll setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getQuestion() {
- return question;
- }
-
- public SendPoll setQuestion(String question) {
- this.question = question;
- return this;
- }
-
- public List getOptions() {
- return options;
- }
-
- public SendPoll setOptions(List options) {
- this.options = options;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendPoll setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendPoll setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendPoll enableNotification() {
+ public void enableNotification() {
this.disableNotification = null;
- return this;
}
- public SendPoll disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public Boolean getAnonymous() {
- return isAnonymous;
- }
-
- public SendPoll setAnonymous(Boolean anonymous) {
- isAnonymous = anonymous;
- return this;
- }
-
- public String getType() {
- return type;
- }
-
- public SendPoll setType(String type) {
- this.type = type;
- return this;
- }
-
- public Boolean getAllowMultipleAnswers() {
- return allowMultipleAnswers;
- }
-
- public SendPoll setAllowMultipleAnswers(Boolean allowMultipleAnswers) {
- this.allowMultipleAnswers = allowMultipleAnswers;
- return this;
- }
-
- public Integer getCorrectOptionId() {
- return correctOptionId;
- }
-
- public SendPoll setCorrectOptionId(Integer correctOptionId) {
- this.correctOptionId = correctOptionId;
- return this;
- }
-
- public Boolean getClosed() {
- return isClosed;
- }
-
- public SendPoll setClosed(Boolean closed) {
- isClosed = closed;
- return this;
- }
-
- public Integer getOpenPeriod() {
- return openPeriod;
- }
-
- public SendPoll setOpenPeriod(Integer openPeriod) {
- this.openPeriod = openPeriod;
- return this;
- }
-
- public Integer getCloseDate() {
- return closeDate;
- }
-
- public SendPoll setCloseDate(Integer closeDate) {
- this.closeDate = closeDate;
- return this;
- }
-
- public String getExplanation() {
- return explanation;
- }
-
- public SendPoll setExplanation(String explanation) {
- this.explanation = explanation;
- return this;
- }
-
- public String getExplanationParseMode() {
- return explanationParseMode;
- }
-
- public SendPoll setExplanationParseMode(String explanationParseMode) {
- this.explanationParseMode = explanationParseMode;
- return this;
}
@Override
@@ -287,57 +158,11 @@ public class SendPoll extends BotApiMethod {
if (options.parallelStream().anyMatch(x -> x.isEmpty() || x.length() > 100)) {
throw new TelegramApiValidationException("Options parameter values must be between 1 and 100 chars length", this);
}
+ if (explanationParseMode != null && (captionEntities != null && !captionEntities.isEmpty()) ) {
+ throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
+ }
if (replyMarkup != null) {
replyMarkup.validate();
}
}
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof SendPoll)) return false;
- SendPoll sendPoll = (SendPoll) o;
- return Objects.equals(chatId, sendPoll.chatId) &&
- Objects.equals(question, sendPoll.question) &&
- Objects.equals(options, sendPoll.options) &&
- Objects.equals(isAnonymous, sendPoll.isAnonymous) &&
- Objects.equals(type, sendPoll.type) &&
- Objects.equals(allowMultipleAnswers, sendPoll.allowMultipleAnswers) &&
- Objects.equals(correctOptionId, sendPoll.correctOptionId) &&
- Objects.equals(isClosed, sendPoll.isClosed) &&
- Objects.equals(disableNotification, sendPoll.disableNotification) &&
- Objects.equals(replyToMessageId, sendPoll.replyToMessageId) &&
- Objects.equals(replyMarkup, sendPoll.replyMarkup) &&
- Objects.equals(openPeriod, sendPoll.openPeriod) &&
- Objects.equals(closeDate, sendPoll.closeDate) &&
- Objects.equals(explanation, sendPoll.explanation) &&
- Objects.equals(explanationParseMode, sendPoll.explanationParseMode);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(chatId, question, options, isAnonymous, type, allowMultipleAnswers, correctOptionId, isClosed,
- disableNotification, replyToMessageId, replyMarkup, openPeriod, closeDate, explanation, explanationParseMode);
- }
-
- @Override
- public String toString() {
- return "SendPoll{" +
- "chatId='" + chatId + '\'' +
- ", question='" + question + '\'' +
- ", options=" + options +
- ", isAnonymous=" + isAnonymous +
- ", type='" + type + '\'' +
- ", allowMultipleAnswers=" + allowMultipleAnswers +
- ", correctOptionId=" + correctOptionId +
- ", isClosed=" + isClosed +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", openPeriod=" + openPeriod +
- ", closeDate=" + closeDate +
- ", explanation='" + explanation + '\'' +
- ", explanationParseMode='" + explanationParseMode + '\'' +
- '}';
- }
}
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 915e5de5..457c852b 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
@@ -2,16 +2,21 @@ package org.telegram.telegrambots.meta.api.methods.polls;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -20,6 +25,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
*
* On success, the stopped Poll with the final results is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class StopPoll extends BotApiMethod {
public static final String PATH = "stopPoll";
@@ -27,48 +39,12 @@ public class StopPoll extends BotApiMethod {
private static final String MESSAGEID_FIELD = "message_id";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(MESSAGEID_FIELD)
+ @NonNull
private Integer messageId; ///< Identifier of the original message with the poll
- public StopPoll() {
- super();
- }
-
- public StopPoll(String chatId, Integer messageId) {
- this.chatId = checkNotNull(chatId);
- this.messageId = checkNotNull(messageId);
- }
-
- public StopPoll(Long chatId, Integer messageId) {
- this.chatId = checkNotNull(chatId).toString();
- this.messageId = checkNotNull(messageId);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public StopPoll setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public StopPoll setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getMessageId() {
- return messageId;
- }
-
- public StopPoll setMessageId(Integer messageId) {
- this.messageId = messageId;
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -98,31 +74,4 @@ public class StopPoll extends BotApiMethod {
throw new TelegramApiValidationException("Message Id parameter can't be empty", this);
}
}
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if (!(o instanceof StopPoll)) {
- return false;
- }
- StopPoll sendMessage = (StopPoll) o;
- return Objects.equals(chatId, sendMessage.chatId)
- && Objects.equals(messageId, sendMessage.messageId)
- ;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- chatId,
- messageId);
- }
-
- @Override
- public String toString() {
- return "StopPoll{" +
- "chatId='" + chatId + '\'' +
- ", messageId=" + messageId +
- '}';
- }
}
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 e98e6da8..6d847a68 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,18 +1,27 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
+import java.util.List;
/**
* @author Ruben Bermudez
@@ -22,6 +31,14 @@ import java.util.Objects;
*
* Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendAnimation extends PartialBotApiMethod {
public static final String PATH = "sendAnimation";
@@ -36,14 +53,17 @@ public class SendAnimation extends PartialBotApiMethod {
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 CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
-
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Animation to send. Pass a file_id as String to send an animation that exists on the
* Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation
* from the Internet, or upload a new animation using multipart/form-data.
*/
+ @NonNull
private InputFile animation;
private Integer duration; ///< Optional. Duration of sent animation in seconds
private String caption; ///< Optional. Animation caption (may also be used when resending videos by file_id).
@@ -54,6 +74,7 @@ public class SendAnimation extends PartialBotApiMethod {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
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.
/**
+ * Optional.
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnail’s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
@@ -61,137 +82,16 @@ public class SendAnimation extends PartialBotApiMethod {
* if the thumbnail was uploaded using multipart/form-data under .
*/
private InputFile thumb;
+ @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
- public SendAnimation() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendAnimation setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public InputFile getAnimation() {
- return animation;
- }
-
- public SendAnimation setAnimation(String animation) {
- this.animation = new InputFile(animation);
- return this;
- }
-
- public SendAnimation setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public SendAnimation setDuration(Integer duration) {
- this.duration = duration;
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendAnimation setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendAnimation setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendAnimation setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendAnimation enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendAnimation disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public Integer getWidth() {
- return width;
- }
-
- public SendAnimation setWidth(Integer width) {
- this.width = width;
- return this;
- }
-
- public Integer getHeight() {
- return height;
- }
-
- public SendAnimation setHeight(Integer height) {
- this.height = height;
- return this;
- }
-
- public SendAnimation setAnimation(File file) {
- this.animation = new InputFile(file, file.getName());
- return this;
- }
-
- public SendAnimation setAnimation(String animationName, InputStream inputStream) {
- Objects.requireNonNull(animationName, "animationName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.animation = new InputFile(inputStream, animationName);
- return this;
- }
-
- public SendAnimation setAnimation(InputFile animation) {
- Objects.requireNonNull(animation, "animation cannot be null!");
- this.animation = animation;
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendAnimation setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SendAnimation setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
}
@Override
@@ -219,6 +119,10 @@ public class SendAnimation extends PartialBotApiMethod {
throw new TelegramApiValidationException("Animation 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);
+ }
+
animation.validate();
if (replyMarkup != null) {
@@ -228,20 +132,4 @@ public class SendAnimation extends PartialBotApiMethod {
thumb.validate();
}
}
-
- @Override
- public String toString() {
- return "SendAnimation{" + "chatId='" + chatId + '\'' +
- ", animation=" + animation +
- ", duration=" + duration +
- ", caption='" + caption + '\'' +
- ", width=" + width +
- ", height=" + height +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", parseMode='" + parseMode + '\'' +
- ", thumb=" + thumb +
- '}';
- }
}
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 8fe312e8..1aca6cff 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,18 +1,27 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
+import java.util.List;
/**
* @author Ruben Bermudez
@@ -21,8 +30,16 @@ import java.util.Objects;
* Telegram clients to display them in the music player. Your audio must be in an .mp3 format. On
* success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
* size, this limit may be changed in the future.
- * @note For sending voice notes, use sendVoice method instead.
+ * @apiNote For sending voice notes, use sendVoice method instead.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendAudio extends PartialBotApiMethod {
public static final String PATH = "sendaudio";
@@ -37,9 +54,14 @@ public class SendAudio extends PartialBotApiMethod {
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 CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
+ @NonNull
private InputFile audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers or Url to upload it
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@@ -47,8 +69,9 @@ public class SendAudio extends PartialBotApiMethod {
private String performer; ///< Optional. Performer of sent audio
private String title; ///< Optional. Title of sent audio
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
- private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
+ * Optional.
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnail’s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
@@ -56,149 +79,16 @@ public class SendAudio extends PartialBotApiMethod {
* “attach://” if the thumbnail was uploaded using multipart/form-data under .
*/
private InputFile thumb;
+ @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
- public SendAudio() {
- super();
- }
-
- public Integer getDuration() {
- return this.duration;
- }
-
- public SendAudio setDuration(Integer duration) {
- this.duration = duration;
- return this;
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendAudio setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendAudio setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public InputFile getAudio() {
- return audio;
- }
-
- /**
- * Use this method to set the audio to an audio existing in Telegram system
- *
- * @param audio File_id of the audio to send
- * @note The file_id must have already been received or sent by your bot
- */
- public SendAudio setAudio(String audio) {
- this.audio = new InputFile(audio);
- return this;
- }
-
- /**
- * Use this method to set the audio to a new file
- *
- * @param file New audio file
- */
- public SendAudio setAudio(File file) {
- Objects.requireNonNull(file, "file cannot be null!");
- this.audio = new InputFile(file, file.getName());
- return this;
- }
-
- public SendAudio setAudio(String audioName, InputStream inputStream) {
- Objects.requireNonNull(audioName, "audioName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.audio = new InputFile(inputStream, audioName);
- return this;
- }
-
- public SendAudio setAudio(InputFile audio) {
- Objects.requireNonNull(audio, "audio cannot be null!");
- this.audio = audio;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendAudio setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendAudio setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public String getPerformer() {
- return performer;
- }
-
- public SendAudio setPerformer(String performer) {
- this.performer = performer;
- return this;
- }
-
- public String getTitle() {
- return title;
- }
-
- public SendAudio setTitle(String title) {
- this.title = title;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendAudio enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendAudio disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendAudio setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendAudio setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SendAudio setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
}
@Override
@@ -226,6 +116,10 @@ public class SendAudio extends PartialBotApiMethod {
throw new TelegramApiValidationException("Audio 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);
+ }
+
audio.validate();
if (thumb != null) {
@@ -236,21 +130,4 @@ public class SendAudio extends PartialBotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendAudio{" +
- "duration=" + duration +
- ", chatId='" + chatId + '\'' +
- ", audio=" + audio +
- ", replyToMessageId=" + replyToMessageId +
- ", disableNotification=" + disableNotification +
- ", replyMarkup=" + replyMarkup +
- ", performer='" + performer + '\'' +
- ", title='" + title + '\'' +
- ", caption='" + caption + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", thumb=" + thumb +
- '}';
- }
}
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 66cab9ec..f1eef0b3 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
@@ -3,7 +3,14 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+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.methods.ActionType;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@@ -11,9 +18,6 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -22,6 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram
* clients clear its typing status).
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendChatAction extends BotApiMethod {
public static final String PATH = "sendChatAction";
@@ -30,6 +41,7 @@ public class SendChatAction extends BotApiMethod {
private static final String ACTION_FIELD = "action";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages,
@@ -38,46 +50,17 @@ public class SendChatAction extends BotApiMethod {
* record_video_note or upload_video_note for video notes.
*/
@JsonProperty(ACTION_FIELD)
+ @NonNull
private String action;
- public SendChatAction() {
- super();
- }
-
- public SendChatAction(String chatId, String action) {
- this.chatId = checkNotNull(chatId);
- this.action = checkNotNull(action);
- }
-
- public SendChatAction(Long chatId, String action) {
- this.chatId = checkNotNull(chatId).toString();
- this.action = checkNotNull(action);
- }
-
- public String getChatId() {
- return chatId;
- }
-
@JsonIgnore
- public ActionType getAction() {
+ public ActionType getActionType() {
return ActionType.get(action);
}
- public SendChatAction setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendChatAction setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
@JsonIgnore
- public SendChatAction setAction(ActionType action) {
+ public void setAction(ActionType action) {
this.action = action.toString();
- return this;
}
@Override
@@ -109,12 +92,4 @@ public class SendChatAction extends BotApiMethod {
throw new TelegramApiValidationException("Action parameter can't be empty", this);
}
}
-
- @Override
- public String toString() {
- return "SendChatAction{" +
- "chatId='" + chatId + '\'' +
- ", action='" + action + '\'' +
- '}';
- }
}
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 2b9a9604..a81b2000 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
@@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
@@ -19,6 +26,14 @@ import java.util.Objects;
* Use this method to send information about user contact. On success, the sent Message is
* returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendContact extends BotApiMethod {
public static final String PATH = "sendContact";
@@ -30,12 +45,16 @@ public class SendContact extends BotApiMethod {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String VCARD_FIELD = "vcard";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(PHONE_NUMBER_FIELD)
+ @NonNull
private String phoneNumber; ///< User's phone number
@JsonProperty(FIRST_NAME_FIELD)
+ @NonNull
private String firstName; ///< User's first name
@JsonProperty(LAST_NAME_FIELD)
private String lastName; ///< Optional. User's last name
@@ -47,91 +66,15 @@ public class SendContact extends BotApiMethod {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@JsonProperty(VCARD_FIELD)
private String vCard; ///< Optional. Additional data about the contact in the form of a vCard
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendContact() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendContact setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendContact setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendContact setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendContact setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendContact enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendContact disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getPhoneNumber() {
- return phoneNumber;
- }
-
- public SendContact setPhoneNumber(String phoneNumber) {
- this.phoneNumber = phoneNumber;
- return this;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public SendContact setFirstName(String firstName) {
- this.firstName = firstName;
- return this;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public SendContact setLastName(String lastName) {
- this.lastName = lastName;
- return this;
- }
-
- public String getvCard() {
- return vCard;
- }
-
- public void setvCard(String vCard) {
- this.vCard = vCard;
}
@Override
@@ -169,18 +112,4 @@ public class SendContact extends BotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendContact{" +
- "chatId='" + chatId + '\'' +
- ", phoneNumber='" + phoneNumber + '\'' +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", vCard='" + vCard + '\'' +
- '}';
- }
}
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 a81c0fe4..f18f455b 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
@@ -2,6 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@@ -19,8 +28,16 @@ import java.util.List;
* @version 4.7
* Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendDice extends BotApiMethod {
- private static final List VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("\uD83C\uDFB2", "\uD83C\uDFAF", "\uD83C\uDFC0"));
+ private static final List VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("🎲", "🎯", "🏀", "⚽", "🎰"));
public static final String PATH = "sendDice";
@@ -29,14 +46,19 @@ public class SendDice extends BotApiMethod {
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/**
- * Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, or “🏀”.
- * Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”. Defauts to “🎲”
+ * Emoji on which the dice throw animation is based.
+ * Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”.
+ * Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”.
+ * Defaults to “🎲”
*/
@JsonProperty(EMOJI_FIELD)
+ @NonNull
private String emoji;
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@@ -44,64 +66,15 @@ public class SendDice extends BotApiMethod {
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
@JsonProperty(REPLYMARKUP_FIELD)
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional. Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendDice() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendDice setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendDice setChatId(Long chatId) {
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendDice setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendDice setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendDice enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendDice disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getEmoji() {
- return emoji;
- }
-
- public SendDice setEmoji(String emoji) {
- this.emoji = emoji;
- return this;
}
@Override
@@ -130,21 +103,10 @@ public class SendDice extends BotApiMethod {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (emoji != null && !VALIDEMOJIS.contains(emoji)) {
- throw new TelegramApiValidationException("Only \uD83C\uDFB2, \uD83C\uDFAF or \uD83C\uDFC0 are allowed in Emoji field ", this);
+ throw new TelegramApiValidationException("Only \"\uD83C\uDFB2\", \"\uD83C\uDFAF\", \"\uD83C\uDFC0\", \"⚽\", \"\uD83C\uDFB0\" are allowed in Emoji field ", this);
}
if (replyMarkup != null) {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendDice{" +
- "chatId='" + chatId + '\'' +
- ", emoji='" + emoji + '\'' +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- '}';
- }
}
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 fa87167f..deb094af 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,24 +1,41 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
+import java.util.List;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send general files. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendDocument extends PartialBotApiMethod {
public static final String PATH = "senddocument";
@@ -30,15 +47,20 @@ public class SendDocument extends PartialBotApiMethod {
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 CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
+ @NonNull
private InputFile document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers or Url to upload it
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
- private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
+ * Optional.
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnail’s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
@@ -46,122 +68,16 @@ public class SendDocument extends PartialBotApiMethod {
* if the thumbnail was uploaded using multipart/form-data under .
*/
private InputFile thumb;
+ @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
- public SendDocument() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendDocument setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendDocument setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public InputFile getDocument() {
- return document;
- }
-
- /**
- * Use this method to set the document to an document existing in Telegram system
- *
- * @param document File_id of the document to send
- * @note The file_id must have already been received or sent by your bot
- */
- public SendDocument setDocument(String document) {
- this.document = new InputFile(document);
- return this;
- }
-
- /**
- * Use this method to set the document to a new file
- *
- * @param file New document file
- */
- public SendDocument setDocument(File file) {
- Objects.requireNonNull(file, "documentName cannot be null!");
- this.document = new InputFile(file, file.getName());
- return this;
- }
-
- public SendDocument setDocument(InputFile document) {
- Objects.requireNonNull(document, "document cannot be null!");
- this.document = document;
- return this;
- }
-
- public SendDocument setDocument(String documentName, InputStream inputStream) {
- Objects.requireNonNull(documentName, "documentName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.document = new InputFile(inputStream, documentName);
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendDocument setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendDocument enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendDocument disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendDocument setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendDocument setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendDocument setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SendDocument setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
}
@Override
@@ -189,6 +105,10 @@ public class SendDocument extends PartialBotApiMethod {
throw new TelegramApiValidationException("Document 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);
+ }
+
document.validate();
if (thumb != null) {
@@ -199,18 +119,4 @@ public class SendDocument extends PartialBotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendDocument{" +
- "chatId='" + chatId + '\'' +
- ", document=" + document +
- ", caption='" + caption + '\'' +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", parseMode='" + parseMode + '\'' +
- ", thumb=" + thumb +
- '}';
- }
}
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 54838120..898fbc09 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
@@ -19,22 +19,37 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send a game. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendGame extends BotApiMethod {
public static final String PATH = "sendGame";
@@ -43,10 +58,13 @@ public class SendGame extends BotApiMethod {
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(GAMESHORTNAME_FIELD)
+ @NonNull
private String gameShortName; ///< Short name of the game
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@@ -54,65 +72,15 @@ public class SendGame extends BotApiMethod {
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
@JsonProperty(REPLYMARKUP_FIELD)
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendGame() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendGame setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendGame setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendGame setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendGame setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendGame enableNotification() {
+ public void enableNotification() {
this.disableNotification = null;
- return this;
}
- public SendGame disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getGameShortName() {
- return gameShortName;
- }
-
- public SendGame setGameShortName(String gameShortName) {
- this.gameShortName = gameShortName;
- return this;
}
@Override
@@ -147,15 +115,4 @@ public class SendGame extends BotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendGame{" +
- "chatId='" + chatId + '\'' +
- ", gameShortName='" + gameShortName + '\'' +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- '}';
- }
}
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 5fa8debf..0e0da430 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
@@ -2,10 +2,19 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.payments.LabeledPrice;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -13,13 +22,19 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send an invoice. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendInvoice extends BotApiMethod {
public static final String PATH = "sendinvoice";
@@ -46,22 +61,31 @@ public class SendInvoice extends BotApiMethod {
private static final String REPLY_TO_MESSAGE_ID_FIELD = "reply_to_message_id";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PROVIDER_DATA_FIELD = "provider_data";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private Integer chatId; ///< Unique identifier for the target private chat
@JsonProperty(TITLE_FIELD)
+ @NonNull
private String title; ///< Product name
@JsonProperty(DESCRIPTION_FIELD)
+ @NonNull
private String description; ///< Product description
@JsonProperty(PAYLOAD_FIELD)
+ @NonNull
private String payload; ///< Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
@JsonProperty(PROVIDER_TOKEN_FIELD)
+ @NonNull
private String providerToken; ///< Payments provider token, obtained via Botfather
@JsonProperty(START_PARAMETER_FIELD)
+ @NonNull
private String startParameter; ///< Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.
@JsonProperty(CURRENCY_FIELD)
+ @NonNull
private String currency; ///< 3-letter ISO 4217 currency code
@JsonProperty(PRICES_FIELD)
+ @NonNull
private List prices; ///< Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
/**
* Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
@@ -97,250 +121,19 @@ public class SendInvoice extends BotApiMethod {
/**
* Optional. A JSON-serialized object for an inline keyboard.
*
- * @note If empty, one 'Buy title' button will be shown. If not empty, the first button must be a Pay button.
+ * @apiNote If empty, one 'Buy title' button will be shown. If not empty, the first button must be a Pay button.
*/
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup;
/**
* Optional JSON-encoded data about the invoice, which will be shared with the payment provider.
*
- * @note A detailed description of required fields should be provided by the payment provider.
+ * @apiNote A detailed description of required fields should be provided by the payment provider.
*/
@JsonProperty(PROVIDER_DATA_FIELD)
private String providerData;
-
- /**
- * Build an empty SendInvoice object
- */
- public SendInvoice() {
- super();
- }
-
- /**
- * Build a SendInvoice object with empty parameters
- * @param chatId Unique identifier for the target private chat
- * @param title Product name
- * @param description Product description
- * @param payload Bot defined invoice payload, 1-128 bytes.
- * @param providerToken Payments provider token
- * @param startParameter Unique deep-linking parameter.
- * @param currency 3-letter ISO 4217 currency code
- * @param prices Price breakdown, a list of components
- */
- public SendInvoice(Integer chatId, String title, String description, String payload, String providerToken,
- String startParameter, String currency, List prices) {
- this.chatId = checkNotNull(chatId);
- this.title = checkNotNull(title);
- this.description = checkNotNull(description);
- this.payload = checkNotNull(payload);
- this.providerToken = checkNotNull(providerToken);
- this.startParameter = checkNotNull(startParameter);
- this.currency = checkNotNull(currency);
- this.prices = checkNotNull(prices);
- }
-
- public Integer getChatId() {
- return chatId;
- }
-
- public SendInvoice setChatId(Integer chatId) {
- this.chatId = checkNotNull(chatId);
- return this;
- }
-
- public String getTitle() {
- return title;
- }
-
- public SendInvoice setTitle(String title) {
- this.title = checkNotNull(title);
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public SendInvoice setDescription(String description) {
- this.description = checkNotNull(description);
- return this;
- }
-
- public String getPayload() {
- return payload;
- }
-
- public SendInvoice setPayload(String payload) {
- this.payload = checkNotNull(payload);
- return this;
- }
-
- public String getProviderToken() {
- return providerToken;
- }
-
- public SendInvoice setProviderToken(String providerToken) {
- this.providerToken = checkNotNull(providerToken);
- return this;
- }
-
- public String getStartParameter() {
- return startParameter;
- }
-
- public SendInvoice setStartParameter(String startParameter) {
- this.startParameter = checkNotNull(startParameter);
- return this;
- }
-
- public String getCurrency() {
- return currency;
- }
-
- public SendInvoice setCurrency(String currency) {
- this.currency = checkNotNull(currency);
- return this;
- }
-
- public List getPrices() {
- return prices;
- }
-
- public SendInvoice setPrices(List prices) {
- this.prices = checkNotNull(prices);
- return this;
- }
-
- public String getPhotoUrl() {
- return photoUrl;
- }
-
- public SendInvoice setPhotoUrl(String photoUrl) {
- this.photoUrl = photoUrl;
- return this;
- }
-
- public Integer getPhotoSize() {
- return photoSize;
- }
-
- public SendInvoice setPhotoSize(Integer photoSize) {
- this.photoSize = photoSize;
- return this;
- }
-
- public Integer getPhotoWidth() {
- return photoWidth;
- }
-
- public SendInvoice setPhotoWidth(Integer photoWidth) {
- this.photoWidth = photoWidth;
- return this;
- }
-
- public Integer getPhotoHeight() {
- return photoHeight;
- }
-
- public SendInvoice setPhotoHeight(Integer photoHeight) {
- this.photoHeight = photoHeight;
- return this;
- }
-
- public Boolean getNeedName() {
- return needName;
- }
-
- public SendInvoice setNeedName(Boolean needName) {
- this.needName = needName;
- return this;
- }
-
- public Boolean getNeedPhoneNumber() {
- return needPhoneNumber;
- }
-
- public SendInvoice setNeedPhoneNumber(Boolean needPhoneNumber) {
- this.needPhoneNumber = needPhoneNumber;
- return this;
- }
-
- public Boolean getNeedEmail() {
- return needEmail;
- }
-
- public SendInvoice setNeedEmail(Boolean needEmail) {
- this.needEmail = needEmail;
- return this;
- }
-
- public Boolean getNeedShippingAddress() {
- return needShippingAddress;
- }
-
- public SendInvoice setNeedShippingAddress(Boolean needShippingAddress) {
- this.needShippingAddress = needShippingAddress;
- return this;
- }
-
- public Boolean getSendPhoneNumberToProvider() { return sendPhoneNumberToProvider; }
-
- public SendInvoice setSendPhoneNumberToProvider(Boolean sendPhoneNumberToProvider) {
- this.sendPhoneNumberToProvider = sendPhoneNumberToProvider;
- return this;
- }
-
- public Boolean getSendEmailToProvider() { return sendEmailToProvider; }
-
- public SendInvoice setSendEmailToProvider(Boolean sendEmailToProvider) {
- this.sendEmailToProvider = sendEmailToProvider;
- return this;
- }
-
- public Boolean getFlexible() {
- return isFlexible;
- }
-
- public SendInvoice setFlexible(Boolean flexible) {
- isFlexible = flexible;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendInvoice setDisableNotification(Boolean disableNotification) {
- this.disableNotification = disableNotification;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendInvoice setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public InlineKeyboardMarkup getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendInvoice setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public String getProviderData() {
- return providerData;
- }
-
- public SendInvoice setProviderData(String providerData) {
- this.providerData = providerData;
- return this;
- }
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
@Override
public String getMethod() {
@@ -396,33 +189,4 @@ public class SendInvoice extends BotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendInvoice{" +
- "chatId=" + chatId +
- ", title='" + title + '\'' +
- ", description='" + description + '\'' +
- ", payload='" + payload + '\'' +
- ", providerToken='" + providerToken + '\'' +
- ", startParameter='" + startParameter + '\'' +
- ", currency='" + currency + '\'' +
- ", prices=" + prices +
- ", photoUrl='" + photoUrl + '\'' +
- ", photoSize=" + photoSize +
- ", photoWidth=" + photoWidth +
- ", photoHeight=" + photoHeight +
- ", needName=" + needName +
- ", needPhoneNumber=" + needPhoneNumber +
- ", needEmail=" + needEmail +
- ", needShippingAddress=" + needShippingAddress +
- ", sendPhoneNumberToProvider=" + sendPhoneNumberToProvider +
- ", sendEmailToProvider=" + sendEmailToProvider +
- ", isFlexible=" + isFlexible +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", providerData='" + providerData + '\'' +
- '}';
- }
}
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 28a889d6..720f9eb0 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
@@ -2,23 +2,37 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send point on the map. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendLocation extends BotApiMethod {
public static final String PATH = "sendlocation";
@@ -29,13 +43,20 @@ public class SendLocation extends BotApiMethod {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String LIVEPERIOD_FIELD = "live_period";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ private static final String HORIZONTALACCURACY_FIELD = "horizontal_accuracy";
+ private static final String HEADING_FIELD = "heading";
+ private static final String APPROACHINGNOTIFICATIONDISTANCE_FIELD = "approaching_notification_distance";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(LATITUDE_FIELD)
- private Float latitude; ///< Latitude of location
+ @NonNull
+ private Double latitude; ///< Latitude of location
@JsonProperty(LONGITUDE_FIELD)
- private Float longitude; ///< Longitude of location
+ @NonNull
+ private Double longitude; ///< Longitude of location
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
@JsonProperty(REPLYTOMESSAGEID_FIELD)
@@ -44,91 +65,35 @@ public class SendLocation extends BotApiMethod {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@JsonProperty(LIVEPERIOD_FIELD)
private Integer livePeriod; ///< Optional. Period in seconds for which the location will be updated (see Live Locations), should be between 60 and 86400.
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
+ /**
+ * Optional.
+ * The radius of uncertainty for the location, measured in meters; 0-1500
+ */
+ @JsonProperty(HORIZONTALACCURACY_FIELD)
+ private Double horizontalAccuracy;
+ /**
+ * Optional.
+ * For live locations, a direction in which the user is moving, in degrees.
+ * Must be between 1 and 360 if specified.
+ */
+ @JsonProperty(HEADING_FIELD)
+ private Integer heading;
+ /**
+ * Optional.
+ * For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters.
+ * Must be between 1 and 100000 if specified.
+ */
+ @JsonProperty(APPROACHINGNOTIFICATIONDISTANCE_FIELD)
+ private Integer approachingNotificationDistance;
- public SendLocation() {
- super();
- }
-
- public SendLocation(Float latitude, Float longitude) {
- super();
- this.latitude = checkNotNull(latitude);
- this.longitude = checkNotNull(longitude);
- }
-
-
- public String getChatId() {
- return chatId;
- }
-
- public SendLocation setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendLocation setChatId(Long chatId) {
- this.chatId = chatId.toString();
- return this;
- }
-
- public Float getLatitude() {
- return latitude;
- }
-
- public SendLocation setLatitude(Float latitude) {
- Objects.requireNonNull(latitude);
- this.latitude = latitude;
- return this;
- }
-
- public Float getLongitude() {
- return longitude;
- }
-
- public SendLocation setLongitude(Float longitude) {
- Objects.requireNonNull(longitude);
- this.longitude = longitude;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendLocation setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendLocation setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendLocation enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendLocation disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public Integer getLivePeriod() {
- return livePeriod;
- }
-
- public SendLocation setLivePeriod(Integer livePeriod) {
- this.livePeriod = livePeriod;
- return this;
}
@Override
@@ -162,6 +127,15 @@ public class SendLocation extends BotApiMethod {
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
+ if (horizontalAccuracy != null && (horizontalAccuracy < 0 || horizontalAccuracy > 1500)) {
+ throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
+ }
+ if (heading != null && (heading < 1 || heading > 360)) {
+ throw new TelegramApiValidationException("Heading Accuracy parameter must be between 0 and 1500", this);
+ }
+ if (approachingNotificationDistance != null && (approachingNotificationDistance < 1 || approachingNotificationDistance > 100000)) {
+ throw new TelegramApiValidationException("Approaching notification distance parameter must be between 0 and 1500", this);
+ }
if (replyMarkup != null) {
replyMarkup.validate();
}
@@ -169,17 +143,4 @@ public class SendLocation extends BotApiMethod {
throw new TelegramApiValidationException("Live period parameter must be between 60 and 86400", this);
}
}
-
- @Override
- public String toString() {
- return "SendLocation{" +
- "chatId='" + chatId + '\'' +
- ", latitude=" + latitude +
- ", longitude=" + longitude +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", livePeriod=" + livePeriod +
- '}';
- }
}
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 dd1341a0..25494265 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
@@ -2,12 +2,22 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.media.InputMedia;
-import org.telegram.telegrambots.meta.api.objects.media.InputMediaPhoto;
-import org.telegram.telegrambots.meta.api.objects.media.InputMediaVideo;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+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.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -15,16 +25,23 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 3.5
*
- * Use this method to send a group of photos or videos as an album.
- * On success, an array of the sent Messages is returned.
+ * Use this method to send a group of photos, videos, documents or audios as an album.
+ * Documents and audio files can be only group in an album with messages of the same type.
+ * On success, an array of Messages that were sent is returned.
*/
@SuppressWarnings("unused")
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendMediaGroup extends PartialBotApiMethod> {
public static final String PATH = "sendMediaGroup";
@@ -32,75 +49,27 @@ public class SendMediaGroup extends PartialBotApiMethod> {
public static final String MEDIA_FIELD = "media";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(MEDIA_FIELD)
- private List media; ///< A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
+ @NonNull
+ private List medias; ///< A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
@JsonProperty(REPLYTOMESSAGEID_FIELD)
private Integer replyToMessageId; ///< Optional. If the messages are a reply, ID of the original message
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the messages silently. Users will receive a notification with no sound.
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendMediaGroup() {
- super();
- }
-
- public SendMediaGroup(String chatId, List media) {
- super();
- this.chatId = checkNotNull(chatId);
- this.media = checkNotNull(media);
- }
-
- public SendMediaGroup(Long chatId, List media) {
- super();
- this.chatId = checkNotNull(chatId).toString();
- this.media = checkNotNull(media);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendMediaGroup setChatId(String chatId) {
- this.chatId = checkNotNull(chatId);
- return this;
- }
-
- public SendMediaGroup setChatId(Long chatId) {
- this.chatId = checkNotNull(chatId).toString();
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendMediaGroup setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendMediaGroup enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendMediaGroup disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public List getMedia() {
- return media;
- }
-
- public void setMedia(List media) {
- this.media = media;
}
@Override
@@ -125,26 +94,30 @@ public class SendMediaGroup extends PartialBotApiMethod> {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
- if (media == null || media.isEmpty()) {
+ if (medias == null || medias.isEmpty()) {
throw new TelegramApiValidationException("Media parameter can't be empty", this);
+ } else if (medias.size() < 2 || medias.size() > 10) {
+ throw new TelegramApiValidationException("Number of media should be between 2 and 10", this);
}
- for (InputMedia inputMedia : media) {
- if (inputMedia instanceof InputMediaPhoto || inputMedia instanceof InputMediaVideo) {
- inputMedia.validate();
+ for (InputMedia inputMedia : medias) {
+ if (inputMedia == null) {
+ throw new TelegramApiValidationException("Media parameter can not be empty", this);
+ } else if (inputMedia instanceof InputMediaAnimation) {
+ throw new TelegramApiValidationException("Media parameter can not be an Animation", this);
} else {
- throw new TelegramApiValidationException("Media parameter can only be Photo or Video", this);
+ inputMedia.validate();
+ }
+ }
+
+ if (medias.stream().anyMatch(x -> x instanceof InputMediaAudio)) {
+ if (!medias.stream().allMatch(x -> x instanceof InputMediaAudio)) {
+ throw new TelegramApiValidationException("Media parameter containing Audio can not have other types", this);
+ }
+ } else if (medias.stream().anyMatch(x -> x instanceof InputMediaDocument)) {
+ if (!medias.stream().allMatch(x -> x instanceof InputMediaDocument)) {
+ throw new TelegramApiValidationException("Media parameter containing Document can not have other types", this);
}
}
}
-
- @Override
- public String toString() {
- return "SendMediaGroup{" +
- "chatId='" + chatId + '\'' +
- ", media=" + media +
- ", replyToMessageId=" + replyToMessageId +
- ", disableNotification=" + disableNotification +
- '}';
- }
}
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 5377de33..337c22e0 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
@@ -3,24 +3,41 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.ParseMode;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.List;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send text messages. On success, the sent Message is returned.
*/
+@SuppressWarnings("unused")
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendMessage extends BotApiMethod {
public static final String PATH = "sendmessage";
@@ -31,10 +48,14 @@ public class SendMessage extends BotApiMethod {
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
+ private static final String ENTITIES_FIELD = "entities";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(TEXT_FIELD)
+ @NonNull
private String text; ///< Text of the message to be sent
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message.
@@ -47,121 +68,49 @@ public class SendMessage extends BotApiMethod {
@JsonProperty(REPLYMARKUP_FIELD)
@JsonDeserialize()
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
+ @JsonProperty(ENTITIES_FIELD)
+ private List entities; ///< Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendMessage() {
- super();
- }
-
- public SendMessage(String chatId, String text) {
- this.chatId = checkNotNull(chatId);
- this.text = checkNotNull(text);
- }
-
- public SendMessage(Long chatId, String text) {
- this.chatId = checkNotNull(chatId).toString();
- this.text = checkNotNull(text);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendMessage setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendMessage setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public String getText() {
- return text;
- }
-
- public SendMessage setText(String text) {
- this.text = text;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendMessage setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendMessage setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableWebPagePreview() {
- return disableWebPagePreview;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendMessage disableWebPagePreview() {
+ public void disableWebPagePreview() {
disableWebPagePreview = true;
- return this;
}
- public SendMessage enableWebPagePreview() {
+ public void enableWebPagePreview() {
disableWebPagePreview = null;
- return this;
}
- public SendMessage enableNotification() {
+ public void enableNotification() {
this.disableNotification = null;
- return this;
}
- public SendMessage disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
}
- public SendMessage setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
- }
-
- public SendMessage enableMarkdown(boolean enable) {
+ public void enableMarkdown(boolean enable) {
if (enable) {
this.parseMode = ParseMode.MARKDOWN;
} else {
this.parseMode = null;
}
- return this;
}
- public SendMessage enableHtml(boolean enable) {
+ public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = ParseMode.HTML;
} else {
this.parseMode = null;
}
- return this;
}
- public SendMessage enableMarkdownV2(boolean enable) {
+ public void enableMarkdownV2(boolean enable) {
if (enable) {
this.parseMode = ParseMode.MARKDOWNV2;
} else {
this.parseMode = null;
}
- return this;
}
@Override
@@ -192,50 +141,11 @@ public class SendMessage extends BotApiMethod {
if (text == null || text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
+ if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
+ throw new TelegramApiValidationException("Parse mode can't be enabled if Entities are provided", this);
+ }
if (replyMarkup != null) {
replyMarkup.validate();
}
}
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if (!(o instanceof SendMessage)) {
- return false;
- }
- SendMessage sendMessage = (SendMessage) o;
- return Objects.equals(chatId, sendMessage.chatId)
- && Objects.equals(disableNotification, sendMessage.disableNotification)
- && Objects.equals(disableWebPagePreview, sendMessage.disableWebPagePreview)
- && Objects.equals(parseMode, sendMessage.parseMode)
- && Objects.equals(replyMarkup, sendMessage.replyMarkup)
- && Objects.equals(replyToMessageId, sendMessage.replyToMessageId)
- && Objects.equals(text, sendMessage.text)
- ;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- chatId,
- disableNotification,
- disableWebPagePreview,
- parseMode,
- replyMarkup,
- replyToMessageId,
- text);
- }
-
- @Override
- public String toString() {
- return "SendMessage{" +
- "chatId='" + chatId + '\'' +
- ", text='" + text + '\'' +
- ", parseMode='" + parseMode + '\'' +
- ", disableNotification='" + disableNotification + '\'' +
- ", disableWebPagePreview=" + disableWebPagePreview +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- '}';
- }
}
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 c5c225da..6a643f05 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
@@ -1,17 +1,27 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
+import java.util.List;
import java.util.Objects;
/**
@@ -19,6 +29,14 @@ import java.util.Objects;
* @version 1.0
* Use this method to send photos. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendPhoto extends PartialBotApiMethod {
public static final String PATH = "sendphoto";
@@ -29,110 +47,33 @@ public class SendPhoto extends PartialBotApiMethod {
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 CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ @NonNull
private InputFile photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers or URL to upload it
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
- private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ @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
- public SendPhoto() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendPhoto setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendPhoto setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public InputFile getPhoto() {
- return photo;
- }
-
- public SendPhoto setPhoto(String photo) {
- this.photo = new InputFile(photo);
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendPhoto setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendPhoto setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendPhoto setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendPhoto enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendPhoto disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
}
- public SendPhoto setPhoto(File file) {
- Objects.requireNonNull(file, "file cannot be null!");
- this.photo = new InputFile(file, file.getName());
- return this;
- }
-
- public SendPhoto setPhoto(InputFile photo) {
+ public void setPhoto(InputFile photo) {
Objects.requireNonNull(photo, "photo cannot be null!");
this.photo = photo;
- return this;
- }
-
- public SendPhoto setPhoto(String photoName, InputStream inputStream) {
- Objects.requireNonNull(photoName, "photoName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.photo = new InputFile(inputStream, photoName);
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendPhoto setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
}
@Override
@@ -160,23 +101,13 @@ public class SendPhoto extends PartialBotApiMethod {
throw new TelegramApiValidationException("Photo 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);
+ }
photo.validate();
if (replyMarkup != null) {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendPhoto{" +
- "chatId='" + chatId + '\'' +
- ", photo=" + photo +
- ", caption='" + caption + '\'' +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", parseMode='" + parseMode + '\'' +
- '}';
- }
}
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 94cada4e..9796bc1e 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
@@ -1,24 +1,38 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to send .webp stickers. On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendSticker extends PartialBotApiMethod {
public static final String PATH = "sendsticker";
@@ -27,89 +41,27 @@ public class SendSticker extends PartialBotApiMethod {
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 ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ @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.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
-
- public SendSticker() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendSticker setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendSticker setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public InputFile getSticker() {
- return sticker;
- }
-
- public SendSticker setSticker(String sticker) {
- this.sticker = new InputFile(sticker);
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendSticker setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendSticker setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public SendSticker setSticker(InputFile sticker) {
- Objects.requireNonNull(sticker, "sticker cannot be null!");
- this.sticker = sticker;
- return this;
- }
-
- public SendSticker setSticker(File file) {
- Objects.requireNonNull(file, "file cannot be null!");
- this.sticker = new InputFile(file, file.getName());
- return this;
- }
-
- public SendSticker setSticker(String stickerName, InputStream inputStream) {
- Objects.requireNonNull(stickerName, "stickerName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.sticker = new InputFile(inputStream, stickerName);
- return this;
- }
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
public Boolean getDisableNotification() {
return disableNotification;
}
- public SendSticker enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendSticker disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
}
@Override
@@ -143,15 +95,4 @@ public class SendSticker extends PartialBotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendSticker{" +
- "chatId='" + chatId + '\'' +
- ", sticker=" + sticker +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- '}';
- }
}
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 6d3281f2..574166b4 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
@@ -2,16 +2,23 @@ package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+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.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.util.Objects;
/**
* @author Ruben Bermudez
@@ -19,6 +26,14 @@ import java.util.Objects;
* Use this method to send information about a venue. On success, the sent Message is
* returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendVenue extends BotApiMethod {
public static final String PATH = "sendVenue";
@@ -32,19 +47,27 @@ public class SendVenue extends BotApiMethod {
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
+ private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ private static final String GOOGLEPLACEID_FIELD = "google_place_id";
+ private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
@JsonProperty(CHATID_FIELD)
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@JsonProperty(LATITUDE_FIELD)
- private Float latitude; ///< Latitude of venue location
+ @NonNull
+ private Double latitude; ///< Latitude of venue location
@JsonProperty(LONGITUDE_FIELD)
- private Float longitude; ///< Longitude of venue location
+ @NonNull
+ private Double longitude; ///< Longitude of venue location
@JsonProperty(TITLE_FIELD)
+ @NonNull
private String title; ///< Title of the venue
+ @JsonProperty(ADDRESS_FIELD)
+ @NonNull
+ private String address; ///< Address of the venue
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
- @JsonProperty(ADDRESS_FIELD)
- private String address; ///< Address of the venue
@JsonProperty(FOURSQUAREID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue
@JsonProperty(REPLYTOMESSAGEID_FIELD)
@@ -53,110 +76,19 @@ public class SendVenue extends BotApiMethod {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
+ @JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
+ @JsonProperty(GOOGLEPLACEID_FIELD)
+ private String googlePlaceId; ///< Optional. Google Places identifier of the venue
+ @JsonProperty(GOOGLEPLACETYPE_FIELD)
+ private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
- public SendVenue() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendVenue setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendVenue setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Float getLatitude() {
- return latitude;
- }
-
- public SendVenue setLatitude(Float latitude) {
- this.latitude = latitude;
- return this;
- }
-
- public Float getLongitude() {
- return longitude;
- }
-
- public SendVenue setLongitude(Float longitude) {
- this.longitude = longitude;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendVenue setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendVenue setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendVenue enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendVenue disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getTitle() {
- return title;
- }
-
- public SendVenue setTitle(String title) {
- this.title = title;
- return this;
- }
-
- public String getAddress() {
- return address;
- }
-
- public SendVenue setAddress(String address) {
- this.address = address;
- return this;
- }
-
- public String getFoursquareId() {
- return foursquareId;
- }
-
- public SendVenue setFoursquareId(String foursquareId) {
- this.foursquareId = foursquareId;
- return this;
- }
-
- public String getFoursquareType() {
- return foursquareType;
- }
-
- public SendVenue setFoursquareType(String foursquareType) {
- this.foursquareType = foursquareType;
- return this;
}
@Override
@@ -200,20 +132,4 @@ public class SendVenue extends BotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendVenue{" +
- "chatId='" + chatId + '\'' +
- ", latitude=" + latitude +
- ", longitude=" + longitude +
- ", title='" + title + '\'' +
- ", disableNotification=" + disableNotification +
- ", address='" + address + '\'' +
- ", foursquareId='" + foursquareId + '\'' +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", foursquareType='" + foursquareType + '\'' +
- '}';
- }
}
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 998dd97a..4aa91dab 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,18 +1,27 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
+import java.util.List;
/**
* @author Ruben Bermudez
@@ -20,6 +29,14 @@ import java.util.Objects;
* Use this method to send video files, Telegram clients support mp4 videos (other formats
* may be sent as Document). On success, the sent Message is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendVideo extends PartialBotApiMethod {
public static final String PATH = "sendvideo";
@@ -35,8 +52,12 @@ public class SendVideo extends PartialBotApiMethod {
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 CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ @NonNull
private InputFile video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers or URL to upload it
private Integer duration; ///< Optional. Duration of sent video in seconds
private String caption; ///< Optional. Video caption (may also be used when resending videos by file_id).
@@ -46,8 +67,9 @@ public class SendVideo extends PartialBotApiMethod {
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
- private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
/**
+ * Optional.
* Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
* A thumbnail’s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data.
@@ -55,147 +77,16 @@ public class SendVideo extends PartialBotApiMethod {
* if the thumbnail was uploaded using multipart/form-data under .
*/
private InputFile thumb;
+ @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
- public SendVideo() {
- super();
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendVideo setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public InputFile getVideo() {
- return video;
- }
-
- public SendVideo setVideo(String video) {
- this.video = new InputFile(video);
- return this;
- }
-
- public SendVideo setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public SendVideo setDuration(Integer duration) {
- this.duration = duration;
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendVideo setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendVideo setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendVideo setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendVideo enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendVideo disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public Integer getWidth() {
- return width;
- }
-
- public SendVideo setWidth(Integer width) {
- this.width = width;
- return this;
- }
-
- public Integer getHeight() {
- return height;
- }
-
- public SendVideo setHeight(Integer height) {
- this.height = height;
- return this;
- }
-
- public SendVideo setVideo(InputFile video) {
- Objects.requireNonNull(video, "video cannot be null!");
- this.video = video;
- return this;
- }
-
- public SendVideo setVideo(File file) {
- Objects.requireNonNull(file, "file cannot be null!");
- this.video = new InputFile(file, file.getName());
- return this;
- }
-
- public SendVideo setVideo(String videoName, InputStream inputStream) {
- Objects.requireNonNull(videoName, "videoName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.video = new InputFile(inputStream, videoName);
- return this;
- }
-
- public Boolean getSupportsStreaming() {
- return supportsStreaming;
- }
-
- public SendVideo setSupportsStreaming(Boolean supportsStreaming) {
- this.supportsStreaming = supportsStreaming;
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendVideo setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SendVideo setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
}
@Override
@@ -223,6 +114,10 @@ public class SendVideo extends PartialBotApiMethod {
throw new TelegramApiValidationException("Video 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);
+ }
+
video.validate();
if (thumb != null) {
@@ -232,22 +127,4 @@ public class SendVideo extends PartialBotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendVideo{" +
- "chatId='" + chatId + '\'' +
- ", video=" + video +
- ", duration=" + duration +
- ", caption='" + caption + '\'' +
- ", width=" + width +
- ", height=" + height +
- ", supportsStreaming=" + supportsStreaming +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", parseMode='" + parseMode + '\'' +
- ", thumb=" + thumb +
- '}';
- }
}
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 9da68295..0fba958d 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,20 +1,24 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -23,6 +27,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to send video messages. On success, the sent Message is returned.
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendVideoNote extends PartialBotApiMethod {
public static final String PATH = "sendvideonote";
@@ -34,8 +46,11 @@ public class SendVideoNote extends PartialBotApiMethod {
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 ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ @NonNull
private InputFile videoNote; ///< Videonote to send. file_id as String to resend a video that is already on the Telegram servers.
private Integer duration; ///< Optional. Duration of sent video in seconds
private Integer length; ///< Optional. Video width and height
@@ -50,174 +65,14 @@ public class SendVideoNote extends PartialBotApiMethod {
* if the thumbnail was uploaded using multipart/form-data under .
*/
private InputFile thumb;
+ private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
- public SendVideoNote() {
- super();
- }
-
- /**
- * Creates a new video note with a video already present in telegram servers
- * @param chatId Chat Id to send the video note
- * @param videoNote Video note file_id to send
- */
- public SendVideoNote(String chatId, String videoNote) {
- this.chatId = checkNotNull(chatId);
- this.setVideoNote(checkNotNull(videoNote));
- }
-
- /**
- * Creates a new video note with a video already present in telegram servers
- * @param chatId Chat Id to send the video note
- * @param videoNote Video note file_id to send
- */
- public SendVideoNote(Long chatId, String videoNote) {
-
- this.chatId = checkNotNull(chatId).toString();
- this.setVideoNote(checkNotNull(videoNote));
- }
-
- /**
- * Creates a new video note with a new video note
- * @param chatId Chat Id to send the video note
- * @param videoNote Video note file to upload
- */
- public SendVideoNote(String chatId, File videoNote) {
- this.chatId = checkNotNull(chatId);
- this.setVideoNote(videoNote);
- }
-
- /**
- * Creates a new video note with a video already present in telegram servers
- * @param chatId Chat Id to send the video note
- * @param videoNote Video note file to upload
- */
- public SendVideoNote(Integer chatId, File videoNote) {
- this.chatId = checkNotNull(chatId).toString();
- this.setVideoNote(videoNote);
- }
-
- /**
- * Creates a new video note with a new video note
- * @param chatId Chat Id to send the video note
- * @param videoNoteName Name of the video note file
- * @param videoNote Video note file to upload
- */
- public SendVideoNote(String chatId, String videoNoteName, InputStream videoNote) {
- this.chatId = checkNotNull(chatId);
- this.setVideoNote(videoNoteName, videoNote);
- }
-
- /**
- * Creates a new video note with a video already present in telegram servers
- * @param chatId Chat Id to send the video note
- * @param videoNoteName Name of the video note file
- * @param videoNote Video note file to upload
- */
- public SendVideoNote(Integer chatId, String videoNoteName, InputStream videoNote) {
- this.chatId = checkNotNull(chatId).toString();
- this.setVideoNote(videoNoteName, videoNote);
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendVideoNote setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public InputFile getVideoNote() {
- return videoNote;
- }
-
- public SendVideoNote setVideoNote(String videoNote) {
- this.videoNote = new InputFile(videoNote);
- return this;
- }
-
- public Integer getLength() {
- return length;
- }
-
- public SendVideoNote setLength(Integer length) {
- this.length = length;
- return this;
- }
-
- public SendVideoNote setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public SendVideoNote setDuration(Integer duration) {
- this.duration = duration;
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendVideoNote setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendVideoNote setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendVideoNote enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendVideoNote disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public SendVideoNote setVideoNote(InputFile videoNote) {
- Objects.requireNonNull(videoNote, "videoNote cannot be null!");
- this.videoNote = videoNote;
- return this;
- }
-
- public SendVideoNote setVideoNote(File file) {
- Objects.requireNonNull(file, "file cannot be null!");
- this.videoNote = new InputFile(file, file.getName());
- return this;
- }
-
- public SendVideoNote setVideoNote(String videoName, InputStream inputStream) {
- Objects.requireNonNull(videoName, "videoName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.videoNote = new InputFile(inputStream, videoName);
- return this;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SendVideoNote setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
}
@Override
@@ -254,18 +109,4 @@ public class SendVideoNote extends PartialBotApiMethod {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendVideoNote{" +
- "chatId='" + chatId + '\'' +
- ", videoNote=" + videoNote +
- ", duration=" + duration +
- ", length=" + length +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", thumb=" + thumb +
- '}';
- }
}
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 da19e0e4..61347bbd 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
@@ -1,18 +1,27 @@
package org.telegram.telegrambots.meta.api.methods.send;
import com.fasterxml.jackson.core.type.TypeReference;
+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.Singular;
+import lombok.ToString;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.api.objects.Message;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
+import java.util.List;
/**
* @author Ruben Bermudez
@@ -21,6 +30,14 @@ import java.util.Objects;
* playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
* (other formats may be sent as Audio or Document).
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SendVoice extends PartialBotApiMethod {
public static final String PATH = "sendvoice";
@@ -32,121 +49,29 @@ public class SendVoice extends PartialBotApiMethod {
public static final String DURATION_FIELD = "duration";
public static final String CAPTION_FIELD = "caption";
public static final String PARSEMODE_FIELD = "parse_mode";
+ public static final String CAPTION_ENTITIES_FIELD = "caption_entities";
+ public static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
+ @NonNull
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
+ @NonNull
private InputFile voice; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private Integer duration; ///< Optional. Duration of sent audio in seconds
private String caption; ///< Optional. Voice caption (may also be used when resending videos by file_id).
- private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
+ @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
- public SendVoice() {
- super();
- }
-
- public Boolean getDisableNotification() {
- return disableNotification;
- }
-
- public SendVoice enableNotification() {
+ public void enableNotification() {
this.disableNotification = false;
- return this;
}
- public SendVoice disableNotification() {
+ public void disableNotification() {
this.disableNotification = true;
- return this;
- }
-
- public String getChatId() {
- return chatId;
- }
-
- public SendVoice setChatId(String chatId) {
- this.chatId = chatId;
- return this;
- }
-
- public SendVoice setChatId(Long chatId) {
- Objects.requireNonNull(chatId);
- this.chatId = chatId.toString();
- return this;
- }
-
- public InputFile getVoice() {
- return voice;
- }
-
- public SendVoice setVoice(String voice) {
- Objects.requireNonNull(voice, "voice cannot be null!");
- this.voice = new InputFile(voice);
- return this;
- }
-
- public SendVoice setVoice(File voice) {
- Objects.requireNonNull(voice, "voice cannot be null!");
- this.voice = new InputFile(voice, voice.getName());
- return this;
- }
-
- public SendVoice setVoice(InputFile voice) {
- Objects.requireNonNull(voice, "voice cannot be null!");
- this.voice = voice;
- return this;
- }
-
- public SendVoice setVoice(String voiceName, InputStream inputStream) {
- Objects.requireNonNull(voiceName, "voiceName cannot be null!");
- Objects.requireNonNull(inputStream, "inputStream cannot be null!");
- this.voice = new InputFile(inputStream, voiceName);
- return this;
- }
-
- public Integer getReplyToMessageId() {
- return replyToMessageId;
- }
-
- public SendVoice setReplyToMessageId(Integer replyToMessageId) {
- this.replyToMessageId = replyToMessageId;
- return this;
- }
-
- public ReplyKeyboard getReplyMarkup() {
- return replyMarkup;
- }
-
- public SendVoice setReplyMarkup(ReplyKeyboard replyMarkup) {
- this.replyMarkup = replyMarkup;
- return this;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public SendVoice setDuration(Integer duration) {
- this.duration = duration;
- return this;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public SendVoice setCaption(String caption) {
- this.caption = caption;
- return this;
- }
-
- public String getParseMode() {
- return parseMode;
- }
-
- public SendVoice setParseMode(String parseMode) {
- this.parseMode = parseMode;
- return this;
}
@Override
@@ -173,25 +98,13 @@ public class SendVoice extends PartialBotApiMethod {
if (voice == null) {
throw new TelegramApiValidationException("Voice 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);
+ }
voice.validate();
if (replyMarkup != null) {
replyMarkup.validate();
}
}
-
- @Override
- public String toString() {
- return "SendVoice{" +
- "chatId='" + chatId + '\'' +
- ", voice=" + voice +
- ", disableNotification=" + disableNotification +
- ", replyToMessageId=" + replyToMessageId +
- ", replyMarkup=" + replyMarkup +
- ", duration=" + duration +
- ", caption='" + caption + '\'' +
- ", parseMode='" + parseMode + '\'' +
- '}';
- }
}
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 e1f433d0..7429c625 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
@@ -1,6 +1,15 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
+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.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@@ -8,12 +17,7 @@ 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.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -25,6 +29,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Static sticker sets can have up to 120 stickers.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class AddStickerToSet extends PartialBotApiMethod {
public static final String PATH = "addStickerToSet";
@@ -35,11 +47,15 @@ public class AddStickerToSet extends PartialBotApiMethod {
public static final String EMOJIS_FIELD = "emojis";
public static final String MASKPOSITION_FIELD = "mask_position";
+ @NonNull
private Integer userId; ///< User identifier of sticker set owner
+ @NonNull
private String name; ///< Sticker set name
+ @NonNull
private String emojis; ///< One or more emoji corresponding to the sticker
- private MaskPosition maskPosition; ///< Position where the mask should be placed on faces
+ private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
/**
+ * Optional.
* 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. 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
@@ -47,93 +63,12 @@ public class AddStickerToSet extends PartialBotApiMethod {
*/
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
*/
private InputFile tgsSticker;
- public AddStickerToSet() {
- super();
- }
-
- public AddStickerToSet(Integer userId, String name, String emojis) {
- this.userId = checkNotNull(userId);
- this.name = checkNotNull(name);
- this.emojis = checkNotNull(emojis);
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public AddStickerToSet setUserId(Integer userId) {
- this.userId = userId;
- return this;
- }
-
- public InputFile getPngSticker() {
- return pngSticker;
- }
-
- public AddStickerToSet setPngSticker(String pngSticker) {
- this.pngSticker = new InputFile(pngSticker);
- return this;
- }
-
- public AddStickerToSet setPngSticker(File pngSticker) {
- Objects.requireNonNull(pngSticker, "pngSticker cannot be null!");
- this.pngSticker = new InputFile(pngSticker, pngSticker.getName());
- return this;
- }
-
- public AddStickerToSet setPngSticker(String pngStickerName, InputStream pngSticker) {
- Objects.requireNonNull(pngStickerName, "pngStickerName cannot be null!");
- Objects.requireNonNull(pngSticker, "pngSticker cannot be null!");
- this.pngSticker = new InputFile(pngSticker, pngStickerName);
- return this;
- }
-
- public AddStickerToSet setTgsSticker(File tgsSticker) {
- this.tgsSticker = new InputFile(checkNotNull(tgsSticker), tgsSticker.getName());
- return this;
- }
-
- public AddStickerToSet setTgsSticker(String tgsStickerName, InputStream tgsSticker) {
- this.tgsSticker = new InputFile(checkNotNull(tgsSticker), checkNotNull(tgsStickerName));
- return this;
- }
-
- public InputFile getTgsSticker() {
- return tgsSticker;
- }
-
- public String getName() {
- return name;
- }
-
- public AddStickerToSet setName(String name) {
- this.name = name;
- return this;
- }
-
- public String getEmojis() {
- return emojis;
- }
-
- public AddStickerToSet setEmojis(String emojis) {
- this.emojis = emojis;
- return this;
- }
-
- public MaskPosition getMaskPosition() {
- return maskPosition;
- }
-
- public AddStickerToSet setMaskPosition(MaskPosition maskPosition) {
- this.maskPosition = maskPosition;
- return this;
- }
-
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@@ -180,16 +115,4 @@ public class AddStickerToSet extends PartialBotApiMethod {
maskPosition.validate();
}
}
-
- @Override
- public String toString() {
- return "AddStickerToSet{" +
- "userId=" + userId +
- ", name='" + name + '\'' +
- ", emojis='" + emojis + '\'' +
- ", maskPosition=" + maskPosition +
- ", pngSticker=" + pngSticker +
- ", tgsSticker=" + tgsSticker +
- '}';
- }
}
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 f42fab7f..e324098e 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
@@ -1,6 +1,15 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
+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.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@@ -8,12 +17,7 @@ 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.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -22,6 +26,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* You must use exactly one of the fields png_sticker or tgs_sticker.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class CreateNewStickerSet extends PartialBotApiMethod {
public static final String PATH = "createNewStickerSet";
@@ -34,6 +46,7 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
public static final String CONTAINSMASKS_FIELD = "contains_masks";
public static final String MASKPOSITION_FIELD = "mask_position";
+ @NonNull
private Integer userId; ///< User identifier of created sticker set owner
/**
* Name of sticker set, to be used in t.me/addstickers/ URLs.
@@ -41,12 +54,16 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
* Must begin with a letter, can't contain consecutive underscores and must end in “_by_”.
* 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
private String emojis; ///< One or more emoji corresponding to the sticker
- private Boolean containsMasks; ///< Pass True, if a set of mask stickers should be created
- private MaskPosition maskPosition; ///< Position where the mask should be placed on faces
+ private Boolean containsMasks; ///< Optional. Pass True, if a set of mask stickers should be created
+ private MaskPosition maskPosition; ///< Optional. Position where the mask should be placed on faces
/**
+ * Optional.
* 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.
* Pass a file_id as a String to send a file that already exists on the Telegram servers,
@@ -56,117 +73,12 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
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
*/
private InputFile tgsSticker;
- public CreateNewStickerSet() {
- super();
- }
-
- public CreateNewStickerSet(Integer userId, String name, String title, String emojis) {
- this.userId = checkNotNull(userId);
- this.name = checkNotNull(name);
- this.title = checkNotNull(title);
- this.emojis = checkNotNull(emojis);
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public void setUserId(Integer userId) {
- this.userId = userId;
- }
-
- public InputFile getPngSticker() {
- return pngSticker;
- }
-
- public CreateNewStickerSet setPngSticker(String pngSticker) {
- this.pngSticker = new InputFile(pngSticker);
- return this;
- }
-
- public CreateNewStickerSet setPngStickerFile(InputFile pngStickerFile) {
- Objects.requireNonNull(pngStickerFile, "pngStickerFile cannot be null!");
- this.pngSticker = pngStickerFile;
- return this;
- }
-
- public CreateNewStickerSet setPngStickerFile(File pngStickerFile) {
- Objects.requireNonNull(pngStickerFile, "pngStickerFile cannot be null!");
- this.pngSticker = new InputFile(pngStickerFile, pngStickerFile.getName());
- return this;
- }
-
- public CreateNewStickerSet setPngStickerStream(String pngStickerName, InputStream pngStickerStream) {
- Objects.requireNonNull(pngStickerName, "pngStickerName cannot be null!");
- Objects.requireNonNull(pngStickerStream, "pngStickerStream cannot be null!");
- this.pngSticker = new InputFile(pngStickerStream, pngStickerName);
- return this;
- }
-
- public CreateNewStickerSet setTgsSticker(InputFile tgsSticker) {
- this.tgsSticker = checkNotNull(tgsSticker);
- return this;
- }
-
- public CreateNewStickerSet setTgsSticker(File tgsStickerFile) {
- this.tgsSticker = new InputFile(checkNotNull(tgsStickerFile), tgsStickerFile.getName());;
- return this;
- }
-
- public CreateNewStickerSet setTgsSticker(String tgsStickerName, InputStream tgsStickerStream) {
- this.pngSticker = new InputFile(checkNotNull(tgsStickerStream), checkNotNull(tgsStickerName));
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getEmojis() {
- return emojis;
- }
-
- public void setEmojis(String emojis) {
- this.emojis = emojis;
- }
-
- public Boolean getContainsMasks() {
- return containsMasks;
- }
-
- public void setContainsMasks(Boolean containsMasks) {
- this.containsMasks = containsMasks;
- }
-
- public MaskPosition getMaskPosition() {
- return maskPosition;
- }
-
- public void setMaskPosition(MaskPosition maskPosition) {
- this.maskPosition = maskPosition;
- }
-
- public InputFile getTgsSticker() {
- return tgsSticker;
- }
-
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@@ -216,18 +128,4 @@ public class CreateNewStickerSet extends PartialBotApiMethod {
maskPosition.validate();
}
}
-
- @Override
- public String toString() {
- return "CreateNewStickerSet{" +
- "userId=" + userId +
- ", name='" + name + '\'' +
- ", title='" + title + '\'' +
- ", emojis='" + emojis + '\'' +
- ", containsMasks=" + containsMasks +
- ", maskPosition=" + maskPosition +
- ", pngSticker=" + pngSticker +
- ", tgsSticker=" + tgsSticker +
- '}';
- }
}
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 bd9cffd7..4f447fa5 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
@@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@@ -9,30 +17,27 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to delete a sticker from a set created by the bot. Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DeleteStickerFromSet extends BotApiMethod {
private static final String PATH = "deleteStickerFromSet";
private static final String STICKER_FIELD = "sticker";
@JsonProperty(STICKER_FIELD)
+ @NonNull
private String sticker; ///< File identifier of the sticker
- public DeleteStickerFromSet() {
- super();
- }
-
- public DeleteStickerFromSet(String sticker) {
- super();
- this.sticker = checkNotNull(sticker);
- }
-
@Override
public String getMethod() {
return PATH;
@@ -59,20 +64,4 @@ public class DeleteStickerFromSet extends BotApiMethod {
throw new TelegramApiValidationException("sticker can't be null", this);
}
}
-
- public String getSticker() {
- return sticker;
- }
-
- public DeleteStickerFromSet setSticker(String sticker) {
- this.sticker = sticker;
- return this;
- }
-
- @Override
- public String toString() {
- return "DeleteStickerFromSet{" +
- "sticker='" + sticker + '\'' +
- '}';
- }
}
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 28703f56..fa7fc277 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
@@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.stickers.StickerSet;
@@ -10,30 +18,27 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to get a sticker set. On success, a StickerSet object is returned.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GetStickerSet extends BotApiMethod {
private static final String PATH = "getStickerSet";
private static final String NAME_FIELD = "name";
@JsonProperty(NAME_FIELD)
+ @NonNull
private String name; ///< Name of the sticker set
- public GetStickerSet(String name) {
- super();
- this.name = checkNotNull(name);
- }
-
- public GetStickerSet() {
- super();
- }
-
@Override
public String getMethod() {
return PATH;
@@ -60,20 +65,4 @@ public class GetStickerSet extends BotApiMethod {
throw new TelegramApiValidationException("Name can't be null", this);
}
}
-
- public String getName() {
- return name;
- }
-
- public GetStickerSet setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public String toString() {
- return "GetStickerSet{" +
- "name='" + name + '\'' +
- '}';
- }
}
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 7289ad6c..43c8ffb7 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
@@ -2,6 +2,14 @@ package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@@ -9,13 +17,18 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* @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.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetStickerPositionInSet extends BotApiMethod {
private static final String PATH = "setStickerPositionInSet";
@@ -23,19 +36,12 @@ public class SetStickerPositionInSet extends BotApiMethod {
private static final String POSITION_FIELD = "position";
@JsonProperty(STICKER_FIELD)
+ @NonNull
private String sticker; ///< File identifier of the sticker
@JsonProperty(POSITION_FIELD)
+ @NonNull
private Integer position; ///< New sticker position in the set, zero-based
- public SetStickerPositionInSet(String sticker, Integer position) {
- this.sticker = checkNotNull(sticker);
- this.position = checkNotNull(position);
- }
-
- public SetStickerPositionInSet() {
- super();
- }
-
@Override
public String getMethod() {
return PATH;
@@ -65,30 +71,4 @@ public class SetStickerPositionInSet extends BotApiMethod {
throw new TelegramApiValidationException("position can't be null", this);
}
}
-
- public String getSticker() {
- return sticker;
- }
-
- public SetStickerPositionInSet setSticker(String sticker) {
- this.sticker = checkNotNull(sticker);
- return this;
- }
-
- public Integer getPosition() {
- return position;
- }
-
- public SetStickerPositionInSet setPosition(Integer position) {
- this.position = checkNotNull(position);
- return this;
- }
-
- @Override
- public String toString() {
- return "SetStickerPositionInSet{" +
- "sticker='" + sticker + '\'' +
- ", position=" + position +
- '}';
- }
}
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 5dad0304..87d8f22e 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
@@ -1,17 +1,21 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -19,6 +23,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
* Returns True on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SetStickerSetThumb extends BotApiMethod {
private static final String PATH = "setStickerSetThumb";
@@ -26,7 +37,9 @@ public class SetStickerSetThumb extends BotApiMethod {
public static final String USERID_FIELD = "user_id";
public static final String THUMB_FIELD = "thumb";
+ @NonNull
private String name; ///< Sticker set name
+ @NonNull
private Integer userId; ///< User identifier of the sticker set owner
/**
* A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px,
@@ -36,58 +49,9 @@ public class SetStickerSetThumb extends BotApiMethod {
* String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
* Animated sticker set thumbnail can't be uploaded via HTTP URL.
*/
+ @NonNull
private InputFile thumb;
- public SetStickerSetThumb() {
- super();
- }
-
- public SetStickerSetThumb(String name, Integer userId, InputFile thumb) {
- this.name = name;
- this.userId = userId;
- this.thumb = thumb;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Integer getUserId() {
- return userId;
- }
-
- public void setUserId(Integer userId) {
- this.userId = userId;
- }
-
- public InputFile getThumb() {
- return thumb;
- }
-
- public SetStickerSetThumb setThumb(String thumb) {
- this.thumb = new InputFile(thumb);
- return this;
- }
-
- public SetStickerSetThumb setThumb(InputFile thumb) {
- this.thumb = thumb;
- return this;
- }
-
- public SetStickerSetThumb setThumb(File thumbFile) {
- this.thumb = new InputFile(checkNotNull(thumbFile), thumbFile.getName());;
- return this;
- }
-
- public SetStickerSetThumb setThumb(String thumbName, InputStream thumbStream) {
- this.thumb = new InputFile(checkNotNull(thumbStream), checkNotNull(thumbName));
- return this;
- }
-
@Override
public String getMethod() {
return PATH;
@@ -121,13 +85,4 @@ public class SetStickerSetThumb extends BotApiMethod {
}
thumb.validate();
}
-
- @Override
- public String toString() {
- return "SetStickerSetThumb{" +
- "name='" + name + '\'' +
- ", userId=" + userId +
- ", thumb=" + 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 894625b4..d64b006b 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,17 +1,22 @@
package org.telegram.telegrambots.meta.api.methods.stickers;
import com.fasterxml.jackson.core.type.TypeReference;
+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.methods.PartialBotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.File;
import org.telegram.telegrambots.meta.api.objects.InputFile;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
-import java.io.InputStream;
-
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Ruben Bermudez
@@ -19,28 +24,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet
* methods (can be used multiple times). Returns the uploaded File on success.
*/
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@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";
+ @NonNull
private Integer 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 »
*/
+ @NonNull
private InputFile pngSticker; ///< New sticker file
- public UploadStickerFile() {
- super();
- }
-
- public UploadStickerFile(Integer userId) {
- super();
- this.userId = checkNotNull(userId);
- }
-
@Override
public File deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@@ -68,35 +73,4 @@ public class UploadStickerFile extends PartialBotApiMethod