Allow Long setters for ChatIds

This commit is contained in:
rubenlagus 2022-06-14 22:20:22 +02:00 committed by Ruben Bermudez
parent f650e2376a
commit ce4760d994
83 changed files with 1177 additions and 202 deletions

View File

@ -258,6 +258,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -1,12 +1,18 @@
package org.telegram.abilitybots.api.bot;
import com.google.common.collect.*;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.telegram.abilitybots.api.db.DBContext;
import org.telegram.abilitybots.api.objects.*;
import org.telegram.abilitybots.api.objects.Ability;
import org.telegram.abilitybots.api.objects.Locality;
import org.telegram.abilitybots.api.objects.MessageContext;
import org.telegram.abilitybots.api.objects.Privacy;
import org.telegram.abilitybots.api.objects.Reply;
import org.telegram.abilitybots.api.objects.ReplyCollection;
import org.telegram.abilitybots.api.objects.Stats;
import org.telegram.abilitybots.api.sender.DefaultSender;
import org.telegram.abilitybots.api.sender.MessageSender;
import org.telegram.abilitybots.api.sender.SilentSender;
@ -26,7 +32,12 @@ import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMemberOwner;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.BiFunction;
import java.util.function.Function;
@ -44,12 +55,25 @@ import static java.util.Optional.ofNullable;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.compile;
import static java.util.stream.Collectors.toSet;
import static org.telegram.abilitybots.api.objects.Locality.*;
import static org.telegram.abilitybots.api.objects.Locality.ALL;
import static org.telegram.abilitybots.api.objects.Locality.GROUP;
import static org.telegram.abilitybots.api.objects.Locality.USER;
import static org.telegram.abilitybots.api.objects.MessageContext.newContext;
import static org.telegram.abilitybots.api.objects.Privacy.*;
import static org.telegram.abilitybots.api.objects.Privacy.ADMIN;
import static org.telegram.abilitybots.api.objects.Privacy.CREATOR;
import static org.telegram.abilitybots.api.objects.Privacy.GROUP_ADMIN;
import static org.telegram.abilitybots.api.objects.Privacy.PUBLIC;
import static org.telegram.abilitybots.api.objects.Stats.createStats;
import static org.telegram.abilitybots.api.util.AbilityMessageCodes.*;
import static org.telegram.abilitybots.api.util.AbilityUtils.*;
import static org.telegram.abilitybots.api.util.AbilityMessageCodes.CHECK_INPUT_FAIL;
import static org.telegram.abilitybots.api.util.AbilityMessageCodes.CHECK_LOCALITY_FAIL;
import static org.telegram.abilitybots.api.util.AbilityMessageCodes.CHECK_PRIVACY_FAIL;
import static org.telegram.abilitybots.api.util.AbilityUtils.EMPTY_USER;
import static org.telegram.abilitybots.api.util.AbilityUtils.getChatId;
import static org.telegram.abilitybots.api.util.AbilityUtils.getLocalizedMessage;
import static org.telegram.abilitybots.api.util.AbilityUtils.getUser;
import static org.telegram.abilitybots.api.util.AbilityUtils.isGroupUpdate;
import static org.telegram.abilitybots.api.util.AbilityUtils.isSuperGroupUpdate;
import static org.telegram.abilitybots.api.util.AbilityUtils.isUserMessage;
/**
* The <b>father</b> of all ability bots. Bots that need to utilize abilities need to extend this bot.
@ -260,7 +284,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
}
public boolean isGroupAdmin(long chatId, long id) {
GetChatAdministrators admins = GetChatAdministrators.builder().chatId(Long.toString(chatId)).build();
GetChatAdministrators admins = GetChatAdministrators.builder().chatId(chatId).build();
return silent.execute(admins)
.orElse(new ArrayList<>())
.stream()

View File

@ -224,7 +224,7 @@ public final class DefaultAbilities implements AbilityExtension {
printStream.print(bot.db.backup());
bot.sender.sendDocument(SendDocument.builder()
.document(new InputFile(backup))
.chatId(ctx.chatId().toString())
.chatId(ctx.chatId())
.build()
);
} catch (FileNotFoundException e) {

View File

@ -38,7 +38,7 @@ public class SilentSender {
public Optional<Message> forceReply(String message, long id) {
SendMessage msg = new SendMessage();
msg.setText(message);
msg.setChatId(Long.toString(id));
msg.setChatId(id);
ForceReplyKeyboard kb = new ForceReplyKeyboard();
kb.setForceReply(true);
kb.setSelective(true);
@ -67,7 +67,7 @@ public class SilentSender {
private Optional<Message> doSendMessage(String txt, long groupId, boolean format) {
SendMessage smsg = new SendMessage();
smsg.setChatId(Long.toString(groupId));
smsg.setChatId(groupId);
smsg.setText(txt);
smsg.enableMarkdown(format);

View File

@ -249,6 +249,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -233,6 +233,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -1,11 +1,11 @@
package org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.ICommandRegistry;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Chat;
import org.telegram.telegrambots.meta.api.objects.User;
import org.telegram.telegrambots.meta.bots.AbsSender;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand;
import org.telegram.telegrambots.extensions.bots.commandbot.commands.ICommandRegistry;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import java.util.Collection;
@ -98,14 +98,14 @@ public class HelpCommand extends ManCommand {
IBotCommand command = registry.getRegisteredCommand(arguments[0]);
String reply = getManText(command);
try {
absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
absSender.execute(SendMessage.builder().chatId(chat.getId()).text(reply).parseMode("HTML").build());
} catch (TelegramApiException e) {
e.printStackTrace();
}
} else {
String reply = getHelpText(registry);
try {
absSender.execute(SendMessage.builder().chatId(chat.getId().toString()).text(reply).parseMode("HTML").build());
absSender.execute(SendMessage.builder().chatId(chat.getId()).text(reply).parseMode("HTML").build());
} catch (TelegramApiException e) {
e.printStackTrace();
}

View File

@ -256,6 +256,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -12,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
import org.telegram.telegrambots.meta.api.objects.MessageId;
@ -89,6 +90,16 @@ public class CopyMessage extends BotApiMethod<MessageId> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Tolerate
public void setFromChatId(@NonNull Long fromChatId) {
this.fromChatId = fromChatId.toString();
}
public void enableNotification() {
this.disableNotification = null;
}
@ -143,15 +154,9 @@ public class CopyMessage extends BotApiMethod<MessageId> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
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);
@ -160,4 +165,19 @@ public class CopyMessage extends BotApiMethod<MessageId> {
replyMarkup.validate();
}
}
public static class CopyMessageBuilder {
@Tolerate
public CopyMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
@Tolerate
public CopyMessageBuilder fromChatId(@NonNull Long fromChatId) {
this.fromChatId = fromChatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -63,17 +64,24 @@ public class ForwardMessage extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Tolerate
public void setFromChatId(@NonNull Long fromChatId) {
this.fromChatId = fromChatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (fromChatId == null || fromChatId.isEmpty()) {
if (fromChatId.isEmpty()) {
throw new TelegramApiValidationException("FromChatId can't be empty", this);
}
if (messageId == null) {
throw new TelegramApiValidationException("MessageId can't be empty", this);
}
}
@Override
@ -95,4 +103,19 @@ public class ForwardMessage extends BotApiMethod<Message> {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
public static class ForwardMessageBuilder {
@Tolerate
public ForwardMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
@Tolerate
public ForwardMessageBuilder fromChatId(@NonNull Long fromChatId) {
this.fromChatId = fromChatId.toString();
return this;
}
}
}

View File

@ -9,6 +9,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
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;
@ -59,6 +60,11 @@ public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
@JsonProperty(REPLYMARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -111,4 +117,13 @@ public class StopMessageLiveLocation extends BotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class StopMessageLiveLocationBuilder {
@Tolerate
public StopMessageLiveLocationBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -18,7 +18,6 @@ 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;
@ -28,9 +27,10 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
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;
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -76,6 +76,11 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
@NonNull
private Long userId; ///<Target user id
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -98,9 +103,6 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
@Override
public void validate() throws TelegramApiValidationException {
if (userId == null) {
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
}
if (inlineMessageId == null) {
if (chatId == null || chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
@ -117,4 +119,13 @@ public class GetGameHighScores extends BotApiMethod<ArrayList<GameHighScore>> {
}
}
}
public static class GetGameHighScoresBuilder {
@Tolerate
public GetGameHighScoresBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -19,7 +19,6 @@ 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;
@ -29,9 +28,10 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
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.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -84,6 +84,11 @@ public class SetGameScore extends BotApiMethod<Serializable> {
@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
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -117,12 +122,6 @@ public class SetGameScore extends BotApiMethod<Serializable> {
@Override
public void validate() throws TelegramApiValidationException {
if (userId == null) {
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
}
if (score == null) {
throw new TelegramApiValidationException("Score parameter can't be empty", this);
}
if (inlineMessageId == null) {
if (chatId == null || chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty if inlineMessageId is not present", this);
@ -139,4 +138,13 @@ public class SetGameScore extends BotApiMethod<Serializable> {
}
}
}
public static class SetGameScoreBuilder {
@Tolerate
public SetGameScoreBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
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 lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -37,6 +45,11 @@ public class ApproveChatJoinRequest extends BotApiMethod<Boolean> {
@NonNull
private Long userId; ///< Required. Unique identifier of the target user
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -66,4 +79,13 @@ public class ApproveChatJoinRequest extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("UserId can't be null or 0", this);
}
}
public static class ApproveChatJoinRequestBuilder {
@Tolerate
public ApproveChatJoinRequestBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -12,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -69,6 +70,10 @@ public class BanChatMember extends BotApiMethod<Boolean> {
@JsonProperty(REVOKEMESSAGES_FIELD)
private Boolean revokeMessages;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@JsonIgnore
public void setUntilDateInstant(Instant instant) {
@ -107,11 +112,21 @@ public class BanChatMember extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == null || userId == 0) {
if (userId == 0) {
throw new TelegramApiValidationException("UserId can't be null or 0", this);
}
}
public static class BanChatMemberBuilder {
@Tolerate
public BanChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -3,7 +3,16 @@ 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.*;
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 lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -51,6 +60,11 @@ public class BanChatSenderChat extends BotApiMethod<Boolean> {
@JsonProperty(UNTILDATE_FIELD)
private Integer untilDate;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@JsonIgnore
public void setUntilDateInstant(Instant instant) {
setUntilDate((int) instant.getEpochSecond());
@ -95,4 +109,13 @@ public class BanChatSenderChat extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("SenderChatId can't be null or 0", this);
}
}
public static class BanChatSenderChatBuilder {
@Tolerate
public BanChatSenderChatBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
@ -69,6 +70,10 @@ public class CreateChatInviteLink extends BotApiMethod<ChatInviteLink> {
@JsonProperty(CREATESJOINREQUEST_FIELD)
private Boolean createsJoinRequest;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
@ -105,4 +110,13 @@ public class CreateChatInviteLink extends BotApiMethod<ChatInviteLink> {
throw new TelegramApiValidationException("MemberLimit must be between 1 and 99999", this);
}
}
public static class CreateChatInviteLinkBuilder {
@Tolerate
public CreateChatInviteLinkBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
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 lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -37,6 +45,11 @@ public class DeclineChatJoinRequest extends BotApiMethod<Boolean> {
@NonNull
private Long userId; ///< Required. Unique identifier of the target user
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -66,4 +79,13 @@ public class DeclineChatJoinRequest extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("UserId can't be null or 0", this);
}
}
public static class DeclineChatJoinRequestBuilder {
@Tolerate
public DeclineChatJoinRequestBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -42,6 +43,11 @@ public class DeleteChatPhoto extends BotApiMethod<Boolean> {
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -64,8 +70,17 @@ public class DeleteChatPhoto extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be null", this);
}
}
public static class DeleteChatPhotoBuilder {
@Tolerate
public DeleteChatPhotoBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -41,6 +42,11 @@ public class DeleteChatStickerSet extends BotApiMethod<Boolean> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -63,8 +69,17 @@ public class DeleteChatStickerSet extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
public static class DeleteChatStickerSetBuilder {
@Tolerate
public DeleteChatStickerSetBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -12,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
@ -74,6 +75,10 @@ public class EditChatInviteLink extends BotApiMethod<ChatInviteLink> {
@JsonProperty(CREATESJOINREQUEST_FIELD)
private Boolean createsJoinRequest;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
@ -113,4 +118,13 @@ public class EditChatInviteLink extends BotApiMethod<ChatInviteLink> {
throw new TelegramApiValidationException("MemberLimit must be between 1 and 99999", this);
}
}
public static class EditChatInviteLinkBuilder {
@Tolerate
public EditChatInviteLinkBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -47,6 +48,11 @@ public class ExportChatInviteLink extends BotApiMethod<String> {
@NonNull
private String chatId; ///< Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -69,8 +75,17 @@ public class ExportChatInviteLink extends BotApiMethod<String> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
public static class ExportChatInviteLinkBuilder {
@Tolerate
public ExportChatInviteLinkBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Chat;
@ -44,6 +45,11 @@ public class GetChat extends BotApiMethod<Chat> {
return PATH;
}
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public Chat deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -61,8 +67,17 @@ public class GetChat extends BotApiMethod<Chat> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
public static class GetChatBuilder {
@Tolerate
public GetChatBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMember;
@ -44,6 +45,11 @@ public class GetChatAdministrators extends BotApiMethod<ArrayList<ChatMember>> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -66,8 +72,17 @@ public class GetChatAdministrators extends BotApiMethod<ArrayList<ChatMember>> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
public static class GetChatAdministratorsBuilder {
@Tolerate
public GetChatAdministratorsBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMember;
@ -44,6 +45,11 @@ public class GetChatMember extends BotApiMethod<ChatMember> {
@NonNull
private Long userId; ///< Unique identifier of the target user
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -66,11 +72,17 @@ public class GetChatMember extends BotApiMethod<ChatMember> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == null) {
throw new TelegramApiValidationException("UserId can't be null", this);
}
public static class GetChatMemberBuilder {
@Tolerate
public GetChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -38,6 +39,11 @@ public class GetChatMemberCount extends BotApiMethod<Integer> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -60,8 +66,17 @@ public class GetChatMemberCount extends BotApiMethod<Integer> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
}
public static class GetChatMemberCountBuilder {
@Tolerate
public GetChatMemberCountBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -38,6 +39,11 @@ public class LeaveChat extends BotApiMethod<Boolean> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -60,8 +66,17 @@ public class LeaveChat extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be null", this);
}
}
public static class LeaveChatBuilder {
@Tolerate
public LeaveChatBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -92,6 +93,11 @@ public class PromoteChatMember extends BotApiMethod<Boolean> {
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
private Boolean canManageVideoChats;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -122,4 +128,14 @@ public class PromoteChatMember extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("UserId can't be empty", this);
}
}
public static class PromoteChatMemberBuilder {
@Tolerate
public PromoteChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -12,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
@ -70,6 +71,11 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
@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
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@JsonIgnore
public void setUntilDateInstant(Instant instant) {
setUntilDate((int) instant.getEpochSecond());
@ -107,14 +113,17 @@ public class RestrictChatMember extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == null) {
throw new TelegramApiValidationException("UserId can't be empty", this);
}
if (permissions == null) {
throw new TelegramApiValidationException("Permissions can't be empty", this);
}
public static class RestrictChatMemberBuilder {
@Tolerate
public RestrictChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatInviteLink;
@ -51,6 +52,11 @@ public class RevokeChatInviteLink extends BotApiMethod<ChatInviteLink> {
@NonNull
private String inviteLink; ///< The invite link to revoke
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -80,4 +86,13 @@ public class RevokeChatInviteLink extends BotApiMethod<ChatInviteLink> {
throw new TelegramApiValidationException("InviteLink can't be empty", this);
}
}
public static class RevokeChatInviteLinkBuilder {
@Tolerate
public RevokeChatInviteLinkBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -47,6 +48,11 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod<Boolean> {
@NonNull
private String customTitle; ///< New custom title for the administrator; 0-16 characters, emoji are not allowed
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -69,14 +75,20 @@ public class SetChatAdministratorCustomTitle extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == null || userId == 0) {
if (userId == 0) {
throw new TelegramApiValidationException("UserId can't be empty", this);
}
if (customTitle == null) {
throw new TelegramApiValidationException("CustomTitle can't be null", this);
}
public static class SetChatAdministratorCustomTitleBuilder {
@Tolerate
public SetChatAdministratorCustomTitleBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -45,6 +46,11 @@ public class SetChatDescription extends BotApiMethod<Boolean> {
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. New chat description, 0-255 characters
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -67,11 +73,20 @@ public class SetChatDescription extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (description == null) {
throw new TelegramApiValidationException("Description can't be null", this);
}
}
public static class SetChatDescriptionBuilder {
@Tolerate
public SetChatDescriptionBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.ChatPermissions;
@ -45,6 +46,11 @@ public class SetChatPermissions extends BotApiMethod<Boolean> {
@NonNull
private ChatPermissions permissions; ///< New default chat permissions
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -67,11 +73,17 @@ public class SetChatPermissions extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (permissions == null) {
throw new TelegramApiValidationException("Permissions can't be null", this);
}
public static class SetChatPermissionsBuilder {
@Tolerate
public SetChatPermissionsBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -44,6 +45,11 @@ public class SetChatPhoto extends PartialBotApiMethod<Boolean> {
@NonNull
private InputFile photo; ///< New chat photo as InputStream, uploaded using multipart/form-data
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -61,11 +67,20 @@ public class SetChatPhoto extends PartialBotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (photo == null || !photo.isNew()) {
if (!photo.isNew()) {
throw new TelegramApiValidationException("Photo parameter is required and must be a new file to upload", this);
}
}
public static class SetChatPhotoBuilder {
@Tolerate
public SetChatPhotoBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -45,6 +46,11 @@ public class SetChatStickerSet extends BotApiMethod<Boolean> {
@NonNull
private String stickerSetName; ///< Name of the sticker set to be set as the group sticker set
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -67,11 +73,20 @@ public class SetChatStickerSet extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (stickerSetName == null || stickerSetName.isEmpty()) {
if (stickerSetName.isEmpty()) {
throw new TelegramApiValidationException("StickerSetName can't be empty", this);
}
}
public static class SetChatStickerSetBuilder {
@Tolerate
public SetChatStickerSetBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -46,6 +47,11 @@ public class SetChatTitle extends BotApiMethod<Boolean> {
@NonNull
private String title; ///< Required. New chat title, 1-255 characters
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -68,11 +74,20 @@ public class SetChatTitle extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title can't be empty", this);
}
}
public static class SetChatTitleBuilder {
@Tolerate
public SetChatTitleBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -54,6 +55,10 @@ public class UnbanChatMember extends BotApiMethod<Boolean> {
@JsonProperty(ONLYISBANNED_FIELD)
private Boolean onlyIfBanned; ///< Optional. Do nothing if the user is not banned
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
@ -77,11 +82,17 @@ public class UnbanChatMember extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == null) {
throw new TelegramApiValidationException("UserId can't be null", this);
}
public static class UnbanChatMemberBuilder {
@Tolerate
public UnbanChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -25,7 +33,7 @@ import java.io.IOException;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class unbanChatSenderChat extends BotApiMethod<Boolean> {
public class UnbanChatSenderChat extends BotApiMethod<Boolean> {
public static final String PATH = "unbanChatSenderChat";
private static final String CHATID_FIELD = "chat_id";
@ -38,6 +46,11 @@ public class unbanChatSenderChat extends BotApiMethod<Boolean> {
@NonNull
private Long senderChatId; ///< Required. Unique identifier of the target sender chat
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -67,4 +80,13 @@ public class unbanChatSenderChat extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("SenderChatId can't be null or 0", this);
}
}
public static class UnbanChatSenderChatBuilder {
@Tolerate
public UnbanChatSenderChatBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -2,7 +2,15 @@ package org.telegram.telegrambots.meta.api.methods.menubutton;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButton;
@ -39,6 +47,11 @@ public class GetChatMenuButton extends BotApiMethod<MenuButton> {
@JsonProperty(CHATID_FIELD)
private String chatId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
@ -63,4 +76,13 @@ public class GetChatMenuButton extends BotApiMethod<MenuButton> {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
public static class GetChatMenuButtonBuilder {
@Tolerate
public GetChatMenuButtonBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -2,12 +2,18 @@ package org.telegram.telegrambots.meta.api.methods.menubutton;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButton;
import org.telegram.telegrambots.meta.api.objects.webapp.SentWebAppMessage;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@ -49,6 +55,11 @@ public class SetChatMenuButton extends BotApiMethod<Boolean> {
@JsonProperty(MENUBUTTON_FIELD)
private MenuButton menuButton;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (menuButton != null) {
@ -75,4 +86,13 @@ public class SetChatMenuButton extends BotApiMethod<Boolean> {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
public static class SetChatMenuButtonBuilder {
@Tolerate
public SetChatMenuButtonBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -55,6 +56,11 @@ public class PinChatMessage extends BotApiMethod<Boolean> {
@JsonProperty(DISABLENOTIFICATION_FIELD)
private Boolean disableNotification;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -77,11 +83,17 @@ public class PinChatMessage extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (messageId == null) {
throw new TelegramApiValidationException("MessageId parameter can't be null", this);
}
public static class PinChatMessageBuilder {
@Tolerate
public PinChatMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -43,6 +44,11 @@ public class UnpinAllChatMessages extends BotApiMethod<Boolean> {
@NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -65,8 +71,17 @@ public class UnpinAllChatMessages extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
}
public static class UnpinAllChatMessagesBuilder {
@Tolerate
public UnpinAllChatMessagesBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -54,6 +55,11 @@ public class UnpinChatMessage extends BotApiMethod<Boolean> {
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -76,8 +82,17 @@ public class UnpinChatMessage extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
}
public static class UnpinChatMessageBuilder {
@Tolerate
public UnpinChatMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -109,6 +110,11 @@ public class SendPoll extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = null;
}
@ -140,13 +146,13 @@ public class SendPoll extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (question == null || question.isEmpty()) {
if (question.isEmpty()) {
throw new TelegramApiValidationException("Question parameter can't be empty", this);
}
if (options == null || options.size() < 2 || options.size() > 10) {
if (options.size() < 2 || options.size() > 10) {
throw new TelegramApiValidationException("Options parameter must be between 2 and 10 item", this);
}
if (openPeriod != null && closeDate != null) {
@ -168,4 +174,14 @@ public class SendPoll extends BotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendPollBuilder {
@Tolerate
public SendPollBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
@ -45,6 +46,11 @@ public class StopPoll extends BotApiMethod<Poll> {
@NonNull
private Integer messageId; ///< Identifier of the original message with the poll
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -67,11 +73,21 @@ public class StopPoll extends BotApiMethod<Poll> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (messageId == null || messageId == 0) {
if (messageId == 0) {
throw new TelegramApiValidationException("Message Id parameter can't be empty", this);
}
}
public static class StopPollBuilder {
@Tolerate
public StopPollBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -89,6 +89,11 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -114,14 +119,10 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (animation == null) {
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);
}
@ -135,4 +136,13 @@ public class SendAnimation extends PartialBotApiMethod<Message> {
thumb.validate();
}
}
public static class SendAnimationBuilder {
@Tolerate
public SendAnimationBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -85,6 +85,11 @@ public class SendAudio extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -110,14 +115,10 @@ public class SendAudio extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (audio == null) {
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);
}
@ -132,4 +133,13 @@ public class SendAudio extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendAudioBuilder {
@Tolerate
public SendAudioBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.ActionType;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@ -59,6 +60,11 @@ public class SendChatAction extends BotApiMethod<Boolean> {
@NonNull
private String action;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@JsonIgnore
public ActionType getActionType() {
return ActionType.get(action);
@ -98,4 +104,13 @@ public class SendChatAction extends BotApiMethod<Boolean> {
throw new TelegramApiValidationException("Action parameter can't be empty", this);
}
}
public static class SendChatActionBuilder {
@Tolerate
public SendChatActionBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -72,6 +73,11 @@ public class SendContact extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -102,17 +108,20 @@ public class SendContact extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (phoneNumber == null) {
throw new TelegramApiValidationException("PhoneNumber parameter can't be empty", this);
}
if (firstName == null) {
throw new TelegramApiValidationException("FirstName parameter can't be empty", this);
}
if (replyMarkup != null) {
replyMarkup.validate();
}
}
public static class SendContactBuilder {
@Tolerate
public SendContactBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -76,6 +77,11 @@ public class SendDice extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -106,7 +112,7 @@ public class SendDice extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (emoji != null && !VALIDEMOJIS.contains(emoji)) {
@ -116,4 +122,13 @@ public class SendDice extends BotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendDiceBuilder {
@Tolerate
public SendDiceBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -77,6 +77,11 @@ public class SendDocument extends PartialBotApiMethod<Message> {
private Boolean disableContentTypeDetection; ///< Optional Disables automatic server-side content type detection for files uploaded using multipart/form-data
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -102,14 +107,10 @@ public class SendDocument extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (document == null) {
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);
}
@ -124,4 +125,13 @@ public class SendDocument extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendDocumentBuilder {
@Tolerate
public SendDocumentBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -28,6 +28,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -78,6 +79,11 @@ public class SendGame extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = null;
}
@ -108,14 +114,23 @@ public class SendGame extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (gameShortName == null || gameShortName.isEmpty()) {
if (gameShortName.isEmpty()) {
throw new TelegramApiValidationException("GameShortName parameter can't be empty", this);
}
if (replyMarkup != null) {
replyMarkup.validate();
}
}
public static class SendGameBuilder {
@Tolerate
public SendGameBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -165,6 +166,11 @@ public class SendInvoice extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -205,7 +211,7 @@ public class SendInvoice extends BotApiMethod<Message> {
if (Strings.isNullOrEmpty(currency)) {
throw new TelegramApiValidationException("Currency parameter can't be empty", this);
}
if (prices == null || prices.isEmpty()) {
if (prices.isEmpty()) {
throw new TelegramApiValidationException("Prices parameter can't be empty", this);
} else {
for (LabeledPrice price : prices) {
@ -219,4 +225,13 @@ public class SendInvoice extends BotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendInvoiceBuilder {
@Tolerate
public SendInvoiceBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -91,6 +92,11 @@ public class SendLocation extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -121,15 +127,9 @@ public class SendLocation extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (horizontalAccuracy != null && (horizontalAccuracy < 0 || horizontalAccuracy > 1500)) {
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
}
@ -146,4 +146,13 @@ public class SendLocation extends BotApiMethod<Message> {
throw new TelegramApiValidationException("Live period parameter must be between 60 and 86400", this);
}
}
public static class SendLocationBuilder {
@Tolerate
public SendLocationBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -66,6 +67,11 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -92,11 +98,11 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (medias == null || medias.isEmpty()) {
if (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);
@ -122,4 +128,13 @@ public class SendMediaGroup extends PartialBotApiMethod<ArrayList<Message>> {
}
}
}
public static class SendMediaGroupBuilder {
@Tolerate
public SendMediaGroupBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -12,6 +12,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.ParseMode;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@ -76,6 +77,11 @@ public class SendMessage extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void disableWebPagePreview() {
disableWebPagePreview = true;
}
@ -138,10 +144,10 @@ public class SendMessage extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (text == null || text.isEmpty()) {
if (text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
@ -151,4 +157,13 @@ public class SendMessage extends BotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendMessageBuilder {
@Tolerate
public SendMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -66,6 +66,11 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -96,14 +101,10 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (photo == null) {
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);
}
@ -113,4 +114,13 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendPhotoBuilder {
@Tolerate
public SendPhotoBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -55,6 +56,11 @@ public class SendSticker extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public Boolean getDisableNotification() {
return disableNotification;
}
@ -94,4 +100,13 @@ public class SendSticker extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendStickerBuilder {
@Tolerate
public SendStickerBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -86,6 +87,11 @@ public class SendVenue extends BotApiMethod<Message> {
@JsonProperty(PROTECTCONTENT_FIELD)
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -116,23 +122,23 @@ public class SendVenue extends BotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
if (title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (address == null) {
throw new TelegramApiValidationException("Address parameter can't be empty", this);
}
if (replyMarkup != null) {
replyMarkup.validate();
}
}
public static class SendVenueBuilder {
@Tolerate
public SendVenueBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -84,6 +84,11 @@ public class SendVideo extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -109,14 +114,10 @@ public class SendVideo extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (video == null) {
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);
}
@ -130,4 +131,13 @@ public class SendVideo extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendVideoBuilder {
@Tolerate
public SendVideoBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -11,6 +10,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -70,6 +70,11 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -95,14 +100,10 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (videoNote == null) {
throw new TelegramApiValidationException("VideoNote parameter can't be empty", this);
}
videoNote.validate();
if (thumb != null) {
@ -112,4 +113,13 @@ public class SendVideoNote extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendVideoNoteBuilder {
@Tolerate
public SendVideoNoteBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -1,6 +1,5 @@
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;
@ -12,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.InputFile;
@ -69,6 +69,11 @@ public class SendVoice extends PartialBotApiMethod<Message> {
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
public void enableNotification() {
this.disableNotification = false;
}
@ -94,13 +99,10 @@ public class SendVoice extends PartialBotApiMethod<Message> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
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);
}
@ -110,4 +112,13 @@ public class SendVoice extends PartialBotApiMethod<Message> {
replyMarkup.validate();
}
}
public static class SendVoiceBuilder {
@Tolerate
public SendVoiceBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
@ -56,6 +57,11 @@ public class DeleteMessage extends BotApiMethod<Boolean> {
@NonNull
private Integer messageId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -79,11 +85,17 @@ public class DeleteMessage extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (messageId == null) {
throw new TelegramApiValidationException("MessageId parameter can't be empty", this);
}
public static class DeleteMessageBuilder {
@Tolerate
public DeleteMessageBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -72,6 +73,11 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
@Singular
private List<MessageEntity> captionEntities; ///< Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -127,4 +133,13 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class EditMessageCaptionBuilder {
@Tolerate
public EditMessageCaptionBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -93,6 +94,11 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
@JsonProperty(PROXIMITYALERTRADIUS_FIELD)
private Integer proximityAlertRadius;
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -141,12 +147,6 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
throw new TelegramApiValidationException("MessageId parameter must be empty if inlineMessageId is provided", this);
}
}
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (horizontalAccuracy != null && (horizontalAccuracy < 0 || horizontalAccuracy > 1500)) {
throw new TelegramApiValidationException("Horizontal Accuracy parameter must be between 0 and 1500", this);
}
@ -160,4 +160,13 @@ public class EditMessageLiveLocation extends BotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class EditMessageLiveLocationBuilder {
@Tolerate
public EditMessageLiveLocationBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -75,6 +76,11 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
@JsonProperty(REPLYMARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public Serializable deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -118,9 +124,6 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
throw new TelegramApiValidationException("MessageId parameter must be empty if inlineMessageId is provided", this);
}
}
if (media == null) {
throw new TelegramApiValidationException("Media parameter can't be empty", this);
}
media.validate();
@ -128,4 +131,13 @@ public class EditMessageMedia extends PartialBotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class EditMessageMediaBuilder {
@Tolerate
public EditMessageMediaBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -9,6 +9,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.api.objects.Message;
@ -60,6 +61,11 @@ public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
@JsonProperty(REPLYMARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -112,4 +118,13 @@ public class EditMessageReplyMarkup extends BotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class EditMessageReplyMarkupBuilder {
@Tolerate
public EditMessageReplyMarkupBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -11,6 +11,7 @@ import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.methods.ParseMode;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
@ -110,6 +111,11 @@ public class EditMessageText extends BotApiMethod<Serializable> {
}
}
@Tolerate
public void setChatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
}
@Override
public String getMethod() {
return PATH;
@ -158,7 +164,7 @@ public class EditMessageText extends BotApiMethod<Serializable> {
throw new TelegramApiValidationException("MessageId parameter must be empty if inlineMessageId is provided", this);
}
}
if (text == null || text.isEmpty()) {
if (text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
if (parseMode != null && (entities != null && !entities.isEmpty()) ) {
@ -168,4 +174,13 @@ public class EditMessageText extends BotApiMethod<Serializable> {
replyMarkup.validate();
}
}
public static class EditMessageTextBuilder {
@Tolerate
public EditMessageTextBuilder chatId(Long chatId) {
this.chatId = chatId == null ? null : chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
@ -42,10 +43,24 @@ public class BotCommandScopeChat implements BotCommandScope {
@NonNull
private String chatId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
}
public static class BotCommandScopeChatBuilder {
@Tolerate
public BotCommandScopeChatBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
@ -42,10 +43,24 @@ public class BotCommandScopeChatAdministrators implements BotCommandScope {
@NonNull
private String chatId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
}
public static class BotCommandScopeChatAdministratorsBuilder {
@Tolerate
public BotCommandScopeChatAdministratorsBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Tolerate;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
@ -49,13 +50,27 @@ public class BotCommandScopeChatMember implements BotCommandScope {
@NonNull
private Long userId;
@Tolerate
public void setChatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (userId == null || userId == 0L) {
if (userId == 0L) {
throw new TelegramApiValidationException("UserId parameter can't be empty", this);
}
}
public static class BotCommandScopeChatMemberBuilder {
@Tolerate
public BotCommandScopeChatMemberBuilder chatId(@NonNull Long chatId) {
this.chatId = chatId.toString();
return this;
}
}
}

View File

@ -16,7 +16,7 @@ public class BanChatMemberTest {
public void testBanChatMemberWithAllSet() {
BanChatMember banChatMember = BanChatMember
.builder()
.chatId("12345")
.chatId(12345L)
.userId(12345L)
.untilDate(1000)
.revokeMessages(true)

View File

@ -16,7 +16,7 @@ public class GetChatMemberCountTest {
public void testGetChatMemberCountWithAllSet() {
GetChatMemberCount getChatMemberCount = GetChatMemberCount
.builder()
.chatId("12345")
.chatId(12345L)
.build();
assertEquals("getChatMemberCount", getChatMemberCount.getMethod());
assertDoesNotThrow(getChatMemberCount::validate);

View File

@ -4,7 +4,11 @@ import org.junit.jupiter.api.Test;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Ruben Bermudez
@ -15,7 +19,7 @@ public class PromoteChatMemberTest {
public void testPromoteChatMemberWithAllSet() {
PromoteChatMember promoteChatMember = PromoteChatMember
.builder()
.chatId("12345")
.chatId(12345L)
.userId(12345L)
.build();
assertEquals("promoteChatMember", promoteChatMember.getMethod());

View File

@ -5,7 +5,11 @@ import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButton;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButtonDefault;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Ruben Bermudez
@ -26,7 +30,7 @@ public class GetChatMenuButtonTest {
public void testGetChatMenuButtonForChat() {
GetChatMenuButton getChatMenuButton = GetChatMenuButton
.builder()
.chatId("123456")
.chatId(123456L)
.build();
assertEquals("getChatMenuButton", getChatMenuButton.getMethod());
assertDoesNotThrow(getChatMenuButton::validate);

View File

@ -1,7 +1,6 @@
package org.telegram.telegrambots.meta.api.methods.menubutton;
import org.junit.jupiter.api.Test;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButton;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButtonCommands;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButtonDefault;
import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButtonWebApp;
@ -9,7 +8,11 @@ import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Ruben Bermudez
@ -31,7 +34,7 @@ public class SetChatMenuButtonTest {
public void testGetChatMenuButtonAsCommands() {
SetChatMenuButton setChatMenuButton = SetChatMenuButton
.builder()
.chatId("123456")
.chatId(123456L)
.menuButton(MenuButtonCommands.builder().build())
.build();
assertEquals("setChatMenuButton", setChatMenuButton.getMethod());

View File

@ -112,7 +112,7 @@ public class SendInvoiceTest {
private SendInvoice createSendInvoiceObject() {
return SendInvoice.builder()
.chatId("123456")
.chatId(123456L)
.title("Title")
.description("Description")
.payload("Payload")

View File

@ -11,7 +11,7 @@ class SendMessageTest {
void comparison() {
SendMessage sm1 = SendMessage
.builder()
.chatId("1")
.chatId(1L)
.text("Hello World")
.build();
SendMessage sm2 = SendMessage
@ -26,7 +26,6 @@ class SendMessageTest {
.disableNotification(true)
.build();
sm1.equals(sm2);
assertEquals(sm1, sm2);
assertNotEquals(sm1, disabledNotification);

View File

@ -44,7 +44,7 @@ public class BotCommandScopeTest {
public void testBotCommandScopeChatWithValidChatIId() {
BotCommandScopeChat botCommandScope = BotCommandScopeChat
.builder()
.chatId("12345")
.chatId(12345L)
.build();
assertEquals("chat", botCommandScope.getType());
assertDoesNotThrow(botCommandScope::validate);
@ -87,7 +87,7 @@ public class BotCommandScopeTest {
public void testBotCommandScopeChatMemberWithValidSetUp() {
BotCommandScopeChatMember botCommandScope = BotCommandScopeChatMember
.builder()
.chatId("12345")
.chatId(12345L)
.userId(12345L)
.build();
assertEquals("chat_member", botCommandScope.getType());

View File

@ -27,7 +27,7 @@ public class TestSerialization {
@Test
void testSendLocation() throws JsonProcessingException {
SendLocation location = SendLocation.builder()
.chatId("12345")
.chatId(12345L)
.latitude(20.758069)
.longitude(-0.005702)
.horizontalAccuracy(65.00000)

View File

@ -1,7 +1,6 @@
package org.telegram.telegrambots.meta.test.apimethods;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.telegram.telegrambots.meta.api.methods.games.SetGameScore;
@ -26,7 +25,7 @@ class TestSetGameScore {
@BeforeEach
void setUp() {
setGameScore = new SetGameScore();
setGameScore.setChatId("12345");
setGameScore.setChatId(12345L);
setGameScore.setDisableEditMessage(true);
setGameScore.setMessageId(54321);
setGameScore.setScore(12);

View File

@ -267,6 +267,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -338,6 +338,13 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>