More cleanup
This commit is contained in:
parent
bea0b95fc7
commit
3275c10913
2
pom.xml
2
pom.xml
@ -67,7 +67,7 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
|
||||
<junit.version>5.5.2</junit.version>
|
||||
<junit.version>5.6.2</junit.version>
|
||||
<mockito.version>3.1.0</mockito.version>
|
||||
<mockitojupiter.version>3.1.0</mockitojupiter.version>
|
||||
<jacksonbase.version>2.10.1</jacksonbase.version>
|
||||
|
@ -25,7 +25,7 @@ import static org.telegram.abilitybots.api.objects.Flag.*;
|
||||
* Helper and utility methods
|
||||
*/
|
||||
public final class AbilityUtils {
|
||||
public static User EMPTY_USER = new User(0, "", false, "", "", "");
|
||||
public static User EMPTY_USER = new User(0, "", false);
|
||||
|
||||
private AbilityUtils() {
|
||||
|
||||
@ -37,7 +37,7 @@ public final class AbilityUtils {
|
||||
*/
|
||||
public static String stripTag(String username) {
|
||||
String lowerCase = username.toLowerCase();
|
||||
return lowerCase.startsWith("@") ? lowerCase.substring(1, lowerCase.length()) : lowerCase;
|
||||
return lowerCase.startsWith("@") ? lowerCase.substring(1) : lowerCase;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,7 +252,7 @@ public final class AbilityUtils {
|
||||
* The full name is identified as the concatenation of the first and last name, separated by a space.
|
||||
* This method can return an empty name if both first and last name are empty.
|
||||
*
|
||||
* @param user
|
||||
* @param user User to use
|
||||
* @return the full name of the user
|
||||
*/
|
||||
public static String fullName(User user) {
|
||||
|
@ -19,8 +19,8 @@ import static org.telegram.abilitybots.api.bot.TestUtils.mockContext;
|
||||
import static org.telegram.abilitybots.api.db.MapDBContext.offlineInstance;
|
||||
|
||||
class AbilityBotI18nTest {
|
||||
private static final User NO_LANGUAGE_USER = new User(1, "first", false, "last", "username", null);
|
||||
private static final User ITALIAN_USER = new User(2, "first", false, "last", "username", "it-IT");
|
||||
private static final User NO_LANGUAGE_USER = new User(1, "first", false, "last", "username", null, false, false, false);
|
||||
private static final User ITALIAN_USER = new User(2, "first", false, "last", "username", "it-IT", false, false, false);
|
||||
|
||||
private DBContext db;
|
||||
private NoPublicCommandsBot bot;
|
||||
|
@ -351,7 +351,7 @@ public class AbilityBotTest {
|
||||
String newFirstName = USER.getFirstName() + "-test";
|
||||
String newLastName = USER.getLastName() + "-test";
|
||||
int sameId = USER.getId();
|
||||
User changedUser = new User(sameId, newFirstName, false, newLastName, newUsername, null);
|
||||
User changedUser = new User(sameId, newFirstName, false, newLastName, newUsername, "en", false, false, false);
|
||||
|
||||
mockAlternateUser(update, message, changedUser);
|
||||
|
||||
@ -515,6 +515,7 @@ public class AbilityBotTest {
|
||||
assertTrue(bot.checkGlobalFlags(update), "Unexpected result when checking for the default global flags");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"NumericOverflow", "divzero"})
|
||||
@Test
|
||||
void canConsumeUpdate() {
|
||||
Ability ability = getDefaultBuilder()
|
||||
|
@ -22,7 +22,7 @@ import static org.telegram.abilitybots.api.objects.Locality.ALL;
|
||||
import static org.telegram.abilitybots.api.objects.Privacy.PUBLIC;
|
||||
|
||||
public class ContinuousTextTest {
|
||||
private static final User USER = new User(1, "first", false, "last", "username", null);
|
||||
private static final User USER = new User(1, "first", false);
|
||||
|
||||
private DBContext db;
|
||||
|
||||
|
@ -11,8 +11,8 @@ import static org.mockito.Mockito.when;
|
||||
import static org.telegram.abilitybots.api.objects.MessageContext.newContext;
|
||||
|
||||
public final class TestUtils {
|
||||
public static final User USER = new User(1, "first", false, "last", "username", null);
|
||||
public static final User CREATOR = new User(1337, "creatorFirst", false, "creatorLast", "creatorUsername", null);
|
||||
public static final User USER = new User(1, "first", false, "last", "username", null, false, false, false);
|
||||
public static final User CREATOR = new User(1337, "creatorFirst", false, "creatorLast", "creatorUsername", null, false, false, false);
|
||||
|
||||
private TestUtils() {
|
||||
|
||||
|
@ -8,15 +8,6 @@ import org.telegram.telegrambots.meta.bots.AbsSender;
|
||||
|
||||
class CommandRegistryTest {
|
||||
|
||||
@Test
|
||||
void should_create_registry() {
|
||||
CommandRegistry registry = new CommandRegistry(true, () -> "BotUsername");
|
||||
Assertions.assertNotNull(registry, "CommandRegistry is not created");
|
||||
NullPointerException exception = Assertions.assertThrows(NullPointerException.class,
|
||||
() -> new CommandRegistry(true, () -> "BotUsername"));
|
||||
Assertions.assertEquals("Bot username must not be null", exception.getMessage(), "Invalid exception message");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_executes_commandWithBotUsername() {
|
||||
CommandRegistry registry = new CommandRegistry(true, () -> "BotUsername");
|
||||
|
@ -69,11 +69,11 @@
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<guice.version>4.2.2</guice.version>
|
||||
<guice.version>4.2.3</guice.version>
|
||||
<jackson.version>2.10.1</jackson.version>
|
||||
<jacksonanotation.version>2.10.1</jacksonanotation.version>
|
||||
<json.version>20180813</json.version>
|
||||
<guava.version>28.1-jre</guava.version>
|
||||
<guava.version>30.0-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -119,6 +119,7 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -3,7 +3,6 @@ package org.telegram.telegrambots.meta.api.methods;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -15,7 +14,6 @@ import java.io.Serializable;
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Data
|
||||
public abstract class BotApiMethod<T extends Serializable> extends PartialBotApiMethod<T> {
|
||||
protected static final String METHOD_FIELD = "method";
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
/**
|
||||
@ -9,6 +15,10 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* This object represents a Telegram chat with an user or a group
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Chat implements BotApiObject {
|
||||
|
||||
private static final String ID_FIELD = "id";
|
||||
@ -39,8 +49,10 @@ public class Chat implements BotApiObject {
|
||||
* so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
|
||||
*/
|
||||
@JsonProperty(ID_FIELD)
|
||||
@NonNull
|
||||
private Long id; ///< Unique identifier for this chat, not exceeding 1e13 by absolute value
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
@NonNull
|
||||
private String type; ///< Type of the chat, one of “private”, “group” or “channel”
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
private String title; ///< Optional. Title of the chat, only for channels and group chat
|
||||
@ -83,96 +95,23 @@ public class Chat implements BotApiObject {
|
||||
@JsonProperty(SLOWMODEDELAY_FIELD)
|
||||
private Integer slowModeDelay;
|
||||
|
||||
public Chat() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isGroupChat() {
|
||||
return GROUPCHATTYPE.equals(type);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isChannelChat() {
|
||||
return CHANNELCHATTYPE.equals(type);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isUserChat() {
|
||||
return USERCHATTYPE.equals(type);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isSuperGroupChat() {
|
||||
return SUPERGROUPCHATTYPE.equals(type);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public ChatPermissions getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public ChatPhoto getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getInviteLink() {
|
||||
return inviteLink;
|
||||
}
|
||||
|
||||
public Message getPinnedMessage() {
|
||||
return pinnedMessage;
|
||||
}
|
||||
|
||||
public String getStickerSetName() {
|
||||
return stickerSetName;
|
||||
}
|
||||
|
||||
public Boolean getCanSetStickerSet() {
|
||||
return canSetStickerSet;
|
||||
}
|
||||
|
||||
public Integer getSlowModeDelay() {
|
||||
return slowModeDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chat{" +
|
||||
"id=" + id +
|
||||
", type='" + type + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
", allMembersAreAdministrators=" + allMembersAreAdministrators +
|
||||
", photo=" + photo +
|
||||
", description='" + description + '\'' +
|
||||
", inviteLink='" + inviteLink + '\'' +
|
||||
", pinnedMessage=" + pinnedMessage +
|
||||
", stickerSetName='" + stickerSetName + '\'' +
|
||||
", canSetStickerSet=" + canSetStickerSet +
|
||||
", permissions=" + permissions +
|
||||
", slowModeDelay=" + slowModeDelay +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
/**
|
||||
@ -13,15 +13,17 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
* This object represents a point on the map.
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Location implements BotApiObject {
|
||||
|
||||
private static final String LONGITUDE_FIELD = "longitude";
|
||||
private static final String LATITUDE_FIELD = "latitude";
|
||||
|
||||
@JsonProperty(LONGITUDE_FIELD)
|
||||
@NonNull
|
||||
private Double longitude; ///< Longitude as defined by sender
|
||||
@JsonProperty(LATITUDE_FIELD)
|
||||
@NonNull
|
||||
private Double latitude; ///< Latitude as defined by sender
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.games.Animation;
|
||||
import org.telegram.telegrambots.meta.api.objects.games.Game;
|
||||
@ -19,6 +25,10 @@ import java.util.List;
|
||||
* @version 1.0
|
||||
* This object represents a message.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Message implements BotApiObject {
|
||||
private static final String MESSAGEID_FIELD = "message_id";
|
||||
private static final String FROM_FIELD = "from";
|
||||
@ -71,12 +81,15 @@ public class Message implements BotApiObject {
|
||||
private static final String VIABOT_FIELD = "via_bot";
|
||||
|
||||
@JsonProperty(MESSAGEID_FIELD)
|
||||
@NonNull
|
||||
private Integer messageId; ///< Integer Unique message identifier
|
||||
@JsonProperty(FROM_FIELD)
|
||||
private User from; ///< Optional. Sender, can be empty for messages sent to channels
|
||||
@JsonProperty(DATE_FIELD)
|
||||
private Integer date; ///< Optional. Date the message was sent in Unix time
|
||||
@NonNull
|
||||
private Integer date; ///< ODate the message was sent in Unix time
|
||||
@JsonProperty(CHAT_FIELD)
|
||||
@NonNull
|
||||
private Chat chat; ///< Conversation the message belongs to
|
||||
@JsonProperty(FORWARDFROM_FIELD)
|
||||
private User forwardFrom; ///< Optional. For forwarded messages, sender of the original message
|
||||
@ -213,37 +226,6 @@ public class Message implements BotApiObject {
|
||||
private Dice dice; // Optional. Message is a dice with random value from 1 to 6
|
||||
@JsonProperty(VIABOT_FIELD)
|
||||
private User viaBot; // Optional. Bot through which the message was sent
|
||||
public Message() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public User getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public Integer getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Chat getChat() {
|
||||
return chat;
|
||||
}
|
||||
|
||||
public User getForwardFrom() {
|
||||
return forwardFrom;
|
||||
}
|
||||
|
||||
public Integer getForwardDate() {
|
||||
return forwardDate;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public List<MessageEntity> getEntities() {
|
||||
if (entities != null) {
|
||||
@ -259,130 +241,47 @@ public class Message implements BotApiObject {
|
||||
return captionEntities;
|
||||
}
|
||||
|
||||
public Audio getAudio() {
|
||||
return audio;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public List<PhotoSize> getPhoto() {
|
||||
return photo;
|
||||
}
|
||||
|
||||
public Sticker getSticker() {
|
||||
return sticker;
|
||||
}
|
||||
|
||||
public boolean hasSticker() {
|
||||
return sticker != null;
|
||||
}
|
||||
|
||||
public Video getVideo() {
|
||||
return video;
|
||||
}
|
||||
|
||||
public Animation getAnimation() {
|
||||
return animation;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Venue getVenue() {
|
||||
return venue;
|
||||
}
|
||||
|
||||
public Message getPinnedMessage() {
|
||||
return pinnedMessage;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<User> getNewChatMembers() {
|
||||
return newChatMembers == null ? new ArrayList<>() : newChatMembers;
|
||||
}
|
||||
|
||||
public User getLeftChatMember() {
|
||||
return leftChatMember;
|
||||
}
|
||||
|
||||
public String getNewChatTitle() {
|
||||
return newChatTitle;
|
||||
}
|
||||
|
||||
public List<PhotoSize> getNewChatPhoto() {
|
||||
return newChatPhoto;
|
||||
}
|
||||
|
||||
public Boolean getDeleteChatPhoto() {
|
||||
return deleteChatPhoto;
|
||||
}
|
||||
|
||||
public Boolean getGroupchatCreated() {
|
||||
return groupchatCreated;
|
||||
}
|
||||
|
||||
public Message getReplyToMessage() {
|
||||
return replyToMessage;
|
||||
}
|
||||
|
||||
public Voice getVoice() {
|
||||
return voice;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public Boolean getSuperGroupCreated() {
|
||||
return superGroupCreated;
|
||||
}
|
||||
|
||||
public Boolean getChannelChatCreated() {
|
||||
return channelChatCreated;
|
||||
}
|
||||
|
||||
public Long getMigrateToChatId() {
|
||||
return migrateToChatId;
|
||||
}
|
||||
|
||||
public Long getMigrateFromChatId() {
|
||||
return migrateFromChatId;
|
||||
}
|
||||
|
||||
public Integer getForwardFromMessageId() {
|
||||
return forwardFromMessageId;
|
||||
@JsonIgnore
|
||||
public boolean hasSticker() {
|
||||
return sticker != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isGroupMessage() {
|
||||
return chat.isGroupChat();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isUserMessage() {
|
||||
return chat.isUserChat();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isChannelMessage() {
|
||||
return chat.isChannelChat();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isSuperGroupMessage() {
|
||||
return chat.isSuperGroupChat();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Long getChatId() {
|
||||
return chat.getId();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasText() {
|
||||
return text != null && !text.isEmpty();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isCommand() {
|
||||
if (hasText() && entities != null) {
|
||||
for (MessageEntity entity : entities) {
|
||||
@ -395,202 +294,98 @@ public class Message implements BotApiObject {
|
||||
return false;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasDocument() {
|
||||
return this.document != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasVideo() {
|
||||
return this.video != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasAudio(){
|
||||
return this.audio != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasVoice(){
|
||||
return this.voice != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isReply() {
|
||||
return this.replyToMessage != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasLocation() {
|
||||
return location != null;
|
||||
}
|
||||
|
||||
public Chat getForwardFromChat() {
|
||||
return forwardFromChat;
|
||||
}
|
||||
|
||||
public Integer getEditDate() {
|
||||
return editDate;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private boolean hasGame() {
|
||||
return game != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasEntities() {
|
||||
return entities != null && !entities.isEmpty();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasPhoto() {
|
||||
return photo != null && !photo.isEmpty();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasInvoice() {
|
||||
return invoice != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasSuccessfulPayment() {
|
||||
return successfulPayment != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasContact() {
|
||||
return contact != null;
|
||||
}
|
||||
|
||||
public Invoice getInvoice() {
|
||||
return invoice;
|
||||
}
|
||||
|
||||
public SuccessfulPayment getSuccessfulPayment() {
|
||||
return successfulPayment;
|
||||
}
|
||||
|
||||
public VideoNote getVideoNote() {
|
||||
return videoNote;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasVideoNote() {
|
||||
return videoNote != null;
|
||||
}
|
||||
|
||||
public String getAuthorSignature() {
|
||||
return authorSignature;
|
||||
}
|
||||
|
||||
public String getForwardSignature() {
|
||||
return forwardSignature;
|
||||
}
|
||||
|
||||
public String getMediaGroupId() {
|
||||
return mediaGroupId;
|
||||
}
|
||||
|
||||
public String getConnectedWebsite() {
|
||||
return connectedWebsite;
|
||||
}
|
||||
|
||||
public PassportData getPassportData() {
|
||||
return passportData;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasPassportData() {
|
||||
return passportData != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasAnimation() {
|
||||
return animation != null;
|
||||
}
|
||||
|
||||
public String getForwardSenderName() {
|
||||
return forwardSenderName;
|
||||
}
|
||||
|
||||
public void setForwardSenderName(String forwardSenderName) {
|
||||
this.forwardSenderName = forwardSenderName;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasPoll() {
|
||||
return poll != null;
|
||||
}
|
||||
|
||||
public Poll getPoll() {
|
||||
return poll;
|
||||
}
|
||||
|
||||
public Dice getDice() {
|
||||
return dice;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasDice() {
|
||||
return dice != null;
|
||||
}
|
||||
|
||||
public User getViaBot() {
|
||||
return viaBot;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasViaBot() {
|
||||
return viaBot != null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean hasReplyMarkup() {
|
||||
return replyMarkup != null;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message{" +
|
||||
"messageId=" + messageId +
|
||||
", from=" + from +
|
||||
", date=" + date +
|
||||
", chat=" + chat +
|
||||
", forwardFrom=" + forwardFrom +
|
||||
", forwardFromChat=" + forwardFromChat +
|
||||
", forwardDate=" + forwardDate +
|
||||
", text='" + text + '\'' +
|
||||
", entities=" + entities +
|
||||
", captionEntities=" + captionEntities +
|
||||
", audio=" + audio +
|
||||
", document=" + document +
|
||||
", photo=" + photo +
|
||||
", sticker=" + sticker +
|
||||
", video=" + video +
|
||||
", contact=" + contact +
|
||||
", location=" + location +
|
||||
", venue=" + venue +
|
||||
", animation=" + animation +
|
||||
", pinnedMessage=" + pinnedMessage +
|
||||
", newChatMembers=" + newChatMembers +
|
||||
", leftChatMember=" + leftChatMember +
|
||||
", newChatTitle='" + newChatTitle + '\'' +
|
||||
", newChatPhoto=" + newChatPhoto +
|
||||
", deleteChatPhoto=" + deleteChatPhoto +
|
||||
", groupchatCreated=" + groupchatCreated +
|
||||
", replyToMessage=" + replyToMessage +
|
||||
", voice=" + voice +
|
||||
", caption='" + caption + '\'' +
|
||||
", superGroupCreated=" + superGroupCreated +
|
||||
", channelChatCreated=" + channelChatCreated +
|
||||
", migrateToChatId=" + migrateToChatId +
|
||||
", migrateFromChatId=" + migrateFromChatId +
|
||||
", editDate=" + editDate +
|
||||
", game=" + game +
|
||||
", forwardFromMessageId=" + forwardFromMessageId +
|
||||
", invoice=" + invoice +
|
||||
", successfulPayment=" + successfulPayment +
|
||||
", videoNote=" + videoNote +
|
||||
", authorSignature='" + authorSignature + '\'' +
|
||||
", forwardSignature='" + forwardSignature + '\'' +
|
||||
", mediaGroupId='" + mediaGroupId + '\'' +
|
||||
", connectedWebsite='" + connectedWebsite + '\'' +
|
||||
", passportData=" + passportData +
|
||||
", forwardSenderName='" + forwardSenderName + '\'' +
|
||||
", poll=" + poll +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", dice=" + dice +
|
||||
", viaBot=" + viaBot +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,22 @@
|
||||
package org.telegram.telegrambots.meta.api.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.0
|
||||
* This object represents a Telegram user or bot.
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class User implements BotApiObject {
|
||||
|
||||
private static final String ID_FIELD = "id";
|
||||
@ -23,10 +30,13 @@ public class User implements BotApiObject {
|
||||
private static final String SUPPORTINLINEQUERIES_FIELD = "supports_inline_queries";
|
||||
|
||||
@JsonProperty(ID_FIELD)
|
||||
@NonNull
|
||||
private Integer id; ///< Unique identifier for this user or bot
|
||||
@JsonProperty(FIRSTNAME_FIELD)
|
||||
@NonNull
|
||||
private String firstName; ///< User‘s or bot’s first name
|
||||
@JsonProperty(ISBOT_FIELD)
|
||||
@NonNull
|
||||
private Boolean isBot; ///< True, if this user is a bot
|
||||
@JsonProperty(LASTNAME_FIELD)
|
||||
private String lastName; ///< Optional. User‘s or bot’s last name
|
||||
@ -40,90 +50,4 @@ public class User implements BotApiObject {
|
||||
private Boolean canReadAllGroupMessages; ///< Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
|
||||
@JsonProperty(SUPPORTINLINEQUERIES_FIELD)
|
||||
private Boolean supportInlineQueries; ///< Optional. True, if the bot supports inline queries. Returned only in getMe.
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(Integer id, String firstName, Boolean isBot, String lastName, String userName, String languageCode) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
this.isBot = isBot;
|
||||
this.lastName = lastName;
|
||||
this.userName = userName;
|
||||
this.languageCode = languageCode;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getLanguageCode() {
|
||||
return languageCode;
|
||||
}
|
||||
|
||||
public Boolean getBot() {
|
||||
return isBot;
|
||||
}
|
||||
|
||||
public Boolean getCanJoinGroups() {
|
||||
return canJoinGroups;
|
||||
}
|
||||
|
||||
public Boolean getCanReadAllGroupMessages() {
|
||||
return canReadAllGroupMessages;
|
||||
}
|
||||
|
||||
public Boolean getSupportInlineQueries() {
|
||||
return supportInlineQueries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(isBot, user.isBot) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(userName, user.userName) &&
|
||||
Objects.equals(languageCode, user.languageCode) &&
|
||||
Objects.equals(canJoinGroups, user.canJoinGroups) &&
|
||||
Objects.equals(canReadAllGroupMessages, user.canReadAllGroupMessages) &&
|
||||
Objects.equals(supportInlineQueries, user.supportInlineQueries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, firstName, isBot, lastName, userName, languageCode,
|
||||
canJoinGroups, canReadAllGroupMessages, supportInlineQueries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", isBot=" + isBot +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
", languageCode='" + languageCode + '\'' +
|
||||
", canJoinGroups=" + canJoinGroups +
|
||||
", canReadAllGroupMessages=" + canReadAllGroupMessages +
|
||||
", supportInlineQueries=" + supportInlineQueries +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,11 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.games;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.PhotoSize;
|
||||
|
||||
@ -28,7 +31,9 @@ import org.telegram.telegrambots.meta.api.objects.PhotoSize;
|
||||
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Animation implements BotApiObject {
|
||||
private static final String FILEID_FIELD = "file_id";
|
||||
private static final String FILEUNIQUEID_FIELD = "file_unique_id";
|
||||
@ -41,18 +46,23 @@ public class Animation implements BotApiObject {
|
||||
private static final String FILESIZE_FIELD = "file_size";
|
||||
|
||||
@JsonProperty(FILEID_FIELD)
|
||||
@NonNull
|
||||
private String fileId; ///< Identifier for this file, which can be used to download or reuse the file
|
||||
/**
|
||||
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
|
||||
* Can't be used to download or reuse the file.
|
||||
*/
|
||||
@JsonProperty(FILEUNIQUEID_FIELD)
|
||||
@NonNull
|
||||
private String fileUniqueId;
|
||||
@JsonProperty(WIDTH_FIELD)
|
||||
@NonNull
|
||||
private Integer width; ///< Video width as defined by sender
|
||||
@JsonProperty(HEIGHT_FIELD)
|
||||
@NonNull
|
||||
private Integer height; ///< Video height as defined by sender
|
||||
@JsonProperty(DURATION_FIELD)
|
||||
@NonNull
|
||||
private Integer duration; ///< Duration of the video in seconds as defined by sender
|
||||
@JsonProperty(THUMB_FIELD)
|
||||
private PhotoSize thumb; ///< Optional. Animation thumbnail as defined by sender
|
||||
|
@ -17,8 +17,11 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.games;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
import org.telegram.telegrambots.meta.api.objects.PhotoSize;
|
||||
@ -32,7 +35,9 @@ import java.util.List;
|
||||
* @apiNote Use BotFather to create and edit games, their short names will act as unique identifiers.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Game implements BotApiObject {
|
||||
|
||||
private static final String TITLE_FIELD = "title";
|
||||
@ -43,10 +48,13 @@ public class Game implements BotApiObject {
|
||||
private static final String TEXTENTITIES_FIELD = "text_entities";
|
||||
|
||||
@JsonProperty(TITLE_FIELD)
|
||||
@NonNull
|
||||
private String title; ///< Title of the game
|
||||
@JsonProperty(DESCRIPTION_FIELD)
|
||||
@NonNull
|
||||
private String description; ///< Description of the game
|
||||
@JsonProperty(PHOTO_FIELD)
|
||||
@NonNull
|
||||
private List<PhotoSize> photo; ///< Photo
|
||||
/**
|
||||
* Optional. Brief description of the game or high scores included in the game message.
|
||||
|
@ -18,8 +18,10 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.games;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
|
||||
@ -30,15 +32,19 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GameHighScore implements BotApiObject {
|
||||
private static final String POSITION_FIELD = "position";
|
||||
private static final String USER_FIELD = "user";
|
||||
private static final String SCORE_FIELD = "score";
|
||||
|
||||
@JsonProperty(POSITION_FIELD)
|
||||
@NonNull
|
||||
private Integer position; ///< Position in the game high score table
|
||||
@JsonProperty(USER_FIELD)
|
||||
@NonNull
|
||||
private User user; ///< User
|
||||
@JsonProperty(SCORE_FIELD)
|
||||
@NonNull
|
||||
private Integer score; ///< Score
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.Location;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
@ -16,7 +19,9 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
||||
* partner.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ChosenInlineQuery implements BotApiObject {
|
||||
private static final String RESULTID_FIELD = "result_id";
|
||||
@ -26,8 +31,10 @@ public class ChosenInlineQuery implements BotApiObject {
|
||||
private static final String QUERY_FIELD = "query";
|
||||
|
||||
@JsonProperty(RESULTID_FIELD)
|
||||
@NonNull
|
||||
private String resultId; ///< The unique identifier for the result that was chosen.
|
||||
@JsonProperty(FROM_FIELD)
|
||||
@NonNull
|
||||
private User from; ///< The user that chose the result.
|
||||
@JsonProperty(LOCATION_FIELD)
|
||||
private Location location; ///< Optional. Sender location, only for bots that require user location
|
||||
@ -40,5 +47,6 @@ public class ChosenInlineQuery implements BotApiObject {
|
||||
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
|
||||
private String inlineMessageId;
|
||||
@JsonProperty(QUERY_FIELD)
|
||||
@NonNull
|
||||
private String query; ///< The query that was used to obtain the result.
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||
import org.telegram.telegrambots.meta.api.objects.Location;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
@ -16,7 +19,9 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
||||
* bot could return some default or trending results.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class InlineQuery implements BotApiObject {
|
||||
private static final String ID_FIELD = "id";
|
||||
@ -26,14 +31,18 @@ public class InlineQuery implements BotApiObject {
|
||||
private static final String OFFSET_FIELD = "offset";
|
||||
|
||||
@JsonProperty(ID_FIELD)
|
||||
@NonNull
|
||||
private String id; ///< Unique identifier for this query
|
||||
@JsonProperty(FROM_FIELD)
|
||||
@NonNull
|
||||
private User from; ///< Sender
|
||||
@JsonProperty(LOCATION_FIELD)
|
||||
private Location location; ///< Optional. Sender location, only for bots that request user location
|
||||
@JsonProperty(QUERY_FIELD)
|
||||
@NonNull
|
||||
private String query; ///< Text of the query
|
||||
@JsonProperty(OFFSET_FIELD)
|
||||
@NonNull
|
||||
private String offset; ///< Offset of the results to be returned, can be controlled by the bot
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
/**
|
||||
@ -18,6 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
@ -7,6 +7,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
/**
|
||||
@ -18,6 +19,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
@ -7,6 +7,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
/**
|
||||
@ -16,6 +17,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
@ -8,6 +8,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,7 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
@ -3,6 +3,12 @@ package org.telegram.telegrambots.meta.api.objects.inlinequery.result;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
@ -15,6 +21,11 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
||||
* specified content instead of the photo.
|
||||
*/
|
||||
@JsonDeserialize
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
private static final String TYPE_FIELD = "type";
|
||||
private static final String ID_FIELD = "id";
|
||||
@ -33,8 +44,10 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
@JsonProperty(TYPE_FIELD)
|
||||
private final String type = "photo"; ///< Type of the result, must be “photo”
|
||||
@JsonProperty(ID_FIELD)
|
||||
@NonNull
|
||||
private String id; ///< Unique identifier of this result, 1-64 bytes
|
||||
@JsonProperty(PHOTOURL_FIELD)
|
||||
@NonNull
|
||||
private String photoUrl; ///< A valid URL of the photo. Photo size must not exceed 5MB
|
||||
@JsonProperty(MIMETYPE_FIELD)
|
||||
private String mimeType; ///< Optional. MIME type of the photo, defaults to image/jpeg
|
||||
@ -57,122 +70,6 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
@JsonProperty(PARSEMODE_FIELD)
|
||||
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
|
||||
|
||||
public InlineQueryResultPhoto() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhotoUrl() {
|
||||
return photoUrl;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setPhotoUrl(String photoUrl) {
|
||||
this.photoUrl = photoUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPhotoWidth() {
|
||||
return photoWidth;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setPhotoWidth(Integer photoWidth) {
|
||||
this.photoWidth = photoWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPhotoHeight() {
|
||||
return photoHeight;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setPhotoHeight(Integer photoHeight) {
|
||||
this.photoHeight = photoHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getThumbUrl() {
|
||||
return thumbUrl;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setThumbUrl(String thumbUrl) {
|
||||
this.thumbUrl = thumbUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputMessageContent getInputMessageContent() {
|
||||
return inputMessageContent;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setInputMessageContent(InputMessageContent inputMessageContent) {
|
||||
this.inputMessageContent = inputMessageContent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InlineKeyboardMarkup getReplyMarkup() {
|
||||
return replyMarkup;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
|
||||
this.replyMarkup = replyMarkup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public InlineQueryResultPhoto setParseMode(String parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws TelegramApiValidationException {
|
||||
if (id == null || id.isEmpty()) {
|
||||
@ -188,23 +85,4 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||
replyMarkup.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InlineQueryResultPhoto{" +
|
||||
"type='" + type + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", photoUrl='" + photoUrl + '\'' +
|
||||
", mimeType='" + mimeType + '\'' +
|
||||
", photoWidth=" + photoWidth +
|
||||
", photoHeight=" + photoHeight +
|
||||
", thumbUrl='" + thumbUrl + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", caption='" + caption + '\'' +
|
||||
", inputMessageContent=" + inputMessageContent +
|
||||
", replyMarkup=" + replyMarkup +
|
||||
", parseMode='" + parseMode + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.telegram.telegrambots.meta.test;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
|
||||
@ -183,8 +182,8 @@ class TestDeserialization {
|
||||
assertEquals("offset", inlineQuery.getOffset());
|
||||
assertFromUser(inlineQuery.getFrom());
|
||||
assertNotNull(inlineQuery.getLocation());
|
||||
assertEquals(Float.valueOf("0.234242534"), inlineQuery.getLocation().getLatitude());
|
||||
assertEquals(Float.valueOf("0.234242534"), inlineQuery.getLocation().getLongitude());
|
||||
assertEquals(0.234242534, inlineQuery.getLocation().getLatitude());
|
||||
assertEquals(0.234242534, inlineQuery.getLocation().getLongitude());
|
||||
}
|
||||
|
||||
private void assertCallbackQuery(CallbackQuery callbackQuery) {
|
||||
|
@ -18,11 +18,25 @@ import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMem
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.KickChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.LeaveChat;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.UnbanChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.*;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendChatAction;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendContact;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendGame;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendInvoice;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendLocation;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendVenue;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.GetWebhookInfo;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageCaption;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageReplyMarkup;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageText;
|
||||
import org.telegram.telegrambots.meta.api.objects.Chat;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import org.telegram.telegrambots.meta.api.objects.UserProfilePhotos;
|
||||
import org.telegram.telegrambots.meta.api.objects.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent;
|
||||
import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
|
||||
@ -37,6 +51,7 @@ import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKe
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardButton;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardRow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -48,7 +63,7 @@ public final class BotApiMethodHelperFactory {
|
||||
private BotApiMethodHelperFactory() {
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendMessage() {
|
||||
public static BotApiMethod<Message> getSendMessage() {
|
||||
return new SendMessage()
|
||||
.setChatId("@test")
|
||||
.setText("Hithere")
|
||||
@ -57,14 +72,14 @@ public final class BotApiMethodHelperFactory {
|
||||
.setReplyMarkup(new ForceReplyKeyboard());
|
||||
}
|
||||
|
||||
public static BotApiMethod getAnswerCallbackQuery() {
|
||||
public static BotApiMethod<Boolean> getAnswerCallbackQuery() {
|
||||
return new AnswerCallbackQuery()
|
||||
.setCallbackQueryId("id")
|
||||
.setText("text")
|
||||
.setShowAlert(true);
|
||||
}
|
||||
|
||||
public static BotApiMethod getAnswerInlineQuery() {
|
||||
public static BotApiMethod<Boolean> getAnswerInlineQuery() {
|
||||
return new AnswerInlineQuery()
|
||||
.setInlineQueryId("id")
|
||||
.setPersonal(true)
|
||||
@ -75,7 +90,7 @@ public final class BotApiMethodHelperFactory {
|
||||
.setSwitchPmText("pmText");
|
||||
}
|
||||
|
||||
public static BotApiMethod getEditMessageCaption() {
|
||||
public static BotApiMethod<Serializable> getEditMessageCaption() {
|
||||
return new EditMessageCaption()
|
||||
.setChatId("ChatId")
|
||||
.setMessageId(1)
|
||||
@ -84,7 +99,7 @@ public final class BotApiMethodHelperFactory {
|
||||
}
|
||||
|
||||
|
||||
public static BotApiMethod getEditMessageText() {
|
||||
public static BotApiMethod<Serializable> getEditMessageText() {
|
||||
return new EditMessageText()
|
||||
.setChatId("ChatId")
|
||||
.setMessageId(1)
|
||||
@ -93,13 +108,13 @@ public final class BotApiMethodHelperFactory {
|
||||
.setReplyMarkup(getInlineKeyboardMarkup());
|
||||
}
|
||||
|
||||
public static BotApiMethod getEditMessageReplyMarkup() {
|
||||
public static BotApiMethod<Serializable> getEditMessageReplyMarkup() {
|
||||
return new EditMessageReplyMarkup()
|
||||
.setInlineMessageId("12345")
|
||||
.setReplyMarkup(getInlineKeyboardMarkup());
|
||||
}
|
||||
|
||||
public static BotApiMethod getForwardMessage() {
|
||||
public static BotApiMethod<Message> getForwardMessage() {
|
||||
return new ForwardMessage(54L, 123L, 55)
|
||||
.setFromChatId("From")
|
||||
.setChatId("To")
|
||||
@ -107,72 +122,72 @@ public final class BotApiMethodHelperFactory {
|
||||
.disableNotification();
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetChat() {
|
||||
public static BotApiMethod<Chat> getGetChat() {
|
||||
return new GetChat()
|
||||
.setChatId("12345");
|
||||
}
|
||||
|
||||
public static BotApiMethod getChatAdministrators() {
|
||||
public static BotApiMethod<ArrayList<ChatMember>> getChatAdministrators() {
|
||||
return new GetChatAdministrators()
|
||||
.setChatId("12345");
|
||||
}
|
||||
|
||||
public static BotApiMethod getChatMember() {
|
||||
public static BotApiMethod<ChatMember> getChatMember() {
|
||||
return new GetChatMember()
|
||||
.setChatId("12345")
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getChatMembersCount() {
|
||||
public static BotApiMethod<Integer> getChatMembersCount() {
|
||||
return new GetChatMembersCount()
|
||||
.setChatId("12345");
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetFile() {
|
||||
public static BotApiMethod<File> getGetFile() {
|
||||
return new GetFile()
|
||||
.setFileId("FileId");
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetGameHighScores() {
|
||||
public static BotApiMethod<ArrayList<GameHighScore>> getGetGameHighScores() {
|
||||
return new GetGameHighScores()
|
||||
.setChatId("12345")
|
||||
.setMessageId(67890)
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetMe() {
|
||||
public static BotApiMethod<User> getGetMe() {
|
||||
return new GetMe();
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetUserProfilePhotos() {
|
||||
public static BotApiMethod<UserProfilePhotos> getGetUserProfilePhotos() {
|
||||
return new GetUserProfilePhotos()
|
||||
.setUserId(98765)
|
||||
.setLimit(10)
|
||||
.setOffset(3);
|
||||
}
|
||||
|
||||
public static BotApiMethod getGetWebhookInfo() {
|
||||
public static BotApiMethod<WebhookInfo> getGetWebhookInfo() {
|
||||
return new GetWebhookInfo();
|
||||
}
|
||||
|
||||
public static BotApiMethod getKickChatMember() {
|
||||
public static BotApiMethod<Boolean> getKickChatMember() {
|
||||
return new KickChatMember()
|
||||
.setChatId("12345")
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getLeaveChat() {
|
||||
public static BotApiMethod<Boolean> getLeaveChat() {
|
||||
return new LeaveChat()
|
||||
.setChatId("12345");
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendChatAction() {
|
||||
public static BotApiMethod<Boolean> getSendChatAction() {
|
||||
return new SendChatAction()
|
||||
.setChatId("12345")
|
||||
.setAction(ActionType.RECORDVIDEO);
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendContact() {
|
||||
public static BotApiMethod<Message> getSendContact() {
|
||||
return new SendContact()
|
||||
.setChatId("12345")
|
||||
.setFirstName("First Name")
|
||||
@ -213,24 +228,28 @@ public final class BotApiMethodHelperFactory {
|
||||
}
|
||||
|
||||
private static InlineQueryResult getInlineQueryResultPhoto() {
|
||||
return new InlineQueryResultPhoto()
|
||||
.setId("1")
|
||||
.setPhotoUrl("PhotoUrl")
|
||||
.setPhotoWidth(10)
|
||||
.setPhotoHeight(20)
|
||||
.setMimeType("image/jpg")
|
||||
.setThumbUrl("ThumbUrl")
|
||||
.setTitle("Title")
|
||||
.setDescription("Description")
|
||||
.setCaption("Caption")
|
||||
.setInputMessageContent(getInputMessageContent())
|
||||
.setReplyMarkup(getInlineKeyboardMarkup());
|
||||
return InlineQueryResultPhoto
|
||||
.builder()
|
||||
.id("1")
|
||||
.photoUrl("PhotoUrl")
|
||||
.photoWidth(10)
|
||||
.photoHeight(20)
|
||||
.mimeType("image/jpg")
|
||||
.thumbUrl("ThumbUrl")
|
||||
.title("Title")
|
||||
.description("Description")
|
||||
.caption("Caption")
|
||||
.inputMessageContent(getInputMessageContent())
|
||||
.replyMarkup(getInlineKeyboardMarkup())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static InputMessageContent getInputMessageContent() {
|
||||
return new InputTextMessageContent()
|
||||
.setMessageText("Text")
|
||||
.setParseMode(ParseMode.MARKDOWN);
|
||||
return InputTextMessageContent
|
||||
.builder()
|
||||
.messageText("Text")
|
||||
.parseMode(ParseMode.MARKDOWN)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static InlineKeyboardMarkup getInlineKeyboardMarkup() {
|
||||
@ -245,13 +264,13 @@ public final class BotApiMethodHelperFactory {
|
||||
.setKeyboard(keyboard);
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendGame() {
|
||||
public static BotApiMethod<Message> getSendGame() {
|
||||
return new SendGame()
|
||||
.setChatId("12345")
|
||||
.setGameShortName("MyGame");
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendLocation() {
|
||||
public static BotApiMethod<Message> getSendLocation() {
|
||||
return new SendLocation()
|
||||
.setChatId("12345")
|
||||
.setLatitude(12.5F)
|
||||
@ -259,7 +278,7 @@ public final class BotApiMethodHelperFactory {
|
||||
.setReplyToMessageId(53);
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendVenue() {
|
||||
public static BotApiMethod<Message> getSendVenue() {
|
||||
return new SendVenue()
|
||||
.setChatId("12345")
|
||||
.setLatitude(12.5F)
|
||||
@ -270,7 +289,7 @@ public final class BotApiMethodHelperFactory {
|
||||
.setFoursquareId("FourId");
|
||||
}
|
||||
|
||||
public static BotApiMethod getSetGameScore() {
|
||||
public static BotApiMethod<Serializable> getSetGameScore() {
|
||||
return new SetGameScore()
|
||||
.setInlineMessageId("12345")
|
||||
.setDisableEditMessage(true)
|
||||
@ -278,13 +297,13 @@ public final class BotApiMethodHelperFactory {
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getUnbanChatMember() {
|
||||
public static BotApiMethod<Boolean> getUnbanChatMember() {
|
||||
return new UnbanChatMember()
|
||||
.setChatId("12345")
|
||||
.setUserId(98765);
|
||||
}
|
||||
|
||||
public static BotApiMethod getSendInvoice() {
|
||||
public static BotApiMethod<Message> getSendInvoice() {
|
||||
List<LabeledPrice> prices = new ArrayList<>();
|
||||
prices.add(new LabeledPrice("LABEL", 1000));
|
||||
|
||||
|
@ -7,16 +7,42 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.telegram.telegrambots.meta.api.methods.*;
|
||||
import org.telegram.telegrambots.meta.api.methods.AnswerCallbackQuery;
|
||||
import org.telegram.telegrambots.meta.api.methods.AnswerInlineQuery;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.methods.ForwardMessage;
|
||||
import org.telegram.telegrambots.meta.api.methods.GetFile;
|
||||
import org.telegram.telegrambots.meta.api.methods.GetMe;
|
||||
import org.telegram.telegrambots.meta.api.methods.GetUserProfilePhotos;
|
||||
import org.telegram.telegrambots.meta.api.methods.games.GetGameHighScores;
|
||||
import org.telegram.telegrambots.meta.api.methods.games.SetGameScore;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.*;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.*;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChat;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatAdministrators;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatMembersCount;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.KickChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.LeaveChat;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.UnbanChatMember;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendChatAction;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendContact;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendGame;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendInvoice;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendLocation;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendVenue;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.GetWebhookInfo;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageCaption;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageReplyMarkup;
|
||||
import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageText;
|
||||
import org.telegram.telegrambots.meta.api.objects.Chat;
|
||||
import org.telegram.telegrambots.meta.api.objects.ChatMember;
|
||||
import org.telegram.telegrambots.meta.api.objects.File;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import org.telegram.telegrambots.meta.api.objects.UserProfilePhotos;
|
||||
import org.telegram.telegrambots.meta.api.objects.WebhookInfo;
|
||||
import org.telegram.telegrambots.meta.api.objects.games.GameHighScore;
|
||||
import org.telegram.telegrambots.test.Fakes.FakeWebhook;
|
||||
import org.telegram.telegrambots.updatesreceivers.RestApi;
|
||||
|
||||
@ -24,6 +50,8 @@ import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
@ -55,7 +83,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendMessage());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendMessage.class);
|
||||
@ -67,7 +95,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerCallbackQuery());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, AnswerCallbackQuery.class);
|
||||
@ -80,7 +108,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getAnswerInlineQuery());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, AnswerInlineQuery.class);
|
||||
@ -93,7 +121,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageCaption());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Serializable> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, EditMessageCaption.class);
|
||||
@ -109,7 +137,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageReplyMarkup());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Serializable> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, EditMessageReplyMarkup.class);
|
||||
@ -125,7 +153,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getEditMessageText());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Serializable> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, EditMessageText.class);
|
||||
@ -141,7 +169,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getForwardMessage());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, ForwardMessage.class);
|
||||
@ -155,7 +183,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetChat());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Chat> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetChat.class);
|
||||
@ -168,7 +196,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatAdministrators());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<ArrayList<ChatMember>> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetChatAdministrators.class);
|
||||
@ -181,7 +209,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMember());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<ChatMember> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetChatMember.class);
|
||||
@ -194,7 +222,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getChatMembersCount());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Integer> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetChatMembersCount.class);
|
||||
@ -207,7 +235,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetFile());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<File> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetFile.class);
|
||||
@ -220,7 +248,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetGameHighScores());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<ArrayList<GameHighScore>> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetGameHighScores.class);
|
||||
@ -233,7 +261,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetMe());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<User> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetMe.class);
|
||||
@ -246,7 +274,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetUserProfilePhotos());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<UserProfilePhotos> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetUserProfilePhotos.class);
|
||||
@ -259,7 +287,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getGetWebhookInfo());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<WebhookInfo> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, GetWebhookInfo.class);
|
||||
@ -272,7 +300,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getKickChatMember());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, KickChatMember.class);
|
||||
@ -285,7 +313,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getLeaveChat());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, LeaveChat.class);
|
||||
@ -298,7 +326,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendChatAction());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendChatAction.class);
|
||||
@ -311,7 +339,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendContact());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendContact.class);
|
||||
@ -324,7 +352,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendGame());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendGame.class);
|
||||
@ -337,7 +365,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendLocation());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendLocation.class);
|
||||
@ -350,7 +378,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendVenue());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendVenue.class);
|
||||
@ -363,7 +391,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSetGameScore());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Serializable> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SetGameScore.class);
|
||||
@ -376,7 +404,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getUnbanChatMember());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Boolean> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, UnbanChatMember.class);
|
||||
@ -389,7 +417,7 @@ public class TestRestApi extends JerseyTest {
|
||||
webhookBot.setReturnValue(BotApiMethodHelperFactory.getSendInvoice());
|
||||
|
||||
Entity<Update> entity = Entity.json(getUpdate());
|
||||
BotApiMethod result =
|
||||
BotApiMethod<Message> result =
|
||||
target("callback/testbot")
|
||||
.request(MediaType.APPLICATION_JSON)
|
||||
.post(entity, SendInvoice.class);
|
||||
@ -409,7 +437,7 @@ public class TestRestApi extends JerseyTest {
|
||||
}
|
||||
}
|
||||
|
||||
private String map(BotApiMethod method) {
|
||||
private <T extends Serializable> String map(BotApiMethod<T> method) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
return mapper.writeValueAsString(method);
|
||||
|
Loading…
Reference in New Issue
Block a user