Merge pull request #992 from rubenlagus/dev

Dev
This commit is contained in:
Ruben Bermudez 2021-11-06 16:19:45 +00:00 committed by GitHub
commit 3412e0dd48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 315 additions and 51 deletions

View File

@ -13,6 +13,10 @@ notifications:
secure: "jC7dK/x67ONWQoeLZg4HfW0mHhcjDerJjsLLkrbcpltiqAbw2p7XfY8Pk4zHoD72a+5o6WKu5WvYvZ4OdldnjP8Y6ZUbliQ5RG3olg3gFDoe0+sc3geeb4HRYVcdI20O0z4Bup/qO0ZihxPBc0D5IpHmFxlaqlZG0WeST4CicU8PNnBh6aX9/VMrwXhkMb2vfzmjmIhMbx/uK5+93bnk/vR5Uwu00/Yd2cTAAWMaqK1MRdtR0WLbxlUNsprEfCjYiH3n9XZnlKXs6cLC8EOU436Wx7aepiAszW0wWFMe/7nVqOqztrQiKNvL0qXYwlQf0BLechJdt458EopL9QCu687TNDFYvg1yERAmCRiaayYZcX3PbUSMr6H5Q+Odntjs3XKyzfgSqqlkgf/SAND5jny1/1uteVoplZmFXuZFIiK4H8Rl2ezy1/8pnbp+JD3YEfiA2NuRjlou1BZXyMhiqqVXbrJqk/tXF6yZSkDlYJfNsWzRCGfra4B6JjEvUP927chIFm1ii3dgNstXDo1evV46+OQQO4HKvMPdtU2FPvWpPlkTxnmpZRZjB+bjmybluJdWT3E+e1C3wm7YbRe3vporhpfNPlnod6M0G10y9CKzl9Fbcku6X1FtM+IoPO/aqZ8S4/CBZoYEuR/Nk6bcvsYouxtyIl6PSuF9E8YjpJE="
email: false
matrix:
fast_finish: true
allow_failures:
- jdk: openjdk-ea
- jdk: oraclejdk-ea
- jdk: oraclejdk-ea
cache:
directories:
- $HOME/.m2

View File

