diff --git a/README.md b/README.md
index 22226771..0d750390 100644
--- a/README.md
+++ b/README.md
@@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
org.telegram
telegrambots
- 5.7.1
+ 6.0.1
```
2. Using Gradle:
```gradle
- implementation 'org.telegram:telegrambots:5.7.1'
+ implementation 'org.telegram:telegrambots:6.0.1'
```
- 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.7.1)
- 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.7.1)
+ 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.0.1)
+ 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.0.1)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
diff --git a/TelegramBots.wiki/Changelog.md b/TelegramBots.wiki/Changelog.md
index b59c0eca..f144c960 100644
--- a/TelegramBots.wiki/Changelog.md
+++ b/TelegramBots.wiki/Changelog.md
@@ -1,3 +1,7 @@
+### 6.0.1 ###
+1. Update Api version [6.0](https://core.telegram.org/bots/api-changelog#april-16-2022)
+2. Removed all deprecated methods/classes with this major upgrade
+
### 5.7.1 ###
1. Update Api version [5.7](https://core.telegram.org/bots/api-changelog#january-31-2022)
2. Spring boot 2.5.8
diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md
index 609dc1f5..5054813d 100644
--- a/TelegramBots.wiki/Getting-Started.md
+++ b/TelegramBots.wiki/Getting-Started.md
@@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
org.telegram
telegrambots
- 5.7.1
+ 6.0.1
```
* With **Gradle**:
```gradle
- implementation 'org.telegram:telegrambots:5.7.1'
+ implementation 'org.telegram:telegrambots:6.0.1'
```
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md
index 10107cd7..91327aa1 100644
--- a/TelegramBots.wiki/abilities/Simple-Example.md
+++ b/TelegramBots.wiki/abilities/Simple-Example.md
@@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
org.telegram
telegrambots-abilities
- 5.7.1
+ 6.0.1
```
* **Gradle**
```gradle
- implementation 'org.telegram:telegrambots-abilities:5.7.1'
+ implementation 'org.telegram:telegrambots-abilities:6.0.1'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
diff --git a/pom.xml b/pom.xml
index 741d6beb..1859e1d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
pom
- 5.7.1
+ 6.0.1
telegrambots
@@ -73,7 +73,7 @@
4.3.1
4.3.1
2.13.2
- 2.13.2
+ 2.13.2.1
20180813
1.7.36
2.1.0
diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md
index b1ddbb29..db7fa703 100644
--- a/telegrambots-abilities/README.md
+++ b/telegrambots-abilities/README.md
@@ -18,14 +18,14 @@ Usage
org.telegram
telegrambots-abilities
- 5.7.1
+ 6.0.1
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-abilities:5.7.1'
+ implementation 'org.telegram:telegrambots-abilities:6.0.1'
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml
index 38e75777..b18bd042 100644
--- a/telegrambots-abilities/pom.xml
+++ b/telegrambots-abilities/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambots-abilities
@@ -86,7 +86,7 @@
org.telegram
telegrambots
- 5.7.1
+ 6.0.1
org.apache.commons
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java
index 34ce39ce..6d77687a 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Ability.java
@@ -215,16 +215,6 @@ public final class Ability {
return this;
}
- /**
- * @deprecated Please use {@link #reply(BiConsumer, Predicate[])}
- */
- @Deprecated
- @SafeVarargs
- public final AbilityBuilder reply(Consumer action, Predicate... conditions) {
- replies.add(Reply.of(action, conditions));
- return this;
- }
-
@SafeVarargs
public final AbilityBuilder reply(BiConsumer action, Predicate... conditions) {
replies.add(Reply.of(action, conditions));
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java
index 457290ed..8ba939ab 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/Reply.java
@@ -43,29 +43,6 @@ public class Reply {
}
}
- /**
- * @deprecated Please use {@link #Reply(List, BiConsumer)}
- */
- @Deprecated
- Reply(List> conditions, Consumer action) {
- this.conditions = ImmutableList.>builder()
- .addAll(conditions)
- .build();
- this.action = ((baseAbilityBot, update) -> action.accept(update));
- statsEnabled = false;
- }
-
- /**
- * @deprecated Please use {@link #Reply(List, BiConsumer, String)}
- */
- @Deprecated
- Reply(List> conditions, Consumer action, String name) {
- this(conditions, action);
- if (Objects.nonNull(name)) {
- enableStats(name);
- }
- }
-
public static Reply of(BiConsumer action, List> conditions) {
return new Reply(conditions, action);
}
@@ -75,23 +52,6 @@ public class Reply {
return Reply.of(action, newArrayList(conditions));
}
- /**
- * @deprecated Please use {@link #of(BiConsumer, List)}
- */
- @Deprecated
- public static Reply of(Consumer action, List> conditions) {
- return new Reply(conditions, action);
- }
-
- /**
- * @deprecated Please use {@link #of(BiConsumer, Predicate[])}
- */
- @Deprecated
- @SafeVarargs
- public static Reply of(Consumer action, Predicate... conditions) {
- return Reply.of(action, newArrayList(conditions));
- }
-
public boolean isOkFor(Update update) {
// The following variable is required to avoid bug #JDK-8044546
BiFunction, Boolean> stateAnd = (state, cond) -> state && cond.test(update);
diff --git a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java
index 9fb5c3c7..d2148464 100644
--- a/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java
+++ b/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/objects/ReplyFlow.java
@@ -65,15 +65,6 @@ public class ReplyFlow extends Reply {
this(db, replyCounter.getAndIncrement());
}
- /**
- * @deprecated Please use {@link #action(BiConsumer)}
- */
- @Deprecated
- public ReplyFlowBuilder action(Consumer action) {
- this.action = (bot, update) -> action.accept(update);
- return this;
- }
-
public ReplyFlowBuilder action(BiConsumer action) {
this.action = action;
return this;
diff --git a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/DefaultBot.java b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/DefaultBot.java
index 520271f9..e43a6499 100644
--- a/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/DefaultBot.java
+++ b/telegrambots-abilities/src/test/java/org/telegram/abilitybots/api/bot/DefaultBot.java
@@ -78,19 +78,20 @@ public class DefaultBot extends AbilityBot {
public Reply channelPostReply() {
return Reply.of(
- (bot, upd) -> silent.send("test channel post", upd.getChannelPost().getChatId()), Flag.CHANNEL_POST
+ (bot, upd) -> silent.send("test channel post", upd.getChannelPost().getChatId()),
+ Flag.CHANNEL_POST
);
}
public ReplyCollection createReplyCollection() {
return ReplyCollection.of(
Reply.of(
- upd -> silent.send("first reply answer", upd.getMessage().getChatId()),
- update -> update.getMessage().getText().equalsIgnoreCase(FIRST_REPLY_KEY_MESSAGE)
+ (bot, upd) -> silent.send("first reply answer", upd.getMessage().getChatId()),
+ update -> update.getMessage().getText().equalsIgnoreCase(FIRST_REPLY_KEY_MESSAGE)
),
Reply.of(
- upd -> silent.send("second reply answer", upd.getMessage().getChatId()),
- update -> update.getMessage().getText().equalsIgnoreCase(SECOND_REPLY_KEY_MESSAGE)
+ (bot, upd) -> silent.send("second reply answer", upd.getMessage().getChatId()),
+ update -> update.getMessage().getText().equalsIgnoreCase(SECOND_REPLY_KEY_MESSAGE)
)
);
}
diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md
index fbc3d296..da2e48fb 100644
--- a/telegrambots-chat-session-bot/README.md
+++ b/telegrambots-chat-session-bot/README.md
@@ -15,14 +15,14 @@ Usage
org.telegram
telegrambots-chat-session-bot
- 5.7.1
+ 6.0.1
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-chat-session-bot:5.7.1'
+ implementation 'org.telegram:telegrambots-chat-session-bot:6.0.1'
```
Motivation
diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml
index d1ce7a2a..7909f790 100644
--- a/telegrambots-chat-session-bot/pom.xml
+++ b/telegrambots-chat-session-bot/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambots-chat-session-bot
@@ -86,7 +86,7 @@
org.telegram
telegrambots
- 5.7.1
+ 6.0.1
diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md
index 56b8aac5..747fe69a 100644
--- a/telegrambots-extensions/README.md
+++ b/telegrambots-extensions/README.md
@@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
org.telegram
telegrambotsextensions
- 5.7.1
+ 6.0.1
```
2. Using Gradle:
```gradle
- implementation 'org.telegram:telegrambotsextensions:5.7.1'
+ implementation 'org.telegram:telegrambotsextensions:6.0.1'
```
\ No newline at end of file
diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml
index c5ec8bfc..f947f1b7 100644
--- a/telegrambots-extensions/pom.xml
+++ b/telegrambots-extensions/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambotsextensions
@@ -77,7 +77,7 @@
org.telegram
telegrambots
- 5.7.1
+ 6.0.1
diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml
index 9d07e56e..030fcaaa 100644
--- a/telegrambots-meta/pom.xml
+++ b/telegrambots-meta/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambots-meta
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java
index 6f85078c..4f001ec1 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ActionType.java
@@ -9,20 +9,10 @@ public enum ActionType {
TYPING("typing"),
RECORDVIDEO("record_video"),
RECORDVIDEONOTE("record_video_note"),
- /**
- * @deprecated Use {@link #RECORDVOICE} instead
- */
- @Deprecated
- RECORDAUDIO("record_audio"),
RECORDVOICE("record_voice"),
UPLOADPHOTO("upload_photo"),
UPLOADVIDEO("upload_video"),
UPLOADVIDEONOTE("upload_video_note"),
- /**
- * @deprecated Use {@link #UPLOADVOICE} instead
- */
- @Deprecated
- UPLOADAUDIO("upload_audio"),
UPLOADVOICE("upload_voice"),
UPLOADDOCUMENT("upload_document"),
FINDLOCATION("find_location");
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRights.java
new file mode 100644
index 00000000..393083c6
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRights.java
@@ -0,0 +1,66 @@
+package org.telegram.telegrambots.meta.api.methods.adminrights;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Use this method to get the current default administrator rights of the bot.
+ *
+ * Returns ChatAdministratorRights on success.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class GetMyDefaultAdministratorRights extends BotApiMethod {
+ public static final String PATH = "getMyDefaultAdministratorRights";
+
+ private static final String FORCHANNELS_FIELD = "for_channels";
+
+ /**
+ * Optional
+ * Pass True to change default administrator rights of the bot in channels.
+ * Otherwise, default administrator rights of the bot for groups and supergroups will be changed.
+ */
+ @JsonProperty(FORCHANNELS_FIELD)
+ private Boolean forChannels;
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public ChatAdministratorRights deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error getting default administrator rights", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRights.java
new file mode 100644
index 00000000..7f572758
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRights.java
@@ -0,0 +1,74 @@
+package org.telegram.telegrambots.meta.api.methods.adminrights;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
+import org.telegram.telegrambots.meta.api.objects.ApiResponse;
+import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights;
+import org.telegram.telegrambots.meta.api.objects.commands.scope.BotCommandScope;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Use this method to change default administrator rights of the bot for adding it as an administrator to groups or channels.
+ * Returns True on success.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class SetMyDefaultAdministratorRights extends BotApiMethod {
+ public static final String PATH = "setMyDefaultAdministratorRights";
+
+ private static final String RIGHTS_FIELD = "rights";
+ private static final String FORCHANNELS_FIELD = "for_channels";
+
+ /**
+ * Optional
+ * A JSON-serialized object, describing new default administrator rights.
+ * If not specified, the default administrator rights will be cleared.
+ */
+ @JsonProperty(RIGHTS_FIELD)
+ private ChatAdministratorRights rights;
+ /**
+ * Optional
+ * Pass True to change default administrator rights of the bot in channels.
+ * Otherwise, default administrator rights of the bot for groups and supergroups will be changed.
+ */
+ @JsonProperty(FORCHANNELS_FIELD)
+ private Boolean forChannels;
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error setting default administrator rights", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/DeleteMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/DeleteMyCommands.java
index 6a278072..b9bc6242 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/DeleteMyCommands.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/DeleteMyCommands.java
@@ -66,7 +66,7 @@ public class DeleteMyCommands extends BotApiMethod {
if (result.getOk()) {
return result.getResult();
} else {
- throw new TelegramApiRequestException("Error sending commands", result);
+ throw new TelegramApiRequestException("Error deleting commands", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java
deleted file mode 100644
index 199adf29..00000000
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/KickChatMember.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.telegram.telegrambots.meta.api.methods.groupadministration;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.type.TypeReference;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
-import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
-import org.telegram.telegrambots.meta.api.objects.ApiResponse;
-import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
-import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
-
-import java.io.IOException;
-import java.time.Duration;
-import java.time.Instant;
-import java.time.ZonedDateTime;
-
-/**
- * @author Ruben Bermudez
- * @version 1.0
- * Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups,
- * the user will not be able to return to the group on their own using invite links, etc., unless
- * unbanned first. The bot must be an administrator in the group for this to work. Returns True on
- * success.
- * @apiNote This will method only work if the ‘All Members Are Admins’ setting is off in the target
- * group. Otherwise members may only be removed by the group's creator or by the member that added
- * them.
- *
- * @deprecated Use {@link BanChatMember#BanChatMember()} instead
- */
-@EqualsAndHashCode(callSuper = false)
-@Getter
-@Setter
-@ToString
-@NoArgsConstructor
-@RequiredArgsConstructor
-@AllArgsConstructor
-@Builder
-@Deprecated
-public class KickChatMember extends BotApiMethod {
- public static final String PATH = "kickchatmember";
-
- private static final String CHATID_FIELD = "chat_id";
- private static final String USER_ID_FIELD = "user_id";
- private static final String UNTILDATE_FIELD = "until_date";
- private static final String REVOKEMESSAGES_FIELD = "revoke_messages";
-
- @JsonProperty(CHATID_FIELD)
- @NonNull
- private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
- @JsonProperty(USER_ID_FIELD)
- @NonNull
- private Long userId; ///< Required. Unique identifier of the target user
- @JsonProperty(UNTILDATE_FIELD)
- private Integer untilDate; ///< Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
- /**
- * Optional
- *
- * Pass True to delete all messages from the chat for the user that is being removed.
- *
- * If False, the user will be able to see messages in the group that were sent before the user was removed.
- *
- * Always True for supergroups and channels.
- */
- @JsonProperty(REVOKEMESSAGES_FIELD)
- private Boolean revokeMessages;
-
-
- @JsonIgnore
- public void setUntilDateInstant(Instant instant) {
- setUntilDate((int) instant.getEpochSecond());
- }
-
- @JsonIgnore
- public void setUntilDateDateTime(ZonedDateTime date) {
- setUntilDateInstant(date.toInstant());
- }
-
- @JsonIgnore
- public void forTimePeriodDuration(Duration duration) {
- setUntilDateInstant(Instant.now().plusMillis(duration.toMillis()));
- }
-
- @Override
- public String getMethod() {
- return PATH;
- }
-
- @Override
- public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
- try {
- ApiResponse result = OBJECT_MAPPER.readValue(answer,
- new TypeReference>(){});
- if (result.getOk()) {
- return result.getResult();
- } else {
- throw new TelegramApiRequestException("Error kicking chat member", result);
- }
- } catch (IOException e) {
- throw new TelegramApiRequestException("Unable to deserialize response", e);
- }
- }
-
- @Override
- public void validate() throws TelegramApiValidationException {
- if (chatId == null || chatId.isEmpty()) {
- throw new TelegramApiValidationException("ChatId can't be empty", this);
- }
- if (userId == null) {
- throw new TelegramApiValidationException("UserId can't be null", this);
- }
- }
-}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java
index 505691a9..76b11cb2 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java
@@ -49,7 +49,7 @@ public class PromoteChatMember extends BotApiMethod {
private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members";
private static final String ISANONYMOUS_FIELD = "is_anonymous";
private static final String CANMANAGECHAT_FIELD = "can_manage_chat";
- private static final String CANMANAGEVOICECHATS_FIELD = "can_manage_voice_chats";
+ private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats";
@JsonProperty(CHATID_FIELD)
@NonNull
@@ -86,12 +86,11 @@ public class PromoteChatMember extends BotApiMethod {
@JsonProperty(CANMANAGECHAT_FIELD)
private Boolean canManageChat;
/**
- * Optional.
- *
- * Pass True, if the administrator can manage voice chats, supergroups only
+ * Optional
+ * Pass True, if the administrator can manage video chats
*/
- @JsonProperty(CANMANAGEVOICECHATS_FIELD)
- private Boolean canManageVoiceChats;
+ @JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
+ private Boolean canManageVideoChats;
@Override
public String getMethod() {
@@ -116,11 +115,11 @@ public class PromoteChatMember extends BotApiMethod {
@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);
+ if (userId == 0L) {
+ throw new TelegramApiValidationException("UserId can't be empty", this);
}
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButton.java
similarity index 51%
rename from telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java
rename to telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButton.java
index b9c990e7..494609c1 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMembersCount.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButton.java
@@ -1,17 +1,11 @@
-package org.telegram.telegrambots.meta.api.methods.groupadministration;
+package org.telegram.telegrambots.meta.api.methods.menubutton;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
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;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
@@ -19,10 +13,11 @@ import java.io.IOException;
/**
* @author Ruben Bermudez
- * @version 1.0
- * Use this method to get the number of members in a chat. Returns Int on success.
+ * @version 6.0
*
- * @deprecated Use {{@link GetChatMemberCount#GetChatMemberCount()}
+ * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.
+ *
+ * Returns MenuButton on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@@ -31,15 +26,23 @@ import java.io.IOException;
@NoArgsConstructor
@AllArgsConstructor
@Builder
-@Deprecated
-public class GetChatMembersCount extends BotApiMethod {
- public static final String PATH = "getChatMembersCount";
+public class GetChatMenuButton extends BotApiMethod {
+ public static final String PATH = "getChatMenuButton";
private static final String CHATID_FIELD = "chat_id";
+ /**
+ * Optional
+ * Unique identifier for the target private chat.
+ * If not specified, default bot's menu button will be returned
+ */
@JsonProperty(CHATID_FIELD)
- @NonNull
- private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
+ private String chatId;
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+
+ }
@Override
public String getMethod() {
@@ -47,24 +50,17 @@ public class GetChatMembersCount extends BotApiMethod {
}
@Override
- public Integer deserializeResponse(String answer) throws TelegramApiRequestException {
+ public MenuButton deserializeResponse(String answer) throws TelegramApiRequestException {
try {
- ApiResponse result = OBJECT_MAPPER.readValue(answer,
- new TypeReference>(){});
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
if (result.getOk()) {
return result.getResult();
} else {
- throw new TelegramApiRequestException("Error getting chat members count", result);
+ throw new TelegramApiRequestException("Error getting chat menu button query", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
-
- @Override
- public void validate() throws TelegramApiValidationException {
- if (chatId == null || chatId.isEmpty()) {
- throw new TelegramApiValidationException("ChatId can't be empty", this);
- }
- }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java
new file mode 100644
index 00000000..bcf9a6a2
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java
@@ -0,0 +1,78 @@
+package org.telegram.telegrambots.meta.api.methods.menubutton;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.*;
+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;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Use this method to change bot's menu button in a private chat, or the default menu button.
+ *
+ * Returns True on success.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class SetChatMenuButton extends BotApiMethod {
+ public static final String PATH = "setChatMenuButton";
+
+ private static final String CHATID_FIELD = "chat_id";
+ private static final String MENUBUTTON_FIELD = "menu_button";
+
+ /**
+ * Optional
+ * Unique identifier for the target private chat.
+ * If not specified, default bot's menu button will be changed
+ */
+ @JsonProperty(CHATID_FIELD)
+ private String chatId;
+ /**
+ * Optional
+ * A JSON-serialized object for the new bot's menu button.
+ * Defaults to MenuButtonDefault
+ */
+ @JsonProperty(MENUBUTTON_FIELD)
+ private MenuButton menuButton;
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (menuButton != null) {
+ menuButton.validate();
+ }
+ }
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error setting chat menu button query", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java
new file mode 100644
index 00000000..682b939e
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java
@@ -0,0 +1,74 @@
+package org.telegram.telegrambots.meta.api.methods.webapp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import lombok.*;
+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.payments.ShippingOption;
+import org.telegram.telegrambots.meta.api.objects.webapp.SentWebAppMessage;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Use this method to set result of interaction with web app and send corresponding
+ * message on behalf of the user to the chat from which the query originated.
+ *
+ *
+ * On success, SentWebAppMessage is returned.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class AnswerWebAppQuery extends BotApiMethod {
+ public static final String PATH = "answerWebAppQuery";
+
+ private static final String WEBAPPQUERYID_FIELD = "web_app_query_id";
+ private static final String RESULT_FIELD = "result";
+
+ @JsonProperty(WEBAPPQUERYID_FIELD)
+ @NonNull
+ private String webAppQueryId; ///< Unique identifier for the answered query
+ @JsonProperty(RESULT_FIELD)
+ @NonNull
+ private InlineQueryResult queryResult; ///< A JSON-serialized object with a description of the message to send
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (webAppQueryId.isEmpty()) {
+ throw new TelegramApiValidationException("WebAppQueryId can't be empty", this);
+ }
+
+ queryResult.validate();
+ }
+
+ @Override
+ public String getMethod() {
+ return PATH;
+ }
+
+ @Override
+ public SentWebAppMessage deserializeResponse(String answer) throws TelegramApiRequestException {
+ try {
+ ApiResponse result = OBJECT_MAPPER.readValue(answer,
+ new TypeReference>(){});
+ if (result.getOk()) {
+ return result.getResult();
+ } else {
+ throw new TelegramApiRequestException("Error answering web app query query", result);
+ }
+ } catch (IOException e) {
+ throw new TelegramApiRequestException("Unable to deserialize response", e);
+ }
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
index d5a57cad..ba1a3cb2 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java
@@ -17,10 +17,11 @@ import org.telegram.telegrambots.meta.api.objects.payments.SuccessfulPayment;
import org.telegram.telegrambots.meta.api.objects.polls.Poll;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
import org.telegram.telegrambots.meta.api.objects.stickers.Sticker;
-import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatEnded;
-import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatParticipantsInvited;
-import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatScheduled;
-import org.telegram.telegrambots.meta.api.objects.voicechat.VoiceChatStarted;
+import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatEnded;
+import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatParticipantsInvited;
+import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatScheduled;
+import org.telegram.telegrambots.meta.api.objects.videochat.VideoChatStarted;
+import org.telegram.telegrambots.meta.api.objects.webapp.WebAppData;
import java.util.ArrayList;
import java.util.List;
@@ -89,12 +90,13 @@ public class Message implements BotApiObject {
private static final String SENDERCHAT_FIELD = "sender_chat";
private static final String PROXIMITYALERTTRIGGERED_FIELD = "proximity_alert_triggered";
private static final String MESSAGEAUTODELETETIMERCHANGED_FIELD = "message_auto_delete_timer_changed";
- private static final String VOICECHATSTARTED_FIELD = "voice_chat_started";
- private static final String VOICECHATENDED_FIELD = "voice_chat_ended";
- private static final String VOICECHATPARTICIPANTSINVITED_FIELD = "voice_chat_participants_invited";
- private static final String VOICECHATSCHEDULED_FIELD = "voice_chat_scheduled";
private static final String ISAUTOMATICFORWARD_FIELD = "is_automatic_forward";
private static final String HASPROTECTEDCONTENT_FIELD = "has_protected_content";
+ private static final String WEBAPPDATA_FIELD = "web_app_data";
+ private static final String VIDEOCHATSCHEDULED_FIELD = "video_chat_scheduled";
+ private static final String VIDEOCHATSTARTED_FIELD = "video_chat_started";
+ private static final String VIDEOCHATENDED_FIELD = "video_chat_ended";
+ private static final String VIDEOCHATPARTICIPANTSINVITED_FIELD = "video_chat_participants_invited";
private static final String VIEWS_FIELD = "views";
private static final String OUTGOING_FIELD = "outgoing";
@@ -267,14 +269,6 @@ public class Message implements BotApiObject {
private ProximityAlertTriggered proximityAlertTriggered;
@JsonProperty(MESSAGEAUTODELETETIMERCHANGED_FIELD)
private MessageAutoDeleteTimerChanged messageAutoDeleteTimerChanged; ///< Optional. Service message: auto-delete timer settings changed in the chat
- @JsonProperty(VOICECHATSTARTED_FIELD)
- private VoiceChatStarted voiceChatStarted; ///< Optional. Service message: voice chat started
- @JsonProperty(VOICECHATENDED_FIELD)
- private VoiceChatEnded voiceChatEnded; ///< Optional. Service message: voice chat ended
- @JsonProperty(VOICECHATPARTICIPANTSINVITED_FIELD)
- private VoiceChatParticipantsInvited voiceChatParticipantsInvited; ///< Optional. Service message: new members invited to a voice chat
- @JsonProperty(VOICECHATSCHEDULED_FIELD)
- private VoiceChatScheduled voiceChatScheduled; ///< Optional. Service message: voice chat scheduled
@JsonProperty(ISAUTOMATICFORWARD_FIELD)
/**
* Optional.
@@ -283,6 +277,16 @@ public class Message implements BotApiObject {
private Boolean isAutomaticForward;
@JsonProperty(HASPROTECTEDCONTENT_FIELD)
private Boolean hasProtectedContent; ///< Optional. True, if the message can't be forwarded
+ @JsonProperty(WEBAPPDATA_FIELD)
+ private WebAppData webAppData; ///< Optional. Service message: data sent by a web app
+ @JsonProperty(VIDEOCHATSTARTED_FIELD)
+ private VideoChatStarted videoChatStarted; ///< Optional. Service message: video chat started
+ @JsonProperty(VIDEOCHATENDED_FIELD)
+ private VideoChatEnded videoChatEnded; ///< Optional. Service message: video chat ended
+ @JsonProperty(VIDEOCHATPARTICIPANTSINVITED_FIELD)
+ private VideoChatParticipantsInvited videoChatParticipantsInvited; ///< Optional. Service message: new participants invited to a video chat
+ @JsonProperty(VIDEOCHATSCHEDULED_FIELD)
+ private VideoChatScheduled videoChatScheduled; ///< Optional. Service message: video chat scheduled
@JsonProperty(OUTGOING_FIELD)
private Boolean outgoing; ///< Optional. Extra.
@@ -458,22 +462,27 @@ public class Message implements BotApiObject {
}
@JsonIgnore
- private boolean hasVoiceChatStarted() {
- return voiceChatStarted != null;
+ private boolean hasWebAppData() {
+ return webAppData != null;
}
@JsonIgnore
- private boolean hasVoiceChatEnded() {
- return voiceChatEnded != null;
+ private boolean hasVideoChatStarted() {
+ return videoChatStarted != null;
}
@JsonIgnore
- private boolean hasVoiceChatScheduled() {
- return voiceChatScheduled != null;
+ private boolean hasVideoChatEnded() {
+ return videoChatEnded != null;
}
@JsonIgnore
- private boolean hasVoiceChatParticipantsInvited() {
- return voiceChatParticipantsInvited != null;
+ private boolean hasVideoChatScheduled() {
+ return videoChatScheduled != null;
+ }
+
+ @JsonIgnore
+ private boolean hasVideoChatParticipantsInvited() {
+ return videoChatParticipantsInvited != null;
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WebhookInfo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WebhookInfo.java
index ea580761..3c5e3bd1 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WebhookInfo.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WebhookInfo.java
@@ -32,6 +32,7 @@ public class WebhookInfo implements BotApiObject {
private static final String LASTERRORDATE_FIELD = "last_error_date";
private static final String LASTERRORMESSAGE_FIELD = "last_error_message";
private static final String IPADDRESS_FIELD = "ip_address";
+ private static final String LASTSYNCHRONIZATIONERRORDATE_FIELD = "last_synchronization_error_date";
@JsonProperty(URL_FIELD)
private String url; ///< Webhook URL, may be empty if webhook is not set up
@@ -49,4 +50,10 @@ public class WebhookInfo implements BotApiObject {
private List allowedUpdates; ///< Optional. A list of update types the bot is subscribed to. Defaults to all update types
@JsonProperty(IPADDRESS_FIELD)
private String ipAddress; ///< Optional. Currently used webhook IP address
+ /**
+ * Optional.
+ * Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters
+ */
+ @JsonProperty(LASTSYNCHRONIZATIONERRORDATE_FIELD)
+ private Integer lastSynchronizationErrorDate;
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java
new file mode 100644
index 00000000..15bfff13
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java
@@ -0,0 +1,68 @@
+package org.telegram.telegrambots.meta.api.objects.adminrights;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Represents rights of an administrator in a chat.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ChatAdministratorRights implements BotApiObject {
+
+ private static final String ISANONYMOUS_FIELD = "is_anonymous";
+ private static final String CANMANAGECHAT_FIELD = "can_manage_chat";
+ private static final String CANDELETEMESSAGES_FIELD = "can_delete_messages";
+ private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats";
+ private static final String CANRESTRICTMEMBERS_FIELD = "can_restrict_members";
+ private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members";
+ private static final String CANCHANGEINFO_FIELD = "can_change_info";
+ private static final String CANINVITEUSERS_FIELD = "can_invite_users";
+ private static final String CANPOSTMESSAGES_FIELD = "can_post_messages";
+ private static final String CANEDITMESSAGES_FIELD = "can_edit_messages";
+ private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
+
+ @JsonProperty(ISANONYMOUS_FIELD)
+ private Boolean isAnonymous; ///< True, if the user's presence in the chat is hidden
+ /**
+ * True, if the administrator can access the chat event log, chat statistics,
+ * message statistics in channels, see channel members, see anonymous administrators
+ * in supergroups and ignore slow mode.
+ * Implied by any other administrator privilege
+ */
+ @JsonProperty(CANMANAGECHAT_FIELD)
+ private Boolean canManageChat;
+ @JsonProperty(CANDELETEMESSAGES_FIELD)
+ private Boolean canDeleteMessages; ///< True, if the administrator can delete messages of other users
+ @JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
+ private Boolean canManageVideoChats; ///< True, if the administrator can manage video chats
+ @JsonProperty(CANRESTRICTMEMBERS_FIELD)
+ private Boolean canRestrictMembers; ///< True, if the administrator can restrict, ban or unban chat members
+ /**
+ * True, if the administrator can add new administrators with a subset of
+ * their own privileges or demote administrators that he has promoted,
+ * directly or indirectly (promoted by administrators that were appointed by the user)
+ */
+ @JsonProperty(CANPROMOTEMEMBERS_FIELD)
+ private Boolean canPromoteMembers;
+ @JsonProperty(CANCHANGEINFO_FIELD)
+ private Boolean canChangeInfo; ///< True, if the user is allowed to change the chat title, photo and other settings
+ @JsonProperty(CANINVITEUSERS_FIELD)
+ private Boolean canInviteUsers; ///< True, if the user is allowed to invite new users to the chat
+ @JsonProperty(CANPOSTMESSAGES_FIELD)
+ private Boolean canPostMessages; ///< Optional. True, if the administrator can post in the channel; channels only
+ @JsonProperty(CANEDITMESSAGES_FIELD)
+ private Boolean canEditMessages; ///< Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
+ @JsonProperty(CANPINMESSAGES_FIELD)
+ private Boolean canPinMessages; ///< Optional. True, if the user is allowed to pin messages; groups and supergroups only
+
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java
index c8ca7056..be599344 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberAdministrator.java
@@ -37,12 +37,12 @@ public class ChatMemberAdministrator implements ChatMember {
private static final String CANPOSTMESSAGES_FIELD = "can_post_messages";
private static final String CANEDITMESSAGES_FIELD = "can_edit_messages";
private static final String CANDELETEMESSAGES_FIELD = "can_delete_messages";
- private static final String CANMANAGEVOICECHATS_FIELD = "can_manage_voice_chats";
private static final String CANRESTRICTMEMBERS_FIELD = "can_restrict_members";
private static final String CANPROMOTEMEMBERS_FIELD = "can_promote_members";
private static final String CANCHANGEINFO_FIELD = "can_change_info";
private static final String CANINVITEUSERS_FIELD = "can_invite_users";
private static final String CANPINMESSAGES_FIELD = "can_pin_messages";
+ private static final String CANMANAGEVIDEOCHATS_FIELD = "can_manage_video_chats";
/**
* The member's status in the chat, always “administrator”
@@ -92,11 +92,6 @@ public class ChatMemberAdministrator implements ChatMember {
*/
@JsonProperty(CANDELETEMESSAGES_FIELD)
private Boolean canDeleteMessages;
- /**
- * True, if the administrator can manage voice chats
- */
- @JsonProperty(CANMANAGEVOICECHATS_FIELD)
- private Boolean canManageVoiceChats;
/**
* True, if the administrator can restrict, ban or unban chat members
*/
@@ -124,4 +119,9 @@ public class ChatMemberAdministrator implements ChatMember {
*/
@JsonProperty(CANPINMESSAGES_FIELD)
private Boolean canPinMessages;
+ /**
+ * True, if the administrator can manage video chats
+ */
+ @JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
+ private Boolean canManageVideoChats;
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButton.java
new file mode 100644
index 00000000..246d7c46
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButton.java
@@ -0,0 +1,45 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.api.objects.menubutton.serialization.MenuButtonDeserializer;
+import org.telegram.telegrambots.meta.api.objects.menubutton.serialization.MenuButtonSerializer;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 5.3
+ *
+ * This object describes bot's menu button in a private chat. It should be one of
+ *
+ * MenuButtonCommands
+ * MenuButtonWebApp
+ * MenuButtonDefault
+ *
+ * If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat.
+ * Otherwise the default menu button is applied.
+ *
+ * By default, the menu button opens the list of bot's commands.
+ */
+@JsonSerialize(using = MenuButtonSerializer.class)
+@JsonDeserialize(using = MenuButtonDeserializer.class)
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+public abstract class MenuButton implements BotApiObject, Validable {
+ public static final String TYPE_FIELD = "type";
+
+ @JsonProperty(TYPE_FIELD)
+ public abstract String getType();
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonCommands.java
new file mode 100644
index 00000000..8dd74570
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonCommands.java
@@ -0,0 +1,32 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.*;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Represents menu button, which opens the list of bot's commands.
+ */
+@SuppressWarnings({"unused"})
+@JsonDeserialize
+@EqualsAndHashCode(callSuper = true)
+@Getter
+@Setter
+@ToString
+@Builder
+public class MenuButtonCommands extends MenuButton {
+ private static final String TYPE = "commands"; ///< Type of the button, must be commands
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ super.validate();
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonDefault.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonDefault.java
new file mode 100644
index 00000000..d84b1145
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonDefault.java
@@ -0,0 +1,32 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.*;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Describes that no specific value for the menu button was set.
+ */
+@SuppressWarnings({"unused"})
+@JsonDeserialize
+@EqualsAndHashCode(callSuper = true)
+@Getter
+@Setter
+@ToString
+@Builder
+public class MenuButtonDefault extends MenuButton {
+ private static final String TYPE = "default"; ///< Type of the button, must be default
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ super.validate();
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonWebApp.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonWebApp.java
new file mode 100644
index 00000000..a9265ad2
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/MenuButtonWebApp.java
@@ -0,0 +1,53 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Represents menu button, which launches a web app.
+ */
+@SuppressWarnings({"unused"})
+@JsonDeserialize
+@EqualsAndHashCode(callSuper = true)
+@Getter
+@Setter
+@ToString
+@Builder
+public class MenuButtonWebApp extends MenuButton {
+ private static final String TYPE = "web_app"; ///< Type of the button, must be web_app
+
+ public static final String TEXT_FIELD = "text";
+ public static final String WEBAPP_FIELD = "web_app";
+
+ @JsonProperty(TEXT_FIELD)
+ @NonNull
+ private String text; ///< Text of the button
+ /**
+ * Description of the web app that will be launched when the user presses the button.
+ * The web app will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery.
+ */
+ @JsonProperty(WEBAPP_FIELD)
+ @NonNull
+ private WebAppInfo webAppInfo;
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ super.validate();
+
+ if (text.isEmpty()) {
+ throw new TelegramApiValidationException("Text can't be empty", this);
+ }
+ webAppInfo.validate();
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonDeserializer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonDeserializer.java
new file mode 100644
index 00000000..50222b00
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonDeserializer.java
@@ -0,0 +1,57 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton.serialization;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+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;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * JSON serializer for MenuButton type
+ */
+public class MenuButtonDeserializer extends StdDeserializer {
+
+ private final ObjectMapper objectMapper;
+
+ public MenuButtonDeserializer() {
+ this(null);
+ }
+
+ public MenuButtonDeserializer(Class> vc) {
+ super(vc);
+ this.objectMapper = new ObjectMapper();
+ }
+
+ @Override
+ public MenuButton deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
+ throws IOException, JsonProcessingException {
+
+ JsonNode node = jsonParser.getCodec().readTree(jsonParser);
+ switch (node.get("type").asText()) {
+ case "default":
+ return objectMapper.readValue(node.toString(),
+ new com.fasterxml.jackson.core.type.TypeReference() {
+ });
+ case "web_app":
+ return objectMapper.readValue(node.toString(),
+ new com.fasterxml.jackson.core.type.TypeReference() {
+ });
+ case "commands":
+ return objectMapper.readValue(node.toString(),
+ new com.fasterxml.jackson.core.type.TypeReference() {
+ });
+ }
+
+ return null;
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonSerializer.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonSerializer.java
new file mode 100644
index 00000000..48ba2aa2
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/menubutton/serialization/MenuButtonSerializer.java
@@ -0,0 +1,39 @@
+package org.telegram.telegrambots.meta.api.objects.menubutton.serialization;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButton;
+import org.telegram.telegrambots.meta.api.objects.menubutton.MenuButtonWebApp;
+
+import java.io.IOException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * JSON serializer for MenuButton type
+ */
+public class MenuButtonSerializer extends JsonSerializer {
+ @Override
+ public void serialize(MenuButton value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeStringField(MenuButton.TYPE_FIELD, value.getType());
+
+ if (value instanceof MenuButtonWebApp) {
+ MenuButtonWebApp menuButtonWebApp = (MenuButtonWebApp) value;
+
+ gen.writeStringField(MenuButtonWebApp.TEXT_FIELD, menuButtonWebApp.getText());
+ gen.writeObjectField(MenuButtonWebApp.WEBAPP_FIELD, menuButtonWebApp.getWebAppInfo());
+ }
+
+ gen.writeEndObject();
+ }
+
+
+ @Override
+ public void serializeWithType(MenuButton value, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
+ serialize(value, gen, serializers);
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java
index 4c28478a..645fb564 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/InlineKeyboardButton.java
@@ -14,6 +14,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
import org.telegram.telegrambots.meta.api.objects.LoginUrl;
import org.telegram.telegrambots.meta.api.objects.games.CallbackGame;
+import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
@@ -42,6 +43,7 @@ public class InlineKeyboardButton implements Validable, BotApiObject {
private static final String SWITCH_INLINE_QUERY_CURRENT_CHAT_FIELD = "switch_inline_query_current_chat";
private static final String PAY_FIELD = "pay";
private static final String LOGIN_URL_FIELD = "login_url";
+ private static final String WEBAPP_FIELD = "web_app";
@JsonProperty(TEXT_FIELD)
@NonNull
@@ -98,13 +100,25 @@ public class InlineKeyboardButton implements Validable, BotApiObject {
@JsonProperty(LOGIN_URL_FIELD)
private LoginUrl loginUrl;
+ /**
+ * Optional.
+ * Description of the web app that will be launched when the user presses the button.
+ * The web app will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery.
+ * Available only in private chats between users and the bot.
+ */
+ @JsonProperty(WEBAPP_FIELD)
+ private WebAppInfo webApp;
+
@Override
public void validate() throws TelegramApiValidationException {
- if (text == null || text.isEmpty()) {
+ if (text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
if (loginUrl != null) {
loginUrl.validate();
}
+ if (webApp != null) {
+ webApp.validate();
+ }
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java
index fb0adcfd..63c26b82 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButton.java
@@ -12,6 +12,7 @@ import lombok.Setter;
import lombok.ToString;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.api.objects.webapp.WebAppInfo;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
/**
@@ -40,6 +41,7 @@ public class KeyboardButton implements Validable, BotApiObject {
private static final String REQUEST_CONTACT_FIELD = "request_contact";
private static final String REQUEST_LOCATION_FIELD = "request_location";
private static final String REQUEST_POLL_FIELD = "request_poll";
+ private static final String WEBAPP_FIELD = "web_app";
/**
* Text of the button.
* If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed
@@ -69,9 +71,17 @@ public class KeyboardButton implements Validable, BotApiObject {
@JsonProperty(REQUEST_POLL_FIELD)
private KeyboardButtonPollType requestPoll;
+ /**
+ * Optional. Description of the web app that will be launched when the user presses the button.
+ * The web app will be able to send a “web_app_data” service message.
+ * Available in private chats only.
+ */
+ @JsonProperty(WEBAPP_FIELD)
+ private WebAppInfo webApp;
+
@Override
public void validate() throws TelegramApiValidationException {
- if (text == null || text.isEmpty()) {
+ if (text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
if (requestContact != null && requestLocation != null && requestContact && requestLocation) {
@@ -83,5 +93,8 @@ public class KeyboardButton implements Validable, BotApiObject {
if (requestLocation != null && requestPoll != null && requestLocation) {
throw new TelegramApiValidationException("Cant request location and poll at the same time", this);
}
+ if (webApp != null) {
+ webApp.validate();
+ }
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatEnded.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatEnded.java
similarity index 55%
rename from telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatEnded.java
rename to telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatEnded.java
index 07bc282c..b5ac9f1f 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatEnded.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatEnded.java
@@ -1,19 +1,14 @@
-package org.telegram.telegrambots.meta.api.objects.voicechat;
+package org.telegram.telegrambots.meta.api.objects.videochat;
import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
- * @version 5.1
+ * @version 6.0
*
- * This object represents a service message about a voice chat ended in the chat.
+ * This object represents a service message about a video chat ended in the chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@@ -21,7 +16,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
@ToString
@NoArgsConstructor
@AllArgsConstructor
-public class VoiceChatEnded implements BotApiObject {
+public class VideoChatEnded implements BotApiObject {
private static final String DURATION_FIELD = "duration";
@JsonProperty(DURATION_FIELD)
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatParticipantsInvited.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatParticipantsInvited.java
similarity index 64%
rename from telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatParticipantsInvited.java
rename to telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatParticipantsInvited.java
index d35ea25c..91203b20 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatParticipantsInvited.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatParticipantsInvited.java
@@ -1,12 +1,7 @@
-package org.telegram.telegrambots.meta.api.objects.voicechat;
+package org.telegram.telegrambots.meta.api.objects.videochat;
import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.User;
@@ -14,9 +9,9 @@ import java.util.List;
/**
* @author Ruben Bermudez
- * @version 5.1
+ * @version 6.0
*
- * This object represents a service message about new members invited to a voice chat.
+ * This object represents a service message about new members invited to a video chat.
*
*/
@EqualsAndHashCode(callSuper = false)
@@ -25,7 +20,7 @@ import java.util.List;
@ToString
@NoArgsConstructor
@AllArgsConstructor
-public class VoiceChatParticipantsInvited implements BotApiObject {
+public class VideoChatParticipantsInvited implements BotApiObject {
private static final String USERS_FIELD = "users";
@JsonProperty(USERS_FIELD)
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatScheduled.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java
similarity index 57%
rename from telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatScheduled.java
rename to telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java
index 83de59e1..3ef86b79 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatScheduled.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatScheduled.java
@@ -1,20 +1,14 @@
-package org.telegram.telegrambots.meta.api.objects.voicechat;
+package org.telegram.telegrambots.meta.api.objects.videochat;
import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
- * @version 5.2
+ * @version 6.0
*
- * This object represents a service message about a voice chat scheduled in the chat.
+ * This object represents a service message about a video chat scheduled in the chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@@ -22,7 +16,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
@ToString
@NoArgsConstructor
@AllArgsConstructor
-public class VoiceChatScheduled implements BotApiObject {
+public class VideoChatScheduled implements BotApiObject {
private static final String STARTDATE_FIELD = "start_date";
@JsonProperty(STARTDATE_FIELD)
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatStarted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatStarted.java
new file mode 100644
index 00000000..c2e5bc72
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/videochat/VideoChatStarted.java
@@ -0,0 +1,19 @@
+package org.telegram.telegrambots.meta.api.objects.videochat;
+
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * This object represents a service message about a video chat started in the chat.
+ * Currently holds no information.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+public class VideoChatStarted implements BotApiObject {
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatStarted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatStarted.java
deleted file mode 100644
index fe55ef03..00000000
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/voicechat/VoiceChatStarted.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.telegram.telegrambots.meta.api.objects.voicechat;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
-import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
-
-/**
- * @author Ruben Bermudez
- * @version 5.1
- *
- * This object represents a service message about a voice chat started in the chat.
- *
- * Currently holds no information.
- */
-@EqualsAndHashCode(callSuper = false)
-@Getter
-@Setter
-@ToString
-@NoArgsConstructor
-public class VoiceChatStarted implements BotApiObject {
-}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java
new file mode 100644
index 00000000..1b051134
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/SentWebAppMessage.java
@@ -0,0 +1,28 @@
+package org.telegram.telegrambots.meta.api.objects.webapp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class SentWebAppMessage implements BotApiObject {
+ private static final String INLINEMESSAGEID_FIELD = "inline_message_id";
+
+ @JsonProperty(INLINEMESSAGEID_FIELD)
+ @NonNull
+ private String inlineMessageId;
+
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java
new file mode 100644
index 00000000..b71c1625
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppData.java
@@ -0,0 +1,32 @@
+package org.telegram.telegrambots.meta.api.objects.webapp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ * Contains data sent from a web app to the bot.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class WebAppData implements BotApiObject {
+ private static final String DATA_FIELD = "data";
+ private static final String BUTTONTEXT_FIELD = "button_text";
+
+ @JsonProperty(DATA_FIELD)
+ @NonNull
+ private String data; ///< The data
+ @JsonProperty(BUTTONTEXT_FIELD)
+ @NonNull
+ private String buttonText; ///< Text of the web_app keyboard button, from which the web app was opened
+
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java
new file mode 100644
index 00000000..2e1bbf8f
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/webapp/WebAppInfo.java
@@ -0,0 +1,35 @@
+package org.telegram.telegrambots.meta.api.objects.webapp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import lombok.*;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ *
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class WebAppInfo implements Validable, BotApiObject {
+ private static final String URL_FIELD = "url";
+
+ @JsonProperty(URL_FIELD)
+ @NonNull
+ private String url; ///< An HTTPS URL of a web app to be opened with additional data as specified at ...
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (url.isEmpty()) {
+ throw new TelegramApiValidationException("Url can't be empty", this);
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java
new file mode 100644
index 00000000..e4e93ccd
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/GetMyDefaultAdministratorRightsTest.java
@@ -0,0 +1,76 @@
+package org.telegram.telegrambots.meta.api.methods.adminrights;
+
+import org.junit.jupiter.api.Test;
+import org.telegram.telegrambots.meta.api.methods.groupadministration.PromoteChatMember;
+import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class GetMyDefaultAdministratorRightsTest {
+ @Test
+ public void testGetMyDefaultAdministratorRightsWithAllSetForChannel() {
+ GetMyDefaultAdministratorRights getMyDefaultAdministratorRights = GetMyDefaultAdministratorRights
+ .builder()
+ .forChannels(true)
+ .build();
+ assertEquals("getMyDefaultAdministratorRights", getMyDefaultAdministratorRights.getMethod());
+ assertDoesNotThrow(getMyDefaultAdministratorRights::validate);
+ }
+
+ @Test
+ public void testGetMyDefaultAdministratorRightsWithAllSetForGroups() {
+ GetMyDefaultAdministratorRights getMyDefaultAdministratorRights = GetMyDefaultAdministratorRights
+ .builder()
+ .build();
+ assertEquals("getMyDefaultAdministratorRights", getMyDefaultAdministratorRights.getMethod());
+ assertDoesNotThrow(getMyDefaultAdministratorRights::validate);
+ }
+
+ @Test
+ public void testGetMyDefaultAdministratorRightsDeserializeValidResponse() {
+ String responseText = "{\n" +
+ " \"ok\": true,\n" +
+ " \"result\": {\n" +
+ " \"is_anonymous\": true,\n" +
+ " \"can_manage_chat\": true,\n" +
+ " \"can_delete_messages\": true,\n" +
+ " \"can_manage_video_chats\": true,\n" +
+ " \"can_restrict_members\": true,\n" +
+ " \"can_promote_members\": true,\n" +
+ " \"can_change_info\": true,\n" +
+ " \"can_invite_users\": true,\n" +
+ " \"can_post_messages\": true,\n" +
+ " \"can_edit_messages\": true,\n" +
+ " \"can_pin_messages\": true\n" +
+ " }\n" +
+ "}";
+
+ GetMyDefaultAdministratorRights getMyDefaultAdministratorRights = GetMyDefaultAdministratorRights
+ .builder()
+ .build();
+
+ try {
+ ChatAdministratorRights result = getMyDefaultAdministratorRights.deserializeResponse(responseText);
+ assertNotNull(result);
+ assertEquals(true, result.getIsAnonymous());
+ assertEquals(true, result.getCanManageChat());
+ assertEquals(true, result.getCanPostMessages());
+ assertEquals(true, result.getCanEditMessages());
+ assertEquals(true, result.getCanDeleteMessages());
+ assertEquals(true, result.getCanManageVideoChats());
+ assertEquals(true, result.getCanRestrictMembers());
+ assertEquals(true, result.getCanPromoteMembers());
+ assertEquals(true, result.getCanChangeInfo());
+ assertEquals(true, result.getCanInviteUsers());
+ assertEquals(true, result.getCanPinMessages());
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRightsTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRightsTest.java
new file mode 100644
index 00000000..8a060543
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/adminrights/SetMyDefaultAdministratorRightsTest.java
@@ -0,0 +1,96 @@
+package org.telegram.telegrambots.meta.api.methods.adminrights;
+
+import org.junit.jupiter.api.Test;
+import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class SetMyDefaultAdministratorRightsTest {
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsWithNone() {
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .build();
+ assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
+ assertDoesNotThrow(setMyDefaultAdministratorRights::validate);
+ }
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsForChannels() {
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .forChannels(true)
+ .build();
+ assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
+ assertDoesNotThrow(setMyDefaultAdministratorRights::validate);
+ }
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsWithAllSet() {
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .forChannels(true)
+ .rights(ChatAdministratorRights
+ .builder()
+ .isAnonymous(true)
+ .build())
+ .build();
+ assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
+ assertDoesNotThrow(setMyDefaultAdministratorRights::validate);
+ }
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsDeserializeValidResponse() {
+ String responseText = "{\"ok\":true,\"result\": true}";
+
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .build();
+
+ try {
+ boolean result = setMyDefaultAdministratorRights.deserializeResponse(responseText);
+ assertTrue(result);
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsDeserializeErrorResponse() {
+ String responseText = "{\"ok\":false,\"error_code\": 404,\"description\": \"Error message\"}";
+
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .build();
+
+ try {
+ setMyDefaultAdministratorRights.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals(404, e.getErrorCode());
+ assertEquals("Error message", e.getApiResponse());
+ }
+ }
+
+ @Test
+ public void testSetMyDefaultAdministratorRightsDeserializeWithWrongObject() {
+ String responseText = "{\"ok\":false\"error_code\": 404,\"description\": \"Error message\"}";
+
+ SetMyDefaultAdministratorRights setMyDefaultAdministratorRights = SetMyDefaultAdministratorRights
+ .builder()
+ .build();
+
+ try {
+ setMyDefaultAdministratorRights.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals("Unable to deserialize response", e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMemberTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMemberTest.java
new file mode 100644
index 00000000..1c6a026b
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMemberTest.java
@@ -0,0 +1,103 @@
+package org.telegram.telegrambots.meta.api.methods.groupadministration;
+
+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.*;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class PromoteChatMemberTest {
+ @Test
+ public void testPromoteChatMemberWithAllSet() {
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("12345")
+ .userId(12345L)
+ .build();
+ assertEquals("promoteChatMember", promoteChatMember.getMethod());
+ assertDoesNotThrow(promoteChatMember::validate);
+ }
+
+ @Test
+ public void testPromoteChatMemberWithEmptyChatId() {
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("")
+ .userId(12345L)
+ .build();
+ assertEquals("promoteChatMember", promoteChatMember.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, promoteChatMember::validate);
+ assertEquals("ChatId can't be empty", thrown.getMessage());
+ }
+
+ @Test
+ public void testPromoteChatMemberWithEmptyUserId() {
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("12345")
+ .userId(0L)
+ .build();
+ assertEquals("promoteChatMember", promoteChatMember.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, promoteChatMember::validate);
+ assertEquals("UserId can't be empty", thrown.getMessage());
+ }
+
+ @Test
+ public void testPromoteChatMemberDeserializeValidResponse() {
+ String responseText = "{\"ok\":true,\"result\": true}";
+
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("12345")
+ .userId(123456L)
+ .build();
+
+ try {
+ boolean result = promoteChatMember.deserializeResponse(responseText);
+ assertTrue(result);
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testPromoteChatMemberDeserializeErrorResponse() {
+ String responseText = "{\"ok\":false,\"error_code\": 404,\"description\": \"Error message\"}";
+
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("12345")
+ .userId(123456L)
+ .build();
+
+ try {
+ promoteChatMember.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals(404, e.getErrorCode());
+ assertEquals("Error message", e.getApiResponse());
+ }
+ }
+
+ @Test
+ public void testPromoteChatMemberDeserializeWithWrongObject() {
+ String responseText = "{\"ok\":false\"error_code\": 404,\"description\": \"Error message\"}";
+
+ PromoteChatMember promoteChatMember = PromoteChatMember
+ .builder()
+ .chatId("12345")
+ .userId(123456L)
+ .build();
+
+ try {
+ promoteChatMember.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals("Unable to deserialize response", e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButtonTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButtonTest.java
new file mode 100644
index 00000000..b6eb16d3
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/GetChatMenuButtonTest.java
@@ -0,0 +1,86 @@
+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.MenuButtonDefault;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class GetChatMenuButtonTest {
+
+ @Test
+ public void testGetChatMenuButtonAsDefault() {
+ GetChatMenuButton getChatMenuButton = GetChatMenuButton
+ .builder()
+ .build();
+ assertEquals("getChatMenuButton", getChatMenuButton.getMethod());
+ assertDoesNotThrow(getChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonForChat() {
+ GetChatMenuButton getChatMenuButton = GetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .build();
+ assertEquals("getChatMenuButton", getChatMenuButton.getMethod());
+ assertDoesNotThrow(getChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonDeserializeValidResponse() {
+ String responseText = "{\"ok\":true,\"result\":{\"type\": \"default\"}}";
+
+ GetChatMenuButton getChatMenuButton = GetChatMenuButton
+ .builder()
+ .chatId("12345")
+ .build();
+
+ try {
+ MenuButton result = getChatMenuButton.deserializeResponse(responseText);
+ assertNotNull(result);
+ assertTrue(result instanceof MenuButtonDefault);
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetChatMenuButtonErrorResponse() {
+ String responseText = "{\"ok\":false,\"error_code\": 404,\"description\": \"Error message\"}";
+
+ GetChatMenuButton getChatMenuButton = GetChatMenuButton
+ .builder()
+ .build();
+
+ try {
+ getChatMenuButton.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals(404, e.getErrorCode());
+ assertEquals("Error message", e.getApiResponse());
+ }
+ }
+
+ @Test
+ public void testGetChatMenuButtonDeserializeWithWrongObject() {
+ String responseText = "{\"ok\":false\"error_code\": 404,\"description\": \"Error message\"}";
+
+ GetChatMenuButton getChatMenuButton = GetChatMenuButton
+ .builder()
+ .chatId("12345")
+ .build();
+
+ try {
+ getChatMenuButton.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals("Unable to deserialize response", e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButtonTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButtonTest.java
new file mode 100644
index 00000000..4bdfe6c1
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButtonTest.java
@@ -0,0 +1,149 @@
+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;
+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.*;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class SetChatMenuButtonTest {
+
+ @Test
+ public void testGetChatMenuButtonAsDefault() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .menuButton(MenuButtonDefault.builder().build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ assertDoesNotThrow(setChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonAsCommands() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .menuButton(MenuButtonCommands.builder().build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ assertDoesNotThrow(setChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonAsWebApp() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .menuButton(MenuButtonWebApp
+ .builder()
+ .text("Web app text")
+ .webAppInfo(WebAppInfo.builder().url("My url").build())
+ .build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ assertDoesNotThrow(setChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonAsWebAppWithEmptyText() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .menuButton(MenuButtonWebApp
+ .builder()
+ .text("")
+ .webAppInfo(WebAppInfo.builder().url("My url").build())
+ .build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, setChatMenuButton::validate);
+ assertEquals("Text can't be empty", thrown.getMessage());
+ }
+
+ @Test
+ public void testGetChatMenuButtonAsWebAppWithEmptyWebUrl() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .menuButton(MenuButtonWebApp
+ .builder()
+ .text("Text")
+ .webAppInfo(WebAppInfo.builder().url("").build())
+ .build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, setChatMenuButton::validate);
+ assertEquals("Url can't be empty", thrown.getMessage());
+ }
+
+ @Test
+ public void testGetChatMenuButtonForChat() {
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("123456")
+ .menuButton(MenuButtonDefault.builder().build())
+ .build();
+ assertEquals("setChatMenuButton", setChatMenuButton.getMethod());
+ assertDoesNotThrow(setChatMenuButton::validate);
+ }
+
+ @Test
+ public void testGetChatMenuButtonDeserializeValidResponse() {
+ String responseText = "{\"ok\":true,\"result\": true}";
+
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("12345")
+ .build();
+
+ try {
+ boolean result = setChatMenuButton.deserializeResponse(responseText);
+ assertTrue(result);
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetChatMenuButtonErrorResponse() {
+ String responseText = "{\"ok\":false,\"error_code\": 404,\"description\": \"Error message\"}";
+
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .build();
+
+ try {
+ setChatMenuButton.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals(404, e.getErrorCode());
+ assertEquals("Error message", e.getApiResponse());
+ }
+ }
+
+ @Test
+ public void testGetChatMenuButtonDeserializeWithWrongObject() {
+ String responseText = "{\"ok\":false\"error_code\": 404,\"description\": \"Error message\"}";
+
+ SetChatMenuButton setChatMenuButton = SetChatMenuButton
+ .builder()
+ .chatId("12345")
+ .build();
+
+ try {
+ setChatMenuButton.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals("Unable to deserialize response", e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java
new file mode 100644
index 00000000..296967f3
--- /dev/null
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQueryTest.java
@@ -0,0 +1,159 @@
+package org.telegram.telegrambots.meta.api.methods.webapp;
+
+import org.junit.jupiter.api.Test;
+import org.telegram.telegrambots.meta.api.methods.groupadministration.PromoteChatMember;
+import org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent.InputTextMessageContent;
+import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult;
+import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResultArticle;
+import org.telegram.telegrambots.meta.api.objects.webapp.SentWebAppMessage;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.0
+ */
+public class AnswerWebAppQueryTest {
+
+ @Test
+ public void testAnswerWebAppQueryWithAllSet() {
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("123456789")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("MyId")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+ assertEquals("answerWebAppQuery", answerWebAppQuery.getMethod());
+ assertDoesNotThrow(answerWebAppQuery::validate);
+ }
+
+ @Test
+ public void testAnswerWebAppQueryWithEmptyId() {
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("MyId")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+ assertEquals("answerWebAppQuery", answerWebAppQuery.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, answerWebAppQuery::validate);
+ assertEquals("WebAppQueryId can't be empty", thrown.getMessage());
+ }
+
+ @Test
+ public void testAnswerWebAppQueryWithInvalidResult() {
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("123456789")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+ assertEquals("answerWebAppQuery", answerWebAppQuery.getMethod());
+ Throwable thrown = assertThrows(TelegramApiValidationException.class, answerWebAppQuery::validate);
+ assertEquals("ID parameter can't be empty", thrown.getMessage());
+ }
+
+
+ @Test
+ public void testAnswerWebAppQueryDeserializeValidResponse() {
+ String responseText = "{\"ok\":true,\"result\": { \"inline_message_id\": \"123456\" } }";
+
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("123456789")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+
+ try {
+ SentWebAppMessage result = answerWebAppQuery.deserializeResponse(responseText);
+ assertNotNull(result);
+ assertEquals("123456", result.getInlineMessageId());
+ } catch (TelegramApiRequestException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testAnswerWebAppQueryDeserializeErrorResponse() {
+ String responseText = "{\"ok\":false,\"error_code\": 404,\"description\": \"Error message\"}";
+
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("123456789")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+
+ try {
+ answerWebAppQuery.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals(404, e.getErrorCode());
+ assertEquals("Error message", e.getApiResponse());
+ }
+ }
+
+ @Test
+ public void testAnswerWebAppQueryDeserializeWithWrongObject() {
+ String responseText = "{\"ok\":false\"error_code\": 404,\"description\": \"Error message\"}";
+
+ AnswerWebAppQuery answerWebAppQuery = AnswerWebAppQuery
+ .builder()
+ .webAppQueryId("123456789")
+ .queryResult(InlineQueryResultArticle
+ .builder()
+ .id("")
+ .title("Text")
+ .inputMessageContent(InputTextMessageContent
+ .builder()
+ .messageText("My own text")
+ .build())
+ .build())
+ .build();
+
+ try {
+ answerWebAppQuery.deserializeResponse(responseText);
+ fail();
+ } catch (TelegramApiRequestException e) {
+ assertEquals("Unable to deserialize response", e.getMessage());
+ }
+ }
+}
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java
index bc8d1b15..bd781a6b 100644
--- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberTest.java
@@ -122,7 +122,7 @@ public class ChatMemberTest {
" \"can_post_messages\": true,\n" +
" \"can_edit_messages\": true,\n" +
" \"can_delete_messages\": true,\n" +
- " \"can_manage_voice_chats\": true,\n" +
+ " \"can_manage_video_chats\": true,\n" +
" \"can_restrict_members\": true,\n" +
" \"can_promote_members\": true,\n" +
" \"can_change_info\": true,\n" +
@@ -141,7 +141,7 @@ public class ChatMemberTest {
assertEquals(true, chatMemberAdministrator.getCanPostMessages());
assertEquals(true, chatMemberAdministrator.getCanEditMessages());
assertEquals(true, chatMemberAdministrator.getCanDeleteMessages());
- assertEquals(true, chatMemberAdministrator.getCanManageVoiceChats());
+ assertEquals(true, chatMemberAdministrator.getCanManageVideoChats());
assertEquals(true, chatMemberAdministrator.getCanRestrictMembers());
assertEquals(true, chatMemberAdministrator.getCanPromoteMembers());
assertEquals(true, chatMemberAdministrator.getCanChangeInfo());
diff --git a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java
index 9e1824d4..85d71596 100644
--- a/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java
+++ b/telegrambots-meta/src/test/java/org/telegram/telegrambots/meta/test/TestDeserialization.java
@@ -85,7 +85,7 @@ class TestDeserialization {
Integer updateId = update.getUpdateId();
JsonNode realUpdate = updateMap.get(updateId);
JsonNode handledUpdate = mapper.readTree(mapper.writeValueAsString(update));
- assertEquals(realUpdate, handledUpdate);
+ assertEquals(realUpdate, handledUpdate, String.format("Error with update %d", updateId));
}
}
@@ -111,10 +111,10 @@ class TestDeserialization {
String updateText = "{\"ok\":true,\"result\":[{\"update_id\":259894302,\n" +
"\"message\":{\"message_id\":105,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"Username\"},\"chat\":{\"id\":12345678,\"first_name\":\"FirstName\",\"username\":\"Username\",\"type\":\"private\"},\"date\":1604226451,\"text\":\"/start\",\"entities\":[{\"offset\":0,\"length\":6,\"type\":\"bot_command\"}]}},{\"update_id\":259894303,\n" +
"\"message\":{\"message_id\":106,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"Username\",\"language_code\":\"en\"},\"chat\":{\"id\":12345678,\"first_name\":\"FirstName\",\"username\":\"Username\",\"type\":\"private\"},\"date\":1604226480,\"document\":{\"file_name\":\"aaa.txt\",\"mime_type\":\"text/plain\",\"file_id\":\"FILEID\",\"file_unique_id\":\"AgADiQEAAjTe-VQ\",\"file_size\":2}}},{\"update_id\":259894304,\n" +
- "\"message\":{\"message_id\":107,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\",\"all_members_are_administrators\":true},\"date\":1604281682,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}]}},{\"update_id\":259894305,\n" +
- "\"message\":{\"message_id\":108,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\",\"all_members_are_administrators\":true},\"date\":1604281713,\"left_chat_member\":{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}}},{\"update_id\":259894306,\n" +
- "\"message\":{\"message_id\":109,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\",\"all_members_are_administrators\":true},\"date\":1604281720,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}]}},{\"update_id\":259894307,\n" +
- "\"message\":{\"message_id\":110,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\",\"all_members_are_administrators\":false},\"date\":1604281763,\"migrate_to_chat_id\":-10011869112345}},{\"update_id\":259894308,\n" +
+ "\"message\":{\"message_id\":107,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281682,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}]}},{\"update_id\":259894305,\n" +
+ "\"message\":{\"message_id\":108,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281713,\"left_chat_member\":{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}}},{\"update_id\":259894306,\n" +
+ "\"message\":{\"message_id\":109,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281720,\"new_chat_members\":[{\"id\":123455678,\"is_bot\":true,\"first_name\":\"Testing Telegram Bots\",\"username\":\"TestingRanBot\"}]}},{\"update_id\":259894307,\n" +
+ "\"message\":{\"message_id\":110,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"group\"},\"date\":1604281763,\"migrate_to_chat_id\":-10011869112345}},{\"update_id\":259894308,\n" +
"\"message\":{\"message_id\":1,\"from\":{\"id\":12345678,\"is_bot\":true,\"first_name\":\"Group\",\"username\":\"GroupAnonymousBot\"},\"sender_chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281763,\"migrate_from_chat_id\":-10011869112345}},{\"update_id\":259894309,\n" +
"\"message\":{\"message_id\":2,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281985,\"sticker\":{\"width\":512,\"height\":512,\"emoji\":\"\\ud83e\\udd2c\",\"set_name\":\"ShadowKitty\",\"is_animated\":true,\"thumb\":{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":7546,\"width\":128,\"height\":128},\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":13187}}},{\"update_id\":259894310,\n" +
"\"message\":{\"message_id\":3,\"from\":{\"id\":12345678,\"is_bot\":false,\"first_name\":\"FirstName\",\"username\":\"FirstName\",\"language_code\":\"en\"},\"chat\":{\"id\":-10011869112345,\"title\":\"My new test group\",\"type\":\"supergroup\"},\"date\":1604281993,\"photo\":[{\"file_id\":\"FILEID\",\"file_unique_id\":\"AQADL3I6J10AAzbcAQAB\",\"file_size\":15207,\"width\":148,\"height\":320},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":64579,\"width\":369,\"height\":800},{\"file_id\":\"FILEID\",\"file_unique_id\":\"FILEID\",\"file_size\":93424,\"width\":591,\"height\":1280}]}},{\"update_id\":259894311,\n" +
@@ -183,8 +183,7 @@ class TestDeserialization {
" \"chat\": {\n" +
" \"id\": -552721116,\n" +
" \"title\": \"Random test\",\n" +
- " \"type\": \"group\",\n" +
- " \"all_members_are_administrators\": false\n" +
+ " \"type\": \"group\"\n" +
" },\n" +
" \"date\": 1615072605,\n" +
" \"group_chat_created\": true\n" +
@@ -203,8 +202,7 @@ class TestDeserialization {
" \"chat\": {\n" +
" \"id\": -552721116,\n" +
" \"title\": \"Random test\",\n" +
- " \"type\": \"group\",\n" +
- " \"all_members_are_administrators\": false\n" +
+ " \"type\": \"group\"\n" +
" },\n" +
" \"date\": 1615072631,\n" +
" \"migrate_to_chat_id\": -1001308316775\n" +
@@ -226,7 +224,7 @@ class TestDeserialization {
" \"type\": \"supergroup\"\n" +
" },\n" +
" \"date\": 1615072662,\n" +
- " \"voice_chat_started\": {}\n" +
+ " \"video_chat_started\": {}\n" +
" }\n" +
" },\n" +
" {\n" +
@@ -245,7 +243,7 @@ class TestDeserialization {
" \"type\": \"supergroup\"\n" +
" },\n" +
" \"date\": 1615072671,\n" +
- " \"voice_chat_participants_invited\": {\n" +
+ " \"video_chat_participants_invited\": {\n" +
" \"users\": [\n" +
" {\n" +
" \"id\": 222222222222222,\n" +
@@ -274,7 +272,7 @@ class TestDeserialization {
" \"type\": \"supergroup\"\n" +
" },\n" +
" \"date\": 1615072919,\n" +
- " \"voice_chat_ended\": {\n" +
+ " \"video_chat_ended\": {\n" +
" \"duration\": 257\n" +
" }\n" +
" }\n" +
diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md
index 78f01e7a..579b9096 100644
--- a/telegrambots-spring-boot-starter/README.md
+++ b/telegrambots-spring-boot-starter/README.md
@@ -18,14 +18,14 @@ Usage
org.telegram
telegrambots-spring-boot-starter
- 5.7.1
+ 6.0.1
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-spring-boot-starter:5.7.1'
+ implementation 'org.telegram:telegrambots-spring-boot-starter:6.0.1'
```
Motivation
diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml
index 9cac41e0..12ecf4f9 100644
--- a/telegrambots-spring-boot-starter/pom.xml
+++ b/telegrambots-spring-boot-starter/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambots-spring-boot-starter
@@ -72,7 +72,7 @@
UTF-8
UTF-8
- 5.7.1
+ 6.0.1
2.6.6
1.6
diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml
index e4a53a24..e517160c 100644
--- a/telegrambots/pom.xml
+++ b/telegrambots/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 5.7.1
+ 6.0.1
telegrambots
@@ -93,7 +93,7 @@
org.telegram
telegrambots-meta
- 5.7.1
+ 6.0.1
org.projectlombok
diff --git a/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java b/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java
index 15ae6951..b364e73f 100644
--- a/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java
+++ b/telegrambots/src/main/java/org/telegram/telegrambots/util/WebhookUtils.java
@@ -102,59 +102,6 @@ public final class WebhookUtils {
}
}
- /**
- * @deprecated Use {{@link #setWebhook(DefaultAbsSender, WebhookBot, SetWebhook)}} instead
- */
- @Deprecated
- public static void setWebhook(DefaultAbsSender bot, WebhookBot webhookBot, String url, String publicCertificatePath) throws TelegramApiRequestException {
- DefaultBotOptions botOptions = bot.getOptions();
-
- try (CloseableHttpClient httpclient = TelegramHttpClientBuilder.build(botOptions)) {
- String requestUrl = bot.getBaseUrl() + SetWebhook.PATH;
-
- RequestConfig requestConfig = botOptions.getRequestConfig();
- if (requestConfig == null) {
- requestConfig = RequestConfig.copy(RequestConfig.custom().build())
- .setSocketTimeout(SOCKET_TIMEOUT)
- .setConnectTimeout(SOCKET_TIMEOUT)
- .setConnectionRequestTimeout(SOCKET_TIMEOUT).build();
- }
-
- HttpPost httppost = new HttpPost(requestUrl);
- httppost.setConfig(requestConfig);
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- builder.addTextBody(SetWebhook.URL_FIELD, getBotUrl(url, webhookBot.getBotPath()));
- if (botOptions.getMaxWebhookConnections() != null) {
- builder.addTextBody(SetWebhook.MAXCONNECTIONS_FIELD, botOptions.getMaxWebhookConnections().toString());
- }
- if (botOptions.getAllowedUpdates() != null) {
- builder.addTextBody(SetWebhook.ALLOWEDUPDATES_FIELD, new JSONArray(botOptions.getAllowedUpdates()).toString());
- }
- if (botOptions.getAllowedUpdates() != null) {
- builder.addTextBody(SetWebhook.ALLOWEDUPDATES_FIELD, new JSONArray(botOptions.getAllowedUpdates()).toString());
- }
- if (publicCertificatePath != null) {
- File certificate = new File(publicCertificatePath);
- if (certificate.exists()) {
- builder.addBinaryBody(SetWebhook.CERTIFICATE_FIELD, certificate, ContentType.TEXT_PLAIN, certificate.getName());
- }
- }
- HttpEntity multipart = builder.build();
- httppost.setEntity(multipart);
- try (CloseableHttpResponse response = httpclient.execute(httppost, botOptions.getHttpContext())) {
- String responseContent = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
- JSONObject jsonObject = new JSONObject(responseContent);
- if (!jsonObject.getBoolean(ApiConstants.RESPONSE_FIELD_OK)) {
- throw new TelegramApiRequestException("Error setting webhook", jsonObject);
- }
- }
- } catch (JSONException e) {
- throw new TelegramApiRequestException("Error deserializing setWebhook method response", e);
- } catch (IOException e) {
- throw new TelegramApiRequestException("Error executing setWebook method", e);
- }
- }
-
public static void clearWebhook(DefaultAbsSender bot) throws TelegramApiRequestException {
try {
boolean result = bot.execute(new DeleteWebhook());