Add an access to the user in ChatMember interface
This commit is contained in:
parent
c8d461926b
commit
0ec2e32bc9
@ -265,10 +265,10 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
|
|||||||
.orElse(new ArrayList<>())
|
.orElse(new ArrayList<>())
|
||||||
.stream()
|
.stream()
|
||||||
.map(member -> {
|
.map(member -> {
|
||||||
if (member instanceof ChatMemberAdministrator) {
|
final String status = member.getStatus();
|
||||||
return ((ChatMemberAdministrator) member).getUser().getId();
|
if (status.equals(ChatMemberOwner.STATUS)
|
||||||
} else if (member instanceof ChatMemberOwner) {
|
|| status.equals(ChatMemberAdministrator.STATUS)) {
|
||||||
return ((ChatMemberOwner) member).getUser().getId();
|
return member.getUser().getId();
|
||||||
}
|
}
|
||||||
return 0L;
|
return 0L;
|
||||||
})
|
})
|
||||||
|
@ -2,6 +2,7 @@ package org.telegram.telegrambots.meta.api.objects.chatmember;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
|
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;
|
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)
|
@JsonDeserialize(using = ChatMemberDeserializer.class)
|
||||||
public interface ChatMember extends BotApiObject {
|
public interface ChatMember extends BotApiObject {
|
||||||
String getStatus();
|
String getStatus();
|
||||||
|
User getUser();
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberAdministrator implements ChatMember {
|
public class ChatMemberAdministrator implements ChatMember {
|
||||||
|
public static final String STATUS = "administrator";
|
||||||
|
|
||||||
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 CANBEEDITED_FIELD = "can_be_edited";
|
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”
|
* The member's status in the chat, always “administrator”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "administrator";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberBanned implements ChatMember {
|
public class ChatMemberBanned implements ChatMember {
|
||||||
|
public static final String STATUS = "kicked";
|
||||||
|
|
||||||
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 UNTILDATE_FIELD = "until_date";
|
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”
|
* The member's status in the chat, always “kicked”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "kicked";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberLeft implements ChatMember {
|
public class ChatMemberLeft implements ChatMember {
|
||||||
|
public static final String STATUS = "left";
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ public class ChatMemberLeft implements ChatMember {
|
|||||||
* The member's status in the chat, always “left”
|
* The member's status in the chat, always “left”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "left";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberMember implements ChatMember {
|
public class ChatMemberMember implements ChatMember {
|
||||||
|
public static final String STATUS = "member";
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ public class ChatMemberMember implements ChatMember {
|
|||||||
* The member's status in the chat, always “member”
|
* The member's status in the chat, always “member”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "member";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberOwner implements ChatMember {
|
public class ChatMemberOwner implements ChatMember {
|
||||||
|
public static final String STATUS = "creator";
|
||||||
|
|
||||||
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 CUSTOMTITLE_FIELD = "custom_title";
|
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”
|
* The member's status in the chat, always “creator”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "creator";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,8 @@ import org.telegram.telegrambots.meta.api.objects.User;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class ChatMemberRestricted implements ChatMember {
|
public class ChatMemberRestricted implements ChatMember {
|
||||||
|
public static final String STATUS = "restricted";
|
||||||
|
|
||||||
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";
|
||||||
@ -43,7 +45,7 @@ public class ChatMemberRestricted implements ChatMember {
|
|||||||
* The member's status in the chat, always “restricted”
|
* The member's status in the chat, always “restricted”
|
||||||
*/
|
*/
|
||||||
@JsonProperty(STATUS_FIELD)
|
@JsonProperty(STATUS_FIELD)
|
||||||
private final String status = "restricted";
|
private final String status = STATUS;
|
||||||
/**
|
/**
|
||||||
* Information about the user
|
* Information about the user
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user