diff --git a/README.md b/README.md
index 6d9be4c4..30a50ce2 100644
--- a/README.md
+++ b/README.md
@@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
org.telegram
telegrambots
- 6.4.0
+ 6.5.0
```
2. Using Gradle:
```gradle
- implementation 'org.telegram:telegrambots:6.4.0'
+ implementation 'org.telegram:telegrambots:6.5.0'
```
- 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.4.0)
- 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.4.0)
+ 3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/6.5.0)
+ 4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/6.5.0)
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 138f2352..56ab80f3 100644
--- a/TelegramBots.wiki/Changelog.md
+++ b/TelegramBots.wiki/Changelog.md
@@ -1,3 +1,6 @@
+### 6.4.0 ###
+1. Update Api version [6.5](https://core.telegram.org/bots/api-changelog#february-3-2023)
+
### 6.4.0 ###
1. Update Api version [6.4](https://core.telegram.org/bots/api-changelog#december-30-2022)
2. Bug fixing: #1159
diff --git a/TelegramBots.wiki/Getting-Started.md b/TelegramBots.wiki/Getting-Started.md
index 6f19de41..cab5cdb7 100644
--- a/TelegramBots.wiki/Getting-Started.md
+++ b/TelegramBots.wiki/Getting-Started.md
@@ -11,13 +11,13 @@ First you need to acquire the library and add it to your project. There are seve
org.telegram
telegrambots
- 6.4.0
+ 6.5.0
```
* With **Gradle**:
```gradle
- implementation 'org.telegram:telegrambots:6.4.0'
+ implementation 'org.telegram:telegrambots:6.5.0'
```
2. Don't like the **Maven Central Repository**? It can also be grabbed from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md
index 87cf3d8f..c5d46c78 100644
--- a/TelegramBots.wiki/abilities/Simple-Example.md
+++ b/TelegramBots.wiki/abilities/Simple-Example.md
@@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
org.telegram
telegrambots-abilities
- 6.4.0
+ 6.5.0
```
* **Gradle**
```gradle
- implementation 'org.telegram:telegrambots-abilities:6.4.0'
+ implementation 'org.telegram:telegrambots-abilities:6.5.0'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
diff --git a/pom.xml b/pom.xml
index 0431f940..29fa0b0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
pom
- 6.4.0
+ 6.5.0
telegrambots
diff --git a/telegrambots-abilities/README.md b/telegrambots-abilities/README.md
index a9e1cfca..c2c5d439 100644
--- a/telegrambots-abilities/README.md
+++ b/telegrambots-abilities/README.md
@@ -18,14 +18,14 @@ Usage
org.telegram
telegrambots-abilities
- 6.4.0
+ 6.5.0
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-abilities:6.4.0'
+ implementation 'org.telegram:telegrambots-abilities:6.5.0'
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
diff --git a/telegrambots-abilities/pom.xml b/telegrambots-abilities/pom.xml
index b5f6c014..6e2a7c8e 100644
--- a/telegrambots-abilities/pom.xml
+++ b/telegrambots-abilities/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambots-abilities
@@ -84,7 +84,7 @@
org.telegram
telegrambots
- 6.4.0
+ 6.5.0
org.apache.commons
diff --git a/telegrambots-chat-session-bot/README.md b/telegrambots-chat-session-bot/README.md
index 45dd93ed..debf98e8 100644
--- a/telegrambots-chat-session-bot/README.md
+++ b/telegrambots-chat-session-bot/README.md
@@ -15,14 +15,14 @@ Usage
org.telegram
telegrambots-chat-session-bot
- 6.4.0
+ 6.5.0
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-chat-session-bot:6.4.0'
+ implementation 'org.telegram:telegrambots-chat-session-bot:6.5.0'
```
Motivation
diff --git a/telegrambots-chat-session-bot/pom.xml b/telegrambots-chat-session-bot/pom.xml
index 7bc8a742..78f085d8 100644
--- a/telegrambots-chat-session-bot/pom.xml
+++ b/telegrambots-chat-session-bot/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambots-chat-session-bot
@@ -84,7 +84,7 @@
org.telegram
telegrambots
- 6.4.0
+ 6.5.0
diff --git a/telegrambots-extensions/README.md b/telegrambots-extensions/README.md
index cec60de3..3c3a33a2 100644
--- a/telegrambots-extensions/README.md
+++ b/telegrambots-extensions/README.md
@@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
org.telegram
telegrambotsextensions
- 6.4.0
+ 6.5.0
```
2. Using Gradle:
```gradle
- implementation 'org.telegram:telegrambotsextensions:6.4.0'
+ implementation 'org.telegram:telegrambotsextensions:6.5.0'
```
\ No newline at end of file
diff --git a/telegrambots-extensions/pom.xml b/telegrambots-extensions/pom.xml
index ba68eca5..36f88e59 100644
--- a/telegrambots-extensions/pom.xml
+++ b/telegrambots-extensions/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambotsextensions
@@ -75,7 +75,7 @@
org.telegram
telegrambots
- 6.4.0
+ 6.5.0
diff --git a/telegrambots-meta/pom.xml b/telegrambots-meta/pom.xml
index 1cba5f6f..a12be905 100644
--- a/telegrambots-meta/pom.xml
+++ b/telegrambots-meta/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambots-meta
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java
index f7f6b6a7..0983d526 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java
@@ -48,13 +48,20 @@ public class RestrictChatMember extends BotApiMethodBoolean {
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews";
private static final String PERMISSIONS_FIELD = "permissions";
+ private static final String USEINDEPENDENTCHATPERMISSIONS_FIELD = "use_independent_chat_permissions";
+ /**
+ * Required. Unique identifier for the chat to send the message to (Or username for channels)
+ */
@JsonProperty(CHATID_FIELD)
@NonNull
- private String chatId; ///< Required. Unique identifier for the chat to send the message to (Or username for channels)
+ private String chatId;
+ /**
+ * Required. Unique identifier of the target user
+ */
@JsonProperty(USER_ID_FIELD)
@NonNull
- private Long userId; ///< Required. Unique identifier of the target user
+ private Long userId;
/**
* Optional
* Date when restrictions will be lifted for the user, unix time.
@@ -64,8 +71,22 @@ public class RestrictChatMember extends BotApiMethodBoolean {
@JsonProperty(PERMISSIONS_FIELD)
@NonNull
private ChatPermissions permissions;
+ /**
+ * Optional.
+ * Date when restrictions will be lifted for the user, unix time.
+ * If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
+ */
@JsonProperty(UNTILDATE_FIELD)
- private Integer untilDate; ///< Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be banned forever
+ private Integer untilDate;
+ /**
+ * Optional.
+ * Pass True if chat permissions are set independently.
+ * Otherwise, the can_send_other_messages and can_add_web_page_previews permissions
+ * will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes,
+ * and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
+ */
+ @JsonProperty(USEINDEPENDENTCHATPERMISSIONS_FIELD)
+ private Boolean useIndependentChatPermissions;
@Tolerate
public void setChatId(@NonNull Long chatId) {
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java
index 1d22210b..1b3cf57c 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java
@@ -33,13 +33,29 @@ public class SetChatPermissions extends BotApiMethodBoolean {
private static final String CHAT_ID_FIELD = "chat_id";
private static final String PERMISSIONS_FIELD = "permissions";
+ private static final String USEINDEPENDENTCHATPERMISSIONS_FIELD = "use_independent_chat_permissions";
+ /**
+ * Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ */
@JsonProperty(CHAT_ID_FIELD)
@NonNull
- private String chatId; ///< Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
+ private String chatId;
+ /**
+ * New default chat permissions
+ */
@JsonProperty(PERMISSIONS_FIELD)
@NonNull
- private ChatPermissions permissions; ///< New default chat permissions
+ private ChatPermissions permissions;
+ /**
+ * Optional.
+ * Pass True if chat permissions are set independently.
+ * Otherwise, the can_send_other_messages and can_add_web_page_previews permissions
+ * will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes,
+ * and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
+ */
+ @JsonProperty(USEINDEPENDENTCHATPERMISSIONS_FIELD)
+ private Boolean useIndependentChatPermissions;
@Tolerate
public void setChatId(@NonNull Long chatId) {
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatJoinRequest.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatJoinRequest.java
index 1537c9b7..330786b1 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatJoinRequest.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatJoinRequest.java
@@ -21,6 +21,7 @@ public class ChatJoinRequest implements BotApiObject {
private static final String DATE_FIELD = "date";
private static final String BIO_FIELD = "bio";
private static final String INVITELINK_FIELD = "invite_link";
+ private static final String USERCHATID_FIELD = "user_chat_id";
/**
* Chat to which the request was sent
@@ -49,4 +50,12 @@ public class ChatJoinRequest implements BotApiObject {
*/
@JsonProperty(INVITELINK_FIELD)
private ChatInviteLink inviteLink;
+ /**
+ * Identifier of a private chat with the user who sent the join request.
+ * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
+ * @apiNote The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user.
+ */
+ @JsonProperty(USERCHATID_FIELD)
+ private Long userChatId;
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java
index 7fcccbbc..bcede8f2 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java
@@ -26,13 +26,21 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
@Builder
public class ChatPermissions implements BotApiObject {
private static final String CAN_SEND_MESSAGES_FIELD = "can_send_messages";
- private static final String CAN_SEND_MEDIA_MESSAGES_FIELD = "can_send_media_messages";
+ private static final String CANSENDAUDIOS_FIELD = "can_send_audios";
+ private static final String CANSENDDOCUMENTS_FIELD = "can_send_documents";
+ private static final String CANSENDPHOTOS_FIELD = "can_send_photos";
+ private static final String CANSENDVIDEOS_FIELD = "can_send_videos";
+ private static final String CANSENDVIDEONOTES_FIELD = "can_send_video_notes";
+ private static final String CANSENDVOICENOTES_FIELD = "can_send_voice_notes";
private static final String CAN_SEND_POLLS_FIELD = "can_send_polls";
private static final String CAN_SEND_OTHER_MESSAGES_FIELD = "can_send_other_messages";
private static final String CAN_ADD_WEB_PAGE_PREVIEWS_FIELD = "can_add_web_page_previews";
private static final String CAN_CHANGE_INFO_FIELD = "can_change_info";
private static final String CAN_INVITE_USERS_FIELD = "can_invite_users";
private static final String CAN_PIN_MESSAGES_FIELD = "can_pin_messages";
+ private static final String CANMANAGETOPICS_FIELD = "can_manage_topics";
+
+ private static final String CAN_SEND_MEDIA_MESSAGES_FIELD = "can_send_media_messages";
/**
* Optional.
@@ -41,11 +49,35 @@ public class ChatPermissions implements BotApiObject {
@JsonProperty(CAN_SEND_MESSAGES_FIELD)
private Boolean canSendMessages;
/**
- * Optional.
- * True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
+ * True, if the user is allowed to send audios
*/
- @JsonProperty(CAN_SEND_MEDIA_MESSAGES_FIELD)
- private Boolean canSendMediaMessages;
+ @JsonProperty(CANSENDAUDIOS_FIELD)
+ private Boolean canSendAudios;
+ /**
+ * True, if the user is allowed to send documents
+ */
+ @JsonProperty(CANSENDDOCUMENTS_FIELD)
+ private Boolean canSendDocuments;
+ /**
+ * True, if the user is allowed to send photos
+ */
+ @JsonProperty(CANSENDPHOTOS_FIELD)
+ private Boolean canSendPhotos;
+ /**
+ * True, if the user is allowed to send videos
+ */
+ @JsonProperty(CANSENDVIDEOS_FIELD)
+ private Boolean canSendVideos;
+ /**
+ * True, if the user is allowed to send video notes
+ */
+ @JsonProperty(CANSENDVIDEONOTES_FIELD)
+ private Boolean canSendVideoNotes;
+ /**
+ * Optional. True, if the user is allowed to send voice notes
+ */
+ @JsonProperty(CANSENDVOICENOTES_FIELD)
+ private Boolean canSendVoiceNotes;
/**
* Optional.
* True, if the user is allowed to send polls, implies can_send_messages
@@ -82,4 +114,19 @@ public class ChatPermissions implements BotApiObject {
*/
@JsonProperty(CAN_PIN_MESSAGES_FIELD)
private Boolean canPinMessages;
+ /**
+ * Optional. True, if the user is allowed to create forum topics.
+ * If omitted defaults to the value of can_pin_messages
+ */
+ @JsonProperty(CANMANAGETOPICS_FIELD)
+ private Boolean canManageTopics;
+
+ /**
+ * Optional.
+ * True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
+ * @deprecated Use individual permissions
+ */
+ @JsonProperty(CAN_SEND_MEDIA_MESSAGES_FIELD)
+ @Deprecated
+ private Boolean canSendMediaMessages;
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java
new file mode 100644
index 00000000..1aa7d3ba
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java
@@ -0,0 +1,41 @@
+package org.telegram.telegrambots.meta.api.objects;
+
+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 org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+
+/**
+ * This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button.
+ * @author Ruben Bermudez
+ * @version 6.5
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class ChatShared implements BotApiObject {
+
+ private static final String REQUESTID_FIELD = "request_id";
+ private static final String CHATID_FIELD = "chat_id";
+
+ /**
+ * Identifier of the request
+ */
+ @JsonProperty(REQUESTID_FIELD)
+ private String requestId;
+ /**
+ * Identifier of the shared chat.
+ * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
+ * @apiNote The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.
+ */
+ @JsonProperty(CHATID_FIELD)
+ private Long chatId;
+}
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 7356cfe5..f1cdc0dd 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
@@ -113,6 +113,8 @@ public class Message implements BotApiObject {
private static final String GENERALFORUMTOPICUNHIDDEN_FIELD = "general_forum_topic_unhidden";
private static final String WRITEACCESSALLOWED_FIELD = "write_access_allowed";
private static final String HASMEDIASPOILER_FIELD = "has_media_spoiler";
+ private static final String USERSHARED_FIELD = "user_shared";
+ private static final String CHATSHARED_FIELD = "chat_shared";
/**
* Integer Unique message identifier
@@ -541,6 +543,18 @@ public class Message implements BotApiObject {
*/
@JsonProperty(HASMEDIASPOILER_FIELD)
private Boolean hasMediaSpoiler;
+ /**
+ * Optional.
+ * Service message: a user was shared with the bot
+ */
+ @JsonProperty(USERSHARED_FIELD)
+ private UserShared userShared;
+ /**
+ * Optional.
+ * Service message: a chat was shared with the bot
+ */
+ @JsonProperty(CHATSHARED_FIELD)
+ private ChatShared chatShared;
public List getEntities() {
if (entities != null) {
@@ -753,4 +767,14 @@ public class Message implements BotApiObject {
private boolean hasForumTopicReopened() {
return forumTopicReopened != null;
}
+
+ @JsonIgnore
+ private boolean hasUserShared() {
+ return userShared != null;
+ }
+
+ @JsonIgnore
+ private boolean hasChatShared() {
+ return chatShared != null;
+ }
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java
new file mode 100644
index 00000000..b9781a5b
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java
@@ -0,0 +1,41 @@
+package org.telegram.telegrambots.meta.api.objects;
+
+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 org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+
+/**
+ * This object contains information about the user whose identifier was shared with the bot using a KeyboardButtonRequestUser button.
+ * @author Ruben Bermudez
+ * @version 6.5
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserShared implements BotApiObject {
+
+ private static final String REQUESTID_FIELD = "request_id";
+ private static final String USERID_FIELD = "user_id";
+
+ /**
+ * Identifier of the request
+ */
+ @JsonProperty(REQUESTID_FIELD)
+ private String requestId;
+ /**
+ * Identifier of the shared user.
+ * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
+ * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
+ * @apiNote The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.
+ */
+ @JsonProperty(USERID_FIELD)
+ private Long userId;
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java
index a01c1162..80c4cd03 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/adminrights/ChatAdministratorRights.java
@@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.objects.adminrights;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
/**
* Represents rights of an administrator in a chat.
@@ -16,7 +17,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
@NoArgsConstructor
@AllArgsConstructor
@Builder
-public class ChatAdministratorRights implements BotApiObject {
+public class ChatAdministratorRights implements BotApiObject, Validable {
private static final String ISANONYMOUS_FIELD = "is_anonymous";
private static final String CANMANAGECHAT_FIELD = "can_manage_chat";
@@ -35,6 +36,7 @@ public class ChatAdministratorRights implements BotApiObject {
* True, if the user's presence in the chat is hidden
*/
@JsonProperty(ISANONYMOUS_FIELD)
+ @NonNull
private Boolean isAnonymous;
/**
* True, if the administrator can access the chat event log, chat statistics,
@@ -43,21 +45,25 @@ public class ChatAdministratorRights implements BotApiObject {
* Implied by any other administrator privilege
*/
@JsonProperty(CANMANAGECHAT_FIELD)
+ @NonNull
private Boolean canManageChat;
/**
* True, if the administrator can delete messages of other users
*/
@JsonProperty(CANDELETEMESSAGES_FIELD)
+ @NonNull
private Boolean canDeleteMessages;
/**
* True, if the administrator can manage video chats
*/
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
+ @NonNull
private Boolean canManageVideoChats;
/**
* True, if the administrator can restrict, ban or unban chat members
*/
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
+ @NonNull
private Boolean canRestrictMembers;
/**
* True, if the administrator can add new administrators with a subset of
@@ -65,16 +71,19 @@ public class ChatAdministratorRights implements BotApiObject {
* directly or indirectly (promoted by administrators that were appointed by the user)
*/
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
+ @NonNull
private Boolean canPromoteMembers;
/**
* True, if the user is allowed to change the chat title, photo and other settings
*/
@JsonProperty(CANCHANGEINFO_FIELD)
+ @NonNull
private Boolean canChangeInfo;
/**
* True, if the user is allowed to invite new users to the chat
*/
@JsonProperty(CANINVITEUSERS_FIELD)
+ @NonNull
private Boolean canInviteUsers;
/**
* Optional.
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java
index 4d190885..3d4addc7 100644
--- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberRestricted.java
@@ -31,16 +31,23 @@ public class ChatMemberRestricted implements ChatMember {
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
private static final String ISMEMBER_FIELD = "is_member";
- 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 CANSENDMESSAGES_FIELD = "can_send_messages";
- private static final String CANSENDMEDIAMESSAGES_FIELD = "can_send_media_messages";
+ private static final String CANSENDAUDIOS_FIELD = "can_send_audios";
+ private static final String CANSENDDOCUMENTS_FIELD = "can_send_documents";
+ private static final String CANSENDPHOTOS_FIELD = "can_send_photos";
+ private static final String CANSENDVIDEOS_FIELD = "can_send_videos";
+ private static final String CANSENDVIDEONOTES_FIELD = "can_send_video_notes";
+ private static final String CANSENDVOICENOTES_FIELD = "can_send_voice_notes";
private static final String CANSENDPOLLS_FIELD = "can_send_polls";
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
private static final String CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews";
- private static final String UNTILDATE_FIELD = "until_date";
+ 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 CANMANAGETOPICS_FIELD = "can_manage_topics";
+ private static final String UNTILDATE_FIELD = "until_date";
+
+ private static final String CANSENDMEDIAMESSAGES_FIELD = "can_send_media_messages";
/**
* The member's status in the chat, always “restricted”
@@ -57,31 +64,41 @@ public class ChatMemberRestricted implements ChatMember {
*/
@JsonProperty(ISMEMBER_FIELD)
private Boolean isMember;
- /**
- * True, if the user is allowed to change the chat title, photo and other settings
- */
- @JsonProperty(CANCHANGEINFO_FIELD)
- private Boolean canChangeInfo;
- /**
- * True, if the user is allowed to invite new users to the chat
- */
- @JsonProperty(CANINVITEUSERS_FIELD)
- private Boolean canInviteUsers;
- /**
- * True, if the user is allowed to pin messages; groups and supergroups only
- */
- @JsonProperty(CANPINMESSAGES_FIELD)
- private Boolean canPinMessages;
/**
* True, if the user is allowed to send text messages, contacts, locations and venues
*/
@JsonProperty(CANSENDMESSAGES_FIELD)
private Boolean canSendMessages;
/**
- * True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
+ * True, if the user is allowed to send audios
*/
- @JsonProperty(CANSENDMEDIAMESSAGES_FIELD)
- private Boolean canSendMediaMessages;
+ @JsonProperty(CANSENDAUDIOS_FIELD)
+ private Boolean canSendAudios;
+ /**
+ * True, if the user is allowed to send documents
+ */
+ @JsonProperty(CANSENDDOCUMENTS_FIELD)
+ private Boolean canSendDocuments;
+ /**
+ * True, if the user is allowed to send photos
+ */
+ @JsonProperty(CANSENDPHOTOS_FIELD)
+ private Boolean canSendPhotos;
+ /**
+ * True, if the user is allowed to send videos
+ */
+ @JsonProperty(CANSENDVIDEOS_FIELD)
+ private Boolean canSendVideos;
+ /**
+ * True, if the user is allowed to send video notes
+ */
+ @JsonProperty(CANSENDVIDEONOTES_FIELD)
+ private Boolean canSendVideoNotes;
+ /**
+ * Optional. True, if the user is allowed to send voice notes
+ */
+ @JsonProperty(CANSENDVOICENOTES_FIELD)
+ private Boolean canSendVoiceNotes;
/**
* True, if the user is allowed to send polls
*/
@@ -98,13 +115,36 @@ public class ChatMemberRestricted implements ChatMember {
@JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
private Boolean canAddWebpagePreviews;
/**
- * Date when restrictions will be lifted for this user; unix time
+ * True, if the user is allowed to change the chat title, photo and other settings
*/
- @JsonProperty(UNTILDATE_FIELD)
- private Integer untilDate;
+ @JsonProperty(CANCHANGEINFO_FIELD)
+ private Boolean canChangeInfo;
+ /**
+ * True, if the user is allowed to invite new users to the chat
+ */
+ @JsonProperty(CANINVITEUSERS_FIELD)
+ private Boolean canInviteUsers;
+ /**
+ * True, if the user is allowed to pin messages; groups and supergroups only
+ */
+ @JsonProperty(CANPINMESSAGES_FIELD)
+ private Boolean canPinMessages;
/**
* True, if the user is allowed to create forum topics
*/
@JsonProperty(CANMANAGETOPICS_FIELD)
private Boolean canManageTopics;
+ /**
+ * Date when restrictions will be lifted for this user; unix time
+ */
+ @JsonProperty(UNTILDATE_FIELD)
+ private Integer untilDate;
+
+ /**
+ * True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
+ * @deprecated Use individual permissions instead
+ */
+ @JsonProperty(CANSENDMEDIAMESSAGES_FIELD)
+ @Deprecated
+ private Boolean canSendMediaMessages;
}
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 63c26b82..2e2e949c 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
@@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
* after 9 April, 2016. Older clients will ignore them.
* @apiNote request_poll option will only work in Telegram versions released after 1X January, 2020.
* Older clients will receive unsupported message.
+ * @apiNote The optional fields web_app, request_user, request_chat, request_contact, request_location,
+ * and request_poll are mutually exclusive
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@@ -42,6 +44,8 @@ public class KeyboardButton implements Validable, BotApiObject {
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";
+ private static final String REQUESTUSER_FIELD = "request_user";
+ private static final String REQUESTCHAT_FIELD = "request_chat";
/**
* 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
@@ -79,22 +83,51 @@ public class KeyboardButton implements Validable, BotApiObject {
@JsonProperty(WEBAPP_FIELD)
private WebAppInfo webApp;
+ /**
+ * Optional.
+ * If specified, pressing the button will open a list of suitable users.
+ * Tapping on any user will send their identifier to the bot in a “user_shared” service message.
+ * Available in private chats only.
+ */
+ @JsonProperty(REQUESTUSER_FIELD)
+ private KeyboardButtonRequestUser requestUser;
+
+ /**
+ * Optional.
+ * If specified, pressing the button will open a list of suitable chats.
+ * Tapping on a chat will send its identifier to the bot in a “chat_shared” service message.
+ * Available in private chats only.
+ */
+ @JsonProperty(REQUESTCHAT_FIELD)
+ private KeyboardButtonRequestChat requestChat;
+
@Override
public void validate() throws TelegramApiValidationException {
if (text.isEmpty()) {
throw new TelegramApiValidationException("Text parameter can't be empty", this);
}
- if (requestContact != null && requestLocation != null && requestContact && requestLocation) {
- throw new TelegramApiValidationException("Cant request contact and location at the same time", this);
- }
- if (requestContact != null && requestPoll != null && requestContact) {
- throw new TelegramApiValidationException("Cant request contact and poll at the same time", this);
- }
- if (requestLocation != null && requestPoll != null && requestLocation) {
- throw new TelegramApiValidationException("Cant request location and poll at the same time", this);
+
+ int requestsProvided = 0;
+ requestsProvided += (requestContact == null ? 0 : 1);
+ requestsProvided += (requestLocation == null ? 0 : 1);
+ requestsProvided += (requestPoll == null ? 0 : 1);
+ requestsProvided += (webApp == null ? 0 : 1);
+ requestsProvided += (requestUser == null ? 0 : 1);
+ requestsProvided += (requestChat == null ? 0 : 1);
+ if (requestsProvided > 1) {
+ throw new TelegramApiValidationException("The optional fields web_app, request_user, request_chat, request_contact, request_location, and request_poll are mutually exclusive", this);
}
if (webApp != null) {
webApp.validate();
}
+ if (requestPoll != null) {
+ requestPoll.validate();
+ }
+ if (requestUser != null) {
+ requestUser.validate();
+ }
+ if (requestChat != null) {
+ requestChat.validate();
+ }
}
}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java
new file mode 100644
index 00000000..ba6833d7
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestChat.java
@@ -0,0 +1,113 @@
+package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.api.objects.adminrights.ChatAdministratorRights;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.5
+ *
+ * This object defines the criteria used to request a suitable chat.
+ * The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
+public class KeyboardButtonRequestChat implements Validable, BotApiObject {
+
+ private static final String REQUESTID_FIELD = "request_id";
+ private static final String CHATISCHANNEL_FIELD = "chat_is_channel";
+ private static final String CHATISFORUM_FIELD = "chat_is_forum";
+ private static final String CHATHASUSERNAME_FIELD = "chat_has_username";
+ private static final String CHATISCREATED_FIELD = "chat_is_created";
+ private static final String USERADMINISTRATORRIGHTS_FIELD = "user_administrator_rights";
+ private static final String BOTADMINISTRATORRIGHTS_FIELD = "bot_administrator_rights";
+ private static final String BOTISMEMBER_FIELD = "bot_is_member";
+
+ /**
+ * Signed 32-bit identifier of the request
+ */
+ @JsonProperty(REQUESTID_FIELD)
+ @NonNull
+ private String requestId;
+ /**
+ * Pass True to request a channel chat, pass False to request a group or a supergroup chat.
+ */
+ @JsonProperty(CHATISCHANNEL_FIELD)
+ @NonNull
+ private Boolean chatIsChannel;
+ /**
+ * Optional.
+ * Pass True to request a forum supergroup, pass False to request a non-forum chat.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(CHATISFORUM_FIELD)
+ private Boolean chatIsForum;
+ /**
+ * Optional.
+ * Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(CHATHASUSERNAME_FIELD)
+ private Boolean chatHasUsername;
+ /**
+ * Optional.
+ * Pass True to request a chat owned by the user.
+ * Otherwise, no additional restrictions are applied.
+ */
+ @JsonProperty(CHATISCREATED_FIELD)
+ private Boolean chatIsCreated;
+ /**
+ * Optional.
+ * A JSON-serialized object listing the required administrator rights of the user in the chat.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(USERADMINISTRATORRIGHTS_FIELD)
+ private ChatAdministratorRights userAdministratorRights;
+ /**
+ * Optional.
+ * A JSON-serialized object listing the required administrator rights of the bot in the chat.
+ * The rights must be a subset of user_administrator_rights.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(BOTADMINISTRATORRIGHTS_FIELD)
+ private ChatAdministratorRights botAdministratorRights;
+ /**
+ * Optional.
+ * Pass True to request a chat with the bot as a member.
+ * Otherwise, no additional restrictions are applied.
+ */
+ @JsonProperty(BOTISMEMBER_FIELD)
+ private Boolean botIsMember;
+
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (requestId.isEmpty()) {
+ throw new TelegramApiValidationException("Text parameter can't be empty", this);
+ }
+ if (userAdministratorRights != null) {
+ userAdministratorRights.validate();
+ }
+ if (botAdministratorRights != null) {
+ botAdministratorRights.validate();
+ }
+ }
+}
diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java
new file mode 100644
index 00000000..e238f864
--- /dev/null
+++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/replykeyboard/buttons/KeyboardButtonRequestUser.java
@@ -0,0 +1,66 @@
+package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
+import org.telegram.telegrambots.meta.api.interfaces.Validable;
+import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
+
+/**
+ * @author Ruben Bermudez
+ * @version 6.5
+ *
+ * This object defines the criteria used to request a suitable user.
+ * The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
+ */
+@EqualsAndHashCode(callSuper = false)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+@Builder
+public class KeyboardButtonRequestUser implements Validable, BotApiObject {
+
+ private static final String REQUESTID_FIELD = "request_id";
+ private static final String USERISBOT_FIELD = "user_is_bot";
+ private static final String USERISPREMIUM_FIELD = "user_is_premium";
+
+ /**
+ * Signed 32-bit identifier of the request
+ */
+ @JsonProperty(REQUESTID_FIELD)
+ @NonNull
+ private String requestId;
+ /**
+ * Optional.
+ * Pass True to request a bot, pass False to request a regular user.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(USERISBOT_FIELD)
+ private Boolean userIsBot;
+ /**
+ * Optional.
+ * Pass True to request a premium user, pass False to request a non-premium user.
+ * If not specified, no additional restrictions are applied.
+ */
+ @JsonProperty(USERISPREMIUM_FIELD)
+ private Boolean userIsPremium;
+
+
+ @Override
+ public void validate() throws TelegramApiValidationException {
+ if (requestId.isEmpty()) {
+ throw new TelegramApiValidationException("Text parameter can't be empty", this);
+ }
+ }
+}
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
index 8a060543..a0fd39b6 100644
--- 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
@@ -39,6 +39,13 @@ public class SetMyDefaultAdministratorRightsTest {
.rights(ChatAdministratorRights
.builder()
.isAnonymous(true)
+ .canManageChat(false)
+ .canDeleteMessages(false)
+ .canManageVideoChats(false)
+ .canRestrictMembers(false)
+ .canPromoteMembers(true)
+ .canChangeInfo(true)
+ .canInviteUsers(false)
.build())
.build();
assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
diff --git a/telegrambots-spring-boot-starter/README.md b/telegrambots-spring-boot-starter/README.md
index a6e25263..b23762b3 100644
--- a/telegrambots-spring-boot-starter/README.md
+++ b/telegrambots-spring-boot-starter/README.md
@@ -18,14 +18,14 @@ Usage
org.telegram
telegrambots-spring-boot-starter
- 6.4.0
+ 6.5.0
```
**Gradle**
```gradle
- implementation 'org.telegram:telegrambots-spring-boot-starter:6.4.0'
+ implementation 'org.telegram:telegrambots-spring-boot-starter:6.5.0'
```
Motivation
diff --git a/telegrambots-spring-boot-starter/pom.xml b/telegrambots-spring-boot-starter/pom.xml
index 28d95491..7103c81e 100644
--- a/telegrambots-spring-boot-starter/pom.xml
+++ b/telegrambots-spring-boot-starter/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambots-spring-boot-starter
@@ -70,7 +70,7 @@
UTF-8
UTF-8
- 6.4.0
+ 6.5.0
2.7.5
1.6
diff --git a/telegrambots/pom.xml b/telegrambots/pom.xml
index 48a199ae..b343201b 100644
--- a/telegrambots/pom.xml
+++ b/telegrambots/pom.xml
@@ -7,7 +7,7 @@
org.telegram
Bots
- 6.4.0
+ 6.5.0
telegrambots
@@ -91,7 +91,7 @@
org.telegram
telegrambots-meta
- 6.4.0
+ 6.5.0
org.projectlombok