@ -27,18 +27,18 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambots:5.3.0'
implementation 'org.telegram:telegrambots:5.4.0'
```
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.3.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.3.0)
3. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/5.4.0)
4. Download the jar(including all dependencies) from [here](https://mvnrepository.com/artifact/org.telegram/telegrambots/5.4.0)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,3 +1,7 @@
### <a id="5.4.0"></a>5.3.0 ###
1. Update Api version [5.4](https://core.telegram.org/bots/api-changelog#november-4-2021)
2. Bug fixing: #968, #958, #942
### <a id="5.3.0"></a>5.3.0 ###
1. Update Api version [5.3](https://core.telegram.org/bots/api-changelog#june-25-2021)
2. `KeyboardRow` now support creation from a collection of buttons.

View File

@ -11,13 +11,13 @@ First you need ot get the library and add it to your project. There are few poss
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
* With **Gradle**:
```gradle
implementation 'org.telegram:telegrambots:5.3.0'
implementation 'org.telegram:telegrambots:5.4.0'
```
2. Don't like **Maven Central Repository**? It can also be taken from [Jitpack](https://jitpack.io/#rubenlagus/TelegramBots).

View File

@ -48,7 +48,7 @@ public class Main {
TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSessioin.class);
// Set up Http proxy
DefaultBotOptions botOptions = new DefaultBotOptions());
DefaultBotOptions botOptions = new DefaultBotOptions();
botOptions.setProxyHost(PROXY_HOST);
botOptions.setProxyPort(PROXY_PORT);

View File

@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
* **Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:5.3.0'
implementation 'org.telegram:telegrambots-abilities:5.4.0'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>5.3.0</version>
<version>5.4.0</version>
<modules>
<module>telegrambots</module>

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-abilities:5.3.0'
implementation 'org.telegram:telegrambots-abilities:5.4.0'
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v5.0.1)

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambots-abilities</artifactId>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@ -265,10 +265,10 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
.orElse(new ArrayList<>())
.stream()
.map(member -> {
if (member instanceof ChatMemberAdministrator) {
return ((ChatMemberAdministrator) member).getUser().getId();
} else if (member instanceof ChatMemberOwner) {
return ((ChatMemberOwner) member).getUser().getId();
final String status = member.getStatus();
if (status.equals(ChatMemberOwner.STATUS)
|| status.equals(ChatMemberAdministrator.STATUS)) {
return member.getUser().getId();
}
return 0L;
})

View File

@ -31,6 +31,7 @@ public enum Flag implements Predicate<Update> {
POLL_ANSWER(Update::hasPollAnswer),
MY_CHAT_MEMBER(Update::hasMyChatMember),
CHAT_MEMBER(Update::hasChatMember),
CHAT_JOIN_REQUEST(Update::hasChatJoinRequest),
// Message Flags

View File

@ -86,6 +86,8 @@ public final class AbilityUtils {
return update.getMyChatMember().getFrom();
} else if (CHAT_MEMBER.test(update)) {
return update.getChatMember().getFrom();
} else if (CHAT_JOIN_REQUEST.test(update)) {
return update.getChatJoinRequest().getUser();
} else if (POLL.test(update)) {
return EMPTY_USER;
} else {
@ -171,6 +173,8 @@ public final class AbilityUtils {
return update.getMyChatMember().getChat().getId();
} else if (CHAT_MEMBER.test(update)) {
return update.getChatMember().getChat().getId();
} else if (CHAT_JOIN_REQUEST.test(update)) {
return update.getChatJoinRequest().getChat().getId();
} else {
throw new IllegalStateException("Could not retrieve originating chat ID from update");
}

View File

@ -26,6 +26,7 @@ import org.telegram.telegrambots.meta.api.objects.File;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.User;
import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMember;
import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMemberAdministrator;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
@ -453,8 +454,8 @@ public class AbilityBotTest {
mockUser(update, message, user);
when(message.isGroupMessage()).thenReturn(true);
ChatMemberAdministrator member = mock(ChatMemberAdministrator.class);
when(member.getUser()).thenReturn(user);
ChatMember member = mock(ChatMember.class);
when(member.getStatus()).thenReturn(ChatMemberAdministrator.STATUS);
when(member.getUser()).thenReturn(user);
when(silent.execute(any(GetChatAdministrators.class))).thenReturn(Optional.of(newArrayList(member)));

View File

@ -15,14 +15,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-chat-session-bot:5.3.0'
implementation 'org.telegram:telegrambots-chat-session-bot:5.4.0'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambots-chat-session-bot</artifactId>
@ -76,7 +76,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<shiro.version>1.7.0</shiro.version>
<shiro.version>1.8.0</shiro.version>
</properties>
<dependencies>
@ -84,7 +84,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->

View File

@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
2. Using Gradle:
```gradle
implementation 'org.telegram:telegrambotsextensions:5.3.0'
implementation 'org.telegram:telegrambotsextensions:5.4.0'
```

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambotsextensions</artifactId>
@ -75,7 +75,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
</dependencies>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambots-meta</artifactId>

View File

@ -0,0 +1,69 @@
package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 5.4
* Use this method to approve a chat join request.
* The bot must be an administrator in the chat for this to work and must have the can_invite_users admin right.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@RequiredArgsConstructor
@Builder
public class ApproveChatJoinRequest extends BotApiMethod<Boolean> {
public static final String PATH = "approveChatJoinRequest";
private static final String CHATID_FIELD = "chat_id";
private static final String USERID_FIELD = "user_id";
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(USERID_FIELD)
@NonNull
private Long userId; ///< Required. Unique identifier of the target user
@Override
public String getMethod() {
return PATH;
}
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Boolean>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error approving chat join request", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == 0) {
throw new TelegramApiValidationException("UserId can't be null or 0", this);
}
}
}

View File

@ -43,6 +43,8 @@ public class CreateChatInviteLink extends BotApiMethod<ChatInviteLink> {
private static final String CHATID_FIELD = "chat_id";
private static final String EXPIREDATE_FIELD = "expire_date";
private static final String MEMBERLIMIT_FIELD = "member_limit";
private static final String NAME_FIELD = "name";
private static final String CREATESJOINREQUEST_FIELD = "creates_join_request";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -55,7 +57,17 @@ public class CreateChatInviteLink extends BotApiMethod<ChatInviteLink> {
* Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
*/
@JsonProperty(MEMBERLIMIT_FIELD)
private Integer memberLimit;
private Integer memberLimit; ///< Optional. Invite link name; 0-32 characters
@JsonProperty(NAME_FIELD)
private String name; ///< Optional. Invite link name; 0-32 characters
/**
* Optional.
*
* True, if users joining the chat via the link need to be approved by chat administrators.
* If True, member_limit can't be specified
*/
@JsonProperty(CREATESJOINREQUEST_FIELD)
private Boolean createsJoinRequest;
@Override
@ -80,9 +92,15 @@ public class CreateChatInviteLink extends BotApiMethod<ChatInviteLink> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (name != null && name.length() > 32) {
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
}
if (createsJoinRequest != null && memberLimit != null) {
throw new TelegramApiValidationException("MemberLimit can not be used with CreatesJoinRequest field", this);
}
if (memberLimit != null && (memberLimit < 1 || memberLimit > 99999)) {
throw new TelegramApiValidationException("MemberLimit must be between 1 and 99999", this);
}

View File

@ -0,0 +1,69 @@
package org.telegram.telegrambots.meta.api.methods.groupadministration;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.*;
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
import org.telegram.telegrambots.meta.api.objects.ApiResponse;
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 5.4
* Use this method to decline a chat join request.
* The bot must be an administrator in the chat for this to work and must have the can_invite_users admin right.
* Returns True on success.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@RequiredArgsConstructor
@Builder
public class DeclineChatJoinRequest extends BotApiMethod<Boolean> {
public static final String PATH = "declineChatJoinRequest";
private static final String CHATID_FIELD = "chat_id";
private static final String USERID_FIELD = "user_id";
@JsonProperty(CHATID_FIELD)
@NonNull
private String chatId; ///< Required. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@JsonProperty(USERID_FIELD)
@NonNull
private Long userId; ///< Required. Unique identifier of the target user
@Override
public String getMethod() {
return PATH;
}
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
new TypeReference<ApiResponse<Boolean>>(){});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error declining chat join request", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId can't be empty", this);
}
if (userId == 0) {
throw new TelegramApiValidationException("UserId can't be null or 0", this);
}
}
}

View File

@ -45,6 +45,8 @@ public class EditChatInviteLink extends BotApiMethod<ChatInviteLink> {
private static final String INVITELINK_FIELD = "invite_link";
private static final String EXPIREDATE_FIELD = "expire_date";
private static final String MEMBERLIMIT_FIELD = "member_limit";
private static final String NAME_FIELD = "name";
private static final String CREATESJOINREQUEST_FIELD = "creates_join_request";
@JsonProperty(CHATID_FIELD)
@NonNull
@ -61,6 +63,16 @@ public class EditChatInviteLink extends BotApiMethod<ChatInviteLink> {
*/
@JsonProperty(MEMBERLIMIT_FIELD)
private Integer memberLimit;
@JsonProperty(NAME_FIELD)
private String name; ///< Optional. Invite link name; 0-32 characters
/**
* Optional.
*
* True, if users joining the chat via the link need to be approved by chat administrators.
* If True, member_limit can't be specified
*/
@JsonProperty(CREATESJOINREQUEST_FIELD)
private Boolean createsJoinRequest;
@Override
@ -91,6 +103,12 @@ public class EditChatInviteLink extends BotApiMethod<ChatInviteLink> {
if (Strings.isNullOrEmpty(inviteLink)) {
throw new TelegramApiValidationException("InviteLink can't be empty", this);
}
if (name != null && name.length() > 32) {
throw new TelegramApiValidationException("Name must be between 0 and 32 characters", this);
}
if (createsJoinRequest != null && memberLimit != null) {
throw new TelegramApiValidationException("MemberLimit can not be used with CreatesJoinRequest field", this);
}
if (memberLimit != null && (memberLimit < 1 || memberLimit > 99999)) {
throw new TelegramApiValidationException("MemberLimit must be between 1 and 99999", this);
}

View File

@ -44,10 +44,16 @@ public class SendChatAction extends BotApiMethod<Boolean> {
@NonNull
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
/**
* Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages,
* upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files,
* upload_document for general files, find_location for location data,
* record_video_note or upload_video_note for video notes.
* Type of action to broadcast. Choose one, depending on what the user is about to receive:
* typing for text messages
* upload_photo for photos
* record_video or upload_video for videos
* record_voice or upload_voice for voice notes
* upload_document for general files
* choose_sticker for stickers
* find_location for location data
* record_video_note
* upload_video_note for video notes
*/
@JsonProperty(ACTION_FIELD)
@NonNull
@ -85,10 +91,10 @@ public class SendChatAction extends BotApiMethod<Boolean> {
@Override
public void validate() throws TelegramApiValidationException {
if (chatId == null || chatId.isEmpty()) {
if (chatId.isEmpty()) {
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
}
if (action == null) {
if (action.isEmpty()) {
throw new TelegramApiValidationException("Action parameter can't be empty", this);
}
}

View File

@ -28,6 +28,9 @@ public class ChatInviteLink implements BotApiObject {
private static final String ISREVOKED_FIELD = "is_revoked";
private static final String EXPIREDATE_FIELD = "expire_date";
private static final String MEMBERLIMIT_FIELD = "member_limit";
private static final String NAME_FIELD = "name";
private static final String PENDINGJOINREQUESTCOUNT_FIELD = "pending_join_request_count";
private static final String CREATESJOINREQUEST_FIELD = "creates_join_request";
/**
* The invite link.
@ -50,4 +53,13 @@ public class ChatInviteLink implements BotApiObject {
*/
@JsonProperty(MEMBERLIMIT_FIELD)
private Integer memberLimit;
@JsonProperty(NAME_FIELD)
private String name; ///< Optional. Invite link name
@JsonProperty(PENDINGJOINREQUESTCOUNT_FIELD)
private Integer pendingJoinRequestCount; ///< Optional. Number of pending join requests created using this link
/**
* True, if users joining the chat via the link need to be approved by chat administrators
*/
@JsonProperty(CREATESJOINREQUEST_FIELD)
private Boolean createsJoinRequest;
}

View File

@ -0,0 +1,37 @@
package org.telegram.telegrambots.meta.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
/**
* @author Ruben Bermudez
* @version 5.4
*
* Represents a join request sent to a chat.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ChatJoinRequest implements BotApiObject {
private static final String CHAT_FIELD = "chat";
private static final String FROM_FIELD = "from";
private static final String DATE_FIELD = "date";
private static final String BIO_FIELD = "bio";
private static final String INVITELINK_FIELD = "invite_link";
@JsonProperty(CHAT_FIELD)
private Chat chat; ///< Chat to which the request was sent
@JsonProperty(FROM_FIELD)
private User user; ///< User that sent the join request
@JsonProperty(DATE_FIELD)
private Integer date; ///< Date the request was sent in Unix time
@JsonProperty(BIO_FIELD)
private String bio; ///< Optional. Bio of the user.
@JsonProperty(INVITELINK_FIELD)
private String inviteLink; ///< Optional. Chat invite link that was used by the user to send the join request
}

View File

@ -44,6 +44,7 @@ public class Update implements BotApiObject {
private static final String POLLANSWER_FIELD = "poll_answer";
private static final String MYCHATMEMBER_FIELD = "my_chat_member";
private static final String CHATMEMBER_FIELD = "chat_member";
private static final String CHATJOINREQUEST_FIELD = "chat_join_request";
@JsonProperty(UPDATEID_FIELD)
private Integer updateId;
@ -91,6 +92,8 @@ public class Update implements BotApiObject {
*/
@JsonProperty(CHATMEMBER_FIELD)
private ChatMemberUpdated chatMember;
@JsonProperty(CHATJOINREQUEST_FIELD)
private ChatJoinRequest chatJoinRequest;
public boolean hasMessage() {
return message != null;
@ -143,4 +146,8 @@ public class Update implements BotApiObject {
public boolean hasChatMember() {
return chatMember != null;
}
public boolean hasChatJoinRequest() {
return chatJoinRequest != null;
}
}

View File

@ -2,6 +2,7 @@ package org.telegram.telegrambots.meta.api.objects.chatmember;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
import org.telegram.telegrambots.meta.api.objects.User;
import org.telegram.telegrambots.meta.api.objects.chatmember.serialization.ChatMemberDeserializer;
/**
@ -14,4 +15,5 @@ import org.telegram.telegrambots.meta.api.objects.chatmember.serialization.ChatM
@JsonDeserialize(using = ChatMemberDeserializer.class)
public interface ChatMember extends BotApiObject {
String getStatus();
User getUser();
}

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberAdministrator implements ChatMember {
public static final String STATUS = "administrator";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
private static final String CANBEEDITED_FIELD = "can_be_edited";
@ -46,7 +48,7 @@ public class ChatMemberAdministrator implements ChatMember {
* The member's status in the chat, always administrator
*/
@JsonProperty(STATUS_FIELD)
private final String status = "administrator";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberBanned implements ChatMember {
public static final String STATUS = "kicked";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
private static final String UNTILDATE_FIELD = "until_date";
@ -34,7 +36,7 @@ public class ChatMemberBanned implements ChatMember {
* The member's status in the chat, always kicked
*/
@JsonProperty(STATUS_FIELD)
private final String status = "kicked";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberLeft implements ChatMember {
public static final String STATUS = "left";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
@ -33,7 +35,7 @@ public class ChatMemberLeft implements ChatMember {
* The member's status in the chat, always left
*/
@JsonProperty(STATUS_FIELD)
private final String status = "left";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberMember implements ChatMember {
public static final String STATUS = "member";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
@ -33,7 +35,7 @@ public class ChatMemberMember implements ChatMember {
* The member's status in the chat, always member
*/
@JsonProperty(STATUS_FIELD)
private final String status = "member";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberOwner implements ChatMember {
public static final String STATUS = "creator";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
private static final String CUSTOMTITLE_FIELD = "custom_title";
@ -35,7 +37,7 @@ public class ChatMemberOwner implements ChatMember {
* The member's status in the chat, always creator
*/
@JsonProperty(STATUS_FIELD)
private final String status = "creator";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
@AllArgsConstructor
@Builder
public class ChatMemberRestricted implements ChatMember {
public static final String STATUS = "restricted";
private static final String STATUS_FIELD = "status";
private static final String USER_FIELD = "user";
private static final String ISMEMBER_FIELD = "is_member";
@ -43,7 +45,7 @@ public class ChatMemberRestricted implements ChatMember {
* The member's status in the chat, always restricted
*/
@JsonProperty(STATUS_FIELD)
private final String status = "restricted";
private final String status = STATUS;
/**
* Information about the user
*/

View File

@ -18,14 +18,14 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-spring-boot-starter</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'org.telegram:telegrambots-spring-boot-starter:5.3.0'
implementation 'org.telegram:telegrambots-spring-boot-starter:5.4.0'
```
Motivation

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambots-spring-boot-starter</artifactId>
@ -70,7 +70,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<telegrambots.version>5.3.0</telegrambots.version>
<telegrambots.version>5.4.0</telegrambots.version>
<spring-boot.version>2.4.5</spring-boot.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>telegrambots</artifactId>
@ -92,7 +92,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>