2018-07-08 01:41:21 +02:00
package org.telegram.telegrambots.meta.api.objects ;
2016-11-17 02:41:12 +01:00
import com.fasterxml.jackson.annotation.JsonProperty ;
2018-07-08 01:41:21 +02:00
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject ;
2016-11-17 02:41:12 +01:00
2018-12-12 17:10:00 +01:00
import java.time.Instant ;
2016-11-17 02:41:12 +01:00
/ * *
* @author Ruben Bermudez
* @version 1 . 0
2019-07-28 22:13:58 +02:00
* This object contains information about one member of the chat .
2016-11-17 02:41:12 +01:00
* /
public class ChatMember implements BotApiObject {
private static final String USER_FIELD = " user " ;
private static final String STATUS_FIELD = " status " ;
2017-06-30 14:15:48 +02:00
private static final String UNTILDATE_FIELD = " until_date " ;
private static final String CANBEEDITED_FIELD = " can_be_edited " ;
private static final String CANCHANGEINFORMATION_FIELD = " can_change_information " ;
private static final String CANPOSTMESSAGES_FIELD = " can_post_messages " ;
private static final String CANEDITMESSAGES_FIELD = " can_edit_messages " ;
private static final String CANDELETEMESSAGES_FIELD = " can_delete_messages " ;
private static final String CANINVITEUSERS_FIELD = " can_invite_users " ;
2019-12-31 03:36:57 +01:00
private static final String CANRESTRICTMEMBERS_FIELD = " can_restrict_members " ;
2017-06-30 14:15:48 +02:00
private static final String CANPINMESSAGES_FIELD = " can_pin_messages " ;
private static final String CANPROMOTEMEMBERS_FIELD = " can_promote_members " ;
private static final String CANSENDMESSAGES_FIELD = " can_send_messages " ;
private static final String CANSENDMEDIAMESSAGES_FIELD = " can_send_media_messages " ;
private static final String CANSENDOTHERMESSAGES_FIELD = " can_send_other_messages " ;
private static final String CANADDWEBPAGEPREVIEWS_FIELD = " can_add_web_page_previews " ;
2019-07-28 22:13:58 +02:00
private static final String CAN_SEND_POLLS_FIELD = " can_send_polls " ;
2019-04-08 02:43:46 +02:00
private static final String ISMEMBER_FIELD = " is_member " ;
2019-12-31 03:36:57 +01:00
private static final String CUSTOMTITLE_FIELD = " custom_title " ;
2016-11-17 02:41:12 +01:00
@JsonProperty ( USER_FIELD )
private User user ; ///< Information about the user
@JsonProperty ( STATUS_FIELD )
2019-07-28 22:13:58 +02:00
private String status ; ///< The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”
2017-06-30 14:15:48 +02:00
@JsonProperty ( UNTILDATE_FIELD )
2018-11-06 15:35:55 +01:00
private Integer untilDate ; ///< Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANBEEDITED_FIELD )
private Boolean canBeEdited ; ///< Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user
@JsonProperty ( CANCHANGEINFORMATION_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canChangeInformation ; ///< Optional. Administrators and restricted only. True, if the administrator can change the chat title, photo and other settings
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANPOSTMESSAGES_FIELD )
private Boolean canPostMessages ; ///< Optional. Administrators only. True, if the administrator can post in the channel, channels only
@JsonProperty ( CANEDITMESSAGES_FIELD )
2017-11-17 15:47:22 +01:00
private Boolean canEditMessages ; ///< Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANDELETEMESSAGES_FIELD )
private Boolean canDeleteMessages ; ///< Optional. Administrators only. True, if the administrator can delete messages of other users
@JsonProperty ( CANINVITEUSERS_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canInviteUsers ; ///< Optional. Administrators and restricted only. True, if the administrator can invite new users to the chat
2019-12-31 03:36:57 +01:00
@JsonProperty ( CANRESTRICTMEMBERS_FIELD )
private Boolean canRestrictMembers ; ///< Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANPINMESSAGES_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canPinMessages ; ///< Optional. Administrators and restricted only. True, if the administrator can pin messages, groups and supergroups only
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANPROMOTEMEMBERS_FIELD )
2018-11-06 15:35:55 +01:00
private Boolean canPromoteMembers ; ///< Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that it has promoted, directly or indirectly (promoted by administrators that were appointed by the bot)
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANSENDMESSAGES_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canSendMessages ; ///< Optional. Restricted only. True, if the user is allowed to send text messages, contacts, locations and venues
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANSENDMEDIAMESSAGES_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canSendMediaMessages ; ///< Optional. Restricted only. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANSENDOTHERMESSAGES_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canSendOtherMessages ; ///< Optional. Restricted only. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
2017-06-30 14:15:48 +02:00
@JsonProperty ( CANADDWEBPAGEPREVIEWS_FIELD )
2019-07-28 22:13:58 +02:00
private Boolean canAddWebPagePreviews ; ///< Optional. Restricted only. True, if the user is allowed to add web page previews to his messages
@JsonProperty ( CAN_SEND_POLLS_FIELD )
private Boolean canSendPolls ; ///< Optional. Restricted only. True, if the user is allowed to send polls.
2019-04-08 02:43:46 +02:00
@JsonProperty ( ISMEMBER_FIELD )
private Boolean isMemberField ; ///< True, if the user is a member of the chat at the moment of the request. For example, it can be false for the chat creator or for a restricted user.
2019-12-31 03:36:57 +01:00
@JsonProperty ( CUSTOMTITLE_FIELD )
private String customTitle ; ///< Optional. Owner and administrators only. Custom title for this user
2016-11-17 02:41:12 +01:00
public ChatMember ( ) {
super ( ) ;
}
public User getUser ( ) {
return user ;
}
public String getStatus ( ) {
return status ;
}
2017-06-30 14:15:48 +02:00
public Integer getUntilDate ( ) {
return untilDate ;
}
2018-12-12 17:10:00 +01:00
public Instant getUntilDateAsInstant ( ) {
if ( untilDate = = null ) {
return null ;
}
return Instant . ofEpochSecond ( untilDate ) ;
}
2017-06-30 14:15:48 +02:00
public Boolean getCanBeEdited ( ) {
return canBeEdited ;
}
public Boolean getCanChangeInformation ( ) {
return canChangeInformation ;
}
public Boolean getCanPostMessages ( ) {
return canPostMessages ;
}
public Boolean getCanEditMessages ( ) {
return canEditMessages ;
}
public Boolean getCanDeleteMessages ( ) {
return canDeleteMessages ;
}
public Boolean getCanInviteUsers ( ) {
return canInviteUsers ;
}
2019-12-31 03:36:57 +01:00
public Boolean getCanRestrictMembers ( ) {
return canRestrictMembers ;
}
/ * *
* @deprecated Use { { @link # getCanRestrictMembers ( ) } }
* /
@Deprecated
2017-06-30 14:15:48 +02:00
public Boolean getCanRestrictUsers ( ) {
2019-12-31 03:36:57 +01:00
return canRestrictMembers ;
2017-06-30 14:15:48 +02:00
}
public Boolean getCanPinMessages ( ) {
return canPinMessages ;
}
public Boolean getCanPromoteMembers ( ) {
return canPromoteMembers ;
}
public Boolean getCanSendMessages ( ) {
return canSendMessages ;
}
public Boolean getCanSendMediaMessages ( ) {
return canSendMediaMessages ;
}
public Boolean getCanSendOtherMessages ( ) {
return canSendOtherMessages ;
}
public Boolean getCanAddWebPagePreviews ( ) {
return canAddWebPagePreviews ;
}
2019-07-28 22:13:58 +02:00
public Boolean getCanSendPolls ( ) {
return canSendPolls ;
}
public Boolean getMemberField ( ) {
return isMemberField ;
}
2019-12-31 03:36:57 +01:00
public String getCustomTitle ( ) {
return customTitle ;
}
2016-11-17 02:41:12 +01:00
@Override
public String toString ( ) {
return " ChatMember{ " +
" user= " + user +
" , status=' " + status + '\'' +
2017-06-30 14:15:48 +02:00
" , untilDate= " + untilDate +
" , canBeEdited= " + canBeEdited +
" , canChangeInformation= " + canChangeInformation +
" , canPostMessages= " + canPostMessages +
" , canEditMessages= " + canEditMessages +
" , canDeleteMessages= " + canDeleteMessages +
" , canInviteUsers= " + canInviteUsers +
2019-12-31 03:36:57 +01:00
" , canRestrictMembers= " + canRestrictMembers +
2017-06-30 14:15:48 +02:00
" , canPinMessages= " + canPinMessages +
" , canPromoteMembers= " + canPromoteMembers +
" , canSendMessages= " + canSendMessages +
" , canSendMediaMessages= " + canSendMediaMessages +
" , canSendOtherMessages= " + canSendOtherMessages +
" , canAddWebPagePreviews= " + canAddWebPagePreviews +
2019-07-28 22:13:58 +02:00
" , canSendPolls= " + canSendPolls +
" , isMemberField= " + isMemberField +
2019-12-31 03:36:57 +01:00
" , customTitle= " + customTitle +
2016-11-17 02:41:12 +01:00
'}' ;
}
}