Api version 6.5
This commit is contained in:
parent
402a4c46ea
commit
61eb857248
@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```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)
|
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.4.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`.
|
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
### <a id="6.4.0"></a>6.4.0 ###
|
||||||
|
1. Update Api version [6.5](https://core.telegram.org/bots/api-changelog#february-3-2023)
|
||||||
|
|
||||||
### <a id="6.4.0"></a>6.4.0 ###
|
### <a id="6.4.0"></a>6.4.0 ###
|
||||||
1. Update Api version [6.4](https://core.telegram.org/bots/api-changelog#december-30-2022)
|
1. Update Api version [6.4](https://core.telegram.org/bots/api-changelog#december-30-2022)
|
||||||
2. Bug fixing: #1159
|
2. Bug fixing: #1159
|
||||||
|
@ -11,13 +11,13 @@ First you need to acquire the library and add it to your project. There are seve
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* With **Gradle**:
|
* With **Gradle**:
|
||||||
|
|
||||||
```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).
|
2. Don't like the **Maven Central Repository**? It can also be grabbed from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).
|
||||||
|
@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* **Gradle**
|
* **Gradle**
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-abilities:6.4.0'
|
implementation 'org.telegram:telegrambots-abilities:6.5.0'
|
||||||
```
|
```
|
||||||
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>telegrambots</module>
|
<module>telegrambots</module>
|
||||||
|
@ -18,14 +18,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```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)
|
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
@ -15,14 +15,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-chat-session-bot:6.4.0'
|
implementation 'org.telegram:telegrambots-chat-session-bot:6.5.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-chat-session-bot</artifactId>
|
<artifactId>telegrambots-chat-session-bot</artifactId>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
|
||||||
|
@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambotsextensions:6.4.0'
|
implementation 'org.telegram:telegrambotsextensions:6.5.0'
|
||||||
```
|
```
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
|
@ -48,13 +48,20 @@ public class RestrictChatMember extends BotApiMethodBoolean {
|
|||||||
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
|
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 CANADDWEBPAGEPREVIEWS_FIELD = "can_add_web_page_previews";
|
||||||
private static final String PERMISSIONS_FIELD = "permissions";
|
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)
|
@JsonProperty(CHATID_FIELD)
|
||||||
@NonNull
|
@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)
|
@JsonProperty(USER_ID_FIELD)
|
||||||
@NonNull
|
@NonNull
|
||||||
private Long userId; ///< Required. Unique identifier of the target user
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
* Optional
|
* Optional
|
||||||
* Date when restrictions will be lifted for the user, unix time.
|
* Date when restrictions will be lifted for the user, unix time.
|
||||||
@ -64,8 +71,22 @@ public class RestrictChatMember extends BotApiMethodBoolean {
|
|||||||
@JsonProperty(PERMISSIONS_FIELD)
|
@JsonProperty(PERMISSIONS_FIELD)
|
||||||
@NonNull
|
@NonNull
|
||||||
private ChatPermissions permissions;
|
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)
|
@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
|
@Tolerate
|
||||||
public void setChatId(@NonNull Long chatId) {
|
public void setChatId(@NonNull Long chatId) {
|
||||||
|
@ -33,13 +33,29 @@ public class SetChatPermissions extends BotApiMethodBoolean {
|
|||||||
|
|
||||||
private static final String CHAT_ID_FIELD = "chat_id";
|
private static final String CHAT_ID_FIELD = "chat_id";
|
||||||
private static final String PERMISSIONS_FIELD = "permissions";
|
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)
|
@JsonProperty(CHAT_ID_FIELD)
|
||||||
@NonNull
|
@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)
|
@JsonProperty(PERMISSIONS_FIELD)
|
||||||
@NonNull
|
@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
|
@Tolerate
|
||||||
public void setChatId(@NonNull Long chatId) {
|
public void setChatId(@NonNull Long chatId) {
|
||||||
|
@ -21,6 +21,7 @@ public class ChatJoinRequest implements BotApiObject {
|
|||||||
private static final String DATE_FIELD = "date";
|
private static final String DATE_FIELD = "date";
|
||||||
private static final String BIO_FIELD = "bio";
|
private static final String BIO_FIELD = "bio";
|
||||||
private static final String INVITELINK_FIELD = "invite_link";
|
private static final String INVITELINK_FIELD = "invite_link";
|
||||||
|
private static final String USERCHATID_FIELD = "user_chat_id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chat to which the request was sent
|
* Chat to which the request was sent
|
||||||
@ -49,4 +50,12 @@ public class ChatJoinRequest implements BotApiObject {
|
|||||||
*/
|
*/
|
||||||
@JsonProperty(INVITELINK_FIELD)
|
@JsonProperty(INVITELINK_FIELD)
|
||||||
private ChatInviteLink inviteLink;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,21 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
|||||||
@Builder
|
@Builder
|
||||||
public class ChatPermissions implements BotApiObject {
|
public class ChatPermissions implements BotApiObject {
|
||||||
private static final String CAN_SEND_MESSAGES_FIELD = "can_send_messages";
|
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_POLLS_FIELD = "can_send_polls";
|
||||||
private static final String CAN_SEND_OTHER_MESSAGES_FIELD = "can_send_other_messages";
|
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_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_CHANGE_INFO_FIELD = "can_change_info";
|
||||||
private static final String CAN_INVITE_USERS_FIELD = "can_invite_users";
|
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 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.
|
* Optional.
|
||||||
@ -41,11 +49,35 @@ public class ChatPermissions implements BotApiObject {
|
|||||||
@JsonProperty(CAN_SEND_MESSAGES_FIELD)
|
@JsonProperty(CAN_SEND_MESSAGES_FIELD)
|
||||||
private Boolean canSendMessages;
|
private Boolean canSendMessages;
|
||||||
/**
|
/**
|
||||||
* Optional.
|
* True, if the user is allowed to send audios
|
||||||
* True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
|
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CAN_SEND_MEDIA_MESSAGES_FIELD)
|
@JsonProperty(CANSENDAUDIOS_FIELD)
|
||||||
private Boolean canSendMediaMessages;
|
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.
|
* Optional.
|
||||||
* True, if the user is allowed to send polls, implies can_send_messages
|
* 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)
|
@JsonProperty(CAN_PIN_MESSAGES_FIELD)
|
||||||
private Boolean canPinMessages;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -113,6 +113,8 @@ public class Message implements BotApiObject {
|
|||||||
private static final String GENERALFORUMTOPICUNHIDDEN_FIELD = "general_forum_topic_unhidden";
|
private static final String GENERALFORUMTOPICUNHIDDEN_FIELD = "general_forum_topic_unhidden";
|
||||||
private static final String WRITEACCESSALLOWED_FIELD = "write_access_allowed";
|
private static final String WRITEACCESSALLOWED_FIELD = "write_access_allowed";
|
||||||
private static final String HASMEDIASPOILER_FIELD = "has_media_spoiler";
|
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
|
* Integer Unique message identifier
|
||||||
@ -541,6 +543,18 @@ public class Message implements BotApiObject {
|
|||||||
*/
|
*/
|
||||||
@JsonProperty(HASMEDIASPOILER_FIELD)
|
@JsonProperty(HASMEDIASPOILER_FIELD)
|
||||||
private Boolean hasMediaSpoiler;
|
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<MessageEntity> getEntities() {
|
public List<MessageEntity> getEntities() {
|
||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
@ -753,4 +767,14 @@ public class Message implements BotApiObject {
|
|||||||
private boolean hasForumTopicReopened() {
|
private boolean hasForumTopicReopened() {
|
||||||
return forumTopicReopened != null;
|
return forumTopicReopened != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private boolean hasUserShared() {
|
||||||
|
return userShared != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private boolean hasChatShared() {
|
||||||
|
return chatShared != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -3,6 +3,7 @@ package org.telegram.telegrambots.meta.api.objects.adminrights;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
||||||
|
import org.telegram.telegrambots.meta.api.interfaces.Validable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents rights of an administrator in a chat.
|
* Represents rights of an administrator in a chat.
|
||||||
@ -16,7 +17,7 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatAdministratorRights implements BotApiObject {
|
public class ChatAdministratorRights implements BotApiObject, Validable {
|
||||||
|
|
||||||
private static final String ISANONYMOUS_FIELD = "is_anonymous";
|
private static final String ISANONYMOUS_FIELD = "is_anonymous";
|
||||||
private static final String CANMANAGECHAT_FIELD = "can_manage_chat";
|
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
|
* True, if the user's presence in the chat is hidden
|
||||||
*/
|
*/
|
||||||
@JsonProperty(ISANONYMOUS_FIELD)
|
@JsonProperty(ISANONYMOUS_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean isAnonymous;
|
private Boolean isAnonymous;
|
||||||
/**
|
/**
|
||||||
* True, if the administrator can access the chat event log, chat statistics,
|
* 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
|
* Implied by any other administrator privilege
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANMANAGECHAT_FIELD)
|
@JsonProperty(CANMANAGECHAT_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canManageChat;
|
private Boolean canManageChat;
|
||||||
/**
|
/**
|
||||||
* True, if the administrator can delete messages of other users
|
* True, if the administrator can delete messages of other users
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANDELETEMESSAGES_FIELD)
|
@JsonProperty(CANDELETEMESSAGES_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canDeleteMessages;
|
private Boolean canDeleteMessages;
|
||||||
/**
|
/**
|
||||||
* True, if the administrator can manage video chats
|
* True, if the administrator can manage video chats
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
|
@JsonProperty(CANMANAGEVIDEOCHATS_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canManageVideoChats;
|
private Boolean canManageVideoChats;
|
||||||
/**
|
/**
|
||||||
* True, if the administrator can restrict, ban or unban chat members
|
* True, if the administrator can restrict, ban or unban chat members
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
|
@JsonProperty(CANRESTRICTMEMBERS_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canRestrictMembers;
|
private Boolean canRestrictMembers;
|
||||||
/**
|
/**
|
||||||
* True, if the administrator can add new administrators with a subset of
|
* 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)
|
* directly or indirectly (promoted by administrators that were appointed by the user)
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
|
@JsonProperty(CANPROMOTEMEMBERS_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canPromoteMembers;
|
private Boolean canPromoteMembers;
|
||||||
/**
|
/**
|
||||||
* True, if the user is allowed to change the chat title, photo and other settings
|
* True, if the user is allowed to change the chat title, photo and other settings
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANCHANGEINFO_FIELD)
|
@JsonProperty(CANCHANGEINFO_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canChangeInfo;
|
private Boolean canChangeInfo;
|
||||||
/**
|
/**
|
||||||
* True, if the user is allowed to invite new users to the chat
|
* True, if the user is allowed to invite new users to the chat
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANINVITEUSERS_FIELD)
|
@JsonProperty(CANINVITEUSERS_FIELD)
|
||||||
|
@NonNull
|
||||||
private Boolean canInviteUsers;
|
private Boolean canInviteUsers;
|
||||||
/**
|
/**
|
||||||
* Optional.
|
* Optional.
|
||||||
|
@ -31,16 +31,23 @@ public class ChatMemberRestricted implements ChatMember {
|
|||||||
private static final String STATUS_FIELD = "status";
|
private static final String STATUS_FIELD = "status";
|
||||||
private static final String USER_FIELD = "user";
|
private static final String USER_FIELD = "user";
|
||||||
private static final String ISMEMBER_FIELD = "is_member";
|
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 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 CANSENDPOLLS_FIELD = "can_send_polls";
|
||||||
private static final String CANSENDOTHERMESSAGES_FIELD = "can_send_other_messages";
|
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 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 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”
|
* The member's status in the chat, always “restricted”
|
||||||
@ -57,31 +64,41 @@ public class ChatMemberRestricted implements ChatMember {
|
|||||||
*/
|
*/
|
||||||
@JsonProperty(ISMEMBER_FIELD)
|
@JsonProperty(ISMEMBER_FIELD)
|
||||||
private Boolean isMember;
|
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
|
* True, if the user is allowed to send text messages, contacts, locations and venues
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANSENDMESSAGES_FIELD)
|
@JsonProperty(CANSENDMESSAGES_FIELD)
|
||||||
private Boolean canSendMessages;
|
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)
|
@JsonProperty(CANSENDAUDIOS_FIELD)
|
||||||
private Boolean canSendMediaMessages;
|
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
|
* True, if the user is allowed to send polls
|
||||||
*/
|
*/
|
||||||
@ -98,13 +115,36 @@ public class ChatMemberRestricted implements ChatMember {
|
|||||||
@JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
|
@JsonProperty(CANADDWEBPAGEPREVIEWS_FIELD)
|
||||||
private Boolean canAddWebpagePreviews;
|
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)
|
@JsonProperty(CANCHANGEINFO_FIELD)
|
||||||
private Integer untilDate;
|
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
|
* True, if the user is allowed to create forum topics
|
||||||
*/
|
*/
|
||||||
@JsonProperty(CANMANAGETOPICS_FIELD)
|
@JsonProperty(CANMANAGETOPICS_FIELD)
|
||||||
private Boolean canManageTopics;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
|||||||
* after 9 April, 2016. Older clients will ignore them.
|
* after 9 April, 2016. Older clients will ignore them.
|
||||||
* @apiNote request_poll option will only work in Telegram versions released after 1X January, 2020.
|
* @apiNote request_poll option will only work in Telegram versions released after 1X January, 2020.
|
||||||
* Older clients will receive unsupported message.
|
* 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)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Getter
|
@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_LOCATION_FIELD = "request_location";
|
||||||
private static final String REQUEST_POLL_FIELD = "request_poll";
|
private static final String REQUEST_POLL_FIELD = "request_poll";
|
||||||
private static final String WEBAPP_FIELD = "web_app";
|
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.
|
* 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
|
* 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)
|
@JsonProperty(WEBAPP_FIELD)
|
||||||
private WebAppInfo webApp;
|
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
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
throw new TelegramApiValidationException("Text parameter can't be empty", this);
|
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);
|
int requestsProvided = 0;
|
||||||
}
|
requestsProvided += (requestContact == null ? 0 : 1);
|
||||||
if (requestContact != null && requestPoll != null && requestContact) {
|
requestsProvided += (requestLocation == null ? 0 : 1);
|
||||||
throw new TelegramApiValidationException("Cant request contact and poll at the same time", this);
|
requestsProvided += (requestPoll == null ? 0 : 1);
|
||||||
}
|
requestsProvided += (webApp == null ? 0 : 1);
|
||||||
if (requestLocation != null && requestPoll != null && requestLocation) {
|
requestsProvided += (requestUser == null ? 0 : 1);
|
||||||
throw new TelegramApiValidationException("Cant request location and poll at the same time", this);
|
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) {
|
if (webApp != null) {
|
||||||
webApp.validate();
|
webApp.validate();
|
||||||
}
|
}
|
||||||
|
if (requestPoll != null) {
|
||||||
|
requestPoll.validate();
|
||||||
|
}
|
||||||
|
if (requestUser != null) {
|
||||||
|
requestUser.validate();
|
||||||
|
}
|
||||||
|
if (requestChat != null) {
|
||||||
|
requestChat.validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,13 @@ public class SetMyDefaultAdministratorRightsTest {
|
|||||||
.rights(ChatAdministratorRights
|
.rights(ChatAdministratorRights
|
||||||
.builder()
|
.builder()
|
||||||
.isAnonymous(true)
|
.isAnonymous(true)
|
||||||
|
.canManageChat(false)
|
||||||
|
.canDeleteMessages(false)
|
||||||
|
.canManageVideoChats(false)
|
||||||
|
.canRestrictMembers(false)
|
||||||
|
.canPromoteMembers(true)
|
||||||
|
.canChangeInfo(true)
|
||||||
|
.canInviteUsers(false)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
|
assertEquals("setMyDefaultAdministratorRights", setMyDefaultAdministratorRights.getMethod());
|
||||||
|
@ -18,14 +18,14 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'org.telegram:telegrambots-spring-boot-starter:6.4.0'
|
implementation 'org.telegram:telegrambots-spring-boot-starter:6.5.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<telegrambots.version>6.4.0</telegrambots.version>
|
<telegrambots.version>6.5.0</telegrambots.version>
|
||||||
<spring-boot.version>2.7.5</spring-boot.version>
|
<spring-boot.version>2.7.5</spring-boot.version>
|
||||||
|
|
||||||
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
@ -91,7 +91,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
<version>6.4.0</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user