2018-07-08 01:41:21 +02:00
package org.telegram.telegrambots.meta.api.objects ;
2016-01-14 01:14:53 +01:00
2020-10-31 18:43:32 +01:00
import com.fasterxml.jackson.annotation.JsonIgnore ;
2016-01-14 01:14:53 +01:00
import com.fasterxml.jackson.annotation.JsonProperty ;
2020-10-31 18:43:32 +01:00
import lombok.AllArgsConstructor ;
2020-11-01 23:46:36 +01:00
import lombok.EqualsAndHashCode ;
import lombok.Getter ;
2020-10-31 18:43:32 +01:00
import lombok.NoArgsConstructor ;
import lombok.NonNull ;
import lombok.RequiredArgsConstructor ;
2020-11-01 23:46:36 +01:00
import lombok.Setter ;
import lombok.ToString ;
2018-07-08 01:41:21 +02:00
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject ;
2016-01-14 01:14:53 +01:00
/ * *
* @author Ruben Bermudez
* @version 1 . 0
2017-06-30 14:15:48 +02:00
* This object represents a Telegram chat with an user or a group
2016-01-14 01:14:53 +01:00
* /
2018-08-21 22:19:31 +02:00
@SuppressWarnings ( " WeakerAccess " )
2020-11-01 23:46:36 +01:00
@EqualsAndHashCode ( callSuper = false )
@Getter
@Setter
@ToString
2020-10-31 18:43:32 +01:00
@RequiredArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
2016-11-17 02:41:12 +01:00
public class Chat implements BotApiObject {
2016-04-11 02:53:53 +02:00
private static final String ID_FIELD = " id " ;
private static final String TYPE_FIELD = " type " ;
private static final String TITLE_FIELD = " title " ;
2017-06-30 14:15:48 +02:00
private static final String USERNAME_FIELD = " username " ;
2016-04-11 02:53:53 +02:00
private static final String FIRSTNAME_FIELD = " first_name " ;
private static final String LASTNAME_FIELD = " last_name " ;
2020-11-01 23:46:36 +01:00
private static final String BIO_FIELD = " bio " ;
2016-09-24 22:37:25 +02:00
private static final String ALL_MEMBERS_ARE_ADMINISTRATORS_FIELD = " all_members_are_administrators " ;
2017-06-30 14:15:48 +02:00
private static final String PHOTO_FIELD = " photo " ;
private static final String DESCRIPTION_FIELD = " description " ;
private static final String INVITELINK_FIELD = " invite_link " ;
2017-08-23 09:06:32 +02:00
private static final String PINNEDMESSAGE_FIELD = " pinned_message " ;
2017-10-11 19:27:12 +02:00
private static final String STICKERSETNAME_FIELD = " sticker_set_name " ;
private static final String CANSETSTICKERSET_FIELD = " can_set_sticker_set " ;
2019-07-29 01:24:30 +02:00
private static final String PERMISSIONS_FIELD = " permissions " ;
2019-12-31 03:36:57 +01:00
private static final String SLOWMODEDELAY_FIELD = " slow_mode_delay " ;
2020-11-01 23:46:36 +01:00
private static final String LINKEDCHATID_FIELD = " linked_chat_id " ;
private static final String LOCATION_FIELD = " location " ;
2021-03-09 11:59:28 +01:00
private static final String MESSAGEAUTODELETETIME_FIELD = " message_auto_delete_time " ;
2021-12-07 22:03:25 +01:00
private static final String ALLOWSAVINGCONTENT_FIELD = " allow_saving_content " ;
private static final String HASPRIVATEFORWARDS_FIELD = " has_private_forwards " ;
2017-06-30 14:15:48 +02:00
2016-01-14 01:14:53 +01:00
private static final String USERCHATTYPE = " private " ;
private static final String GROUPCHATTYPE = " group " ;
private static final String CHANNELCHATTYPE = " channel " ;
private static final String SUPERGROUPCHATTYPE = " supergroup " ;
2016-11-17 02:41:12 +01:00
2016-05-31 19:08:56 +02:00
/ * *
* Unique identifier for this chat .
* This number may be greater than 32 bits and some programming languages may
* have difficulty / silent defects in interpreting it . But it smaller than 52 bits ,
* so a signed 64 bit integer or double - precision float type are safe for storing this identifier .
* /
2016-11-17 02:41:12 +01:00
@JsonProperty ( ID_FIELD )
2020-10-31 18:43:32 +01:00
@NonNull
2018-11-06 15:35:55 +01:00
private Long id ; ///< Unique identifier for this chat, not exceeding 1e13 by absolute value
2016-01-14 01:14:53 +01:00
@JsonProperty ( TYPE_FIELD )
2020-10-31 18:43:32 +01:00
@NonNull
2020-11-01 23:46:36 +01:00
private String type ; ///< Type of the chat, one of “private”, “group” or “channel” or "supergroup"
2016-01-14 01:14:53 +01:00
@JsonProperty ( TITLE_FIELD )
private String title ; ///< Optional. Title of the chat, only for channels and group chat
@JsonProperty ( FIRSTNAME_FIELD )
private String firstName ; ///< Optional. Username of the chat, only for private chats and channels if available
@JsonProperty ( LASTNAME_FIELD )
private String lastName ; ///< Optional. Interlocutor's first name for private chats
@JsonProperty ( USERNAME_FIELD )
private String userName ; ///< Optional. Interlocutor's last name for private chats
2016-09-30 23:32:05 +02:00
/ * *
2017-06-30 14:15:48 +02:00
* Optional . True if a group has ‘ All Members Are Admins ’ enabled .
2016-09-30 23:32:05 +02:00
* /
2016-11-17 02:41:12 +01:00
@JsonProperty ( ALL_MEMBERS_ARE_ADMINISTRATORS_FIELD )
2016-09-30 23:32:05 +02:00
private Boolean allMembersAreAdministrators ;
2017-06-30 14:15:48 +02:00
@JsonProperty ( PHOTO_FIELD )
private ChatPhoto photo ; ///< Optional. Chat photo. Returned only in getChat.
@JsonProperty ( DESCRIPTION_FIELD )
2019-07-28 22:13:58 +02:00
private String description ; ///< Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.
2017-06-30 14:15:48 +02:00
@JsonProperty ( INVITELINK_FIELD )
2021-03-09 11:59:28 +01:00
private String inviteLink ; ///< Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
2017-08-23 09:06:32 +02:00
@JsonProperty ( PINNEDMESSAGE_FIELD )
2020-11-01 23:46:36 +01:00
private Message pinnedMessage ; ///< Optional. The most recent pinned message (by sending date). Returned only in getChat.
2017-10-11 19:27:12 +02:00
@JsonProperty ( STICKERSETNAME_FIELD )
private String stickerSetName ; ///< Optional. For supergroups, name of Group sticker set. Returned only in getChat.
@JsonProperty ( CANSETSTICKERSET_FIELD )
2018-08-21 22:19:31 +02:00
private Boolean canSetStickerSet ; ///< Optional. True, if the bot can change group the sticker set. Returned only in getChat.
2019-07-28 22:13:58 +02:00
@JsonProperty ( PERMISSIONS_FIELD )
private ChatPermissions permissions ; ///< Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
2019-12-31 03:36:57 +01:00
/ * *
* Optional .
* For supergroups , the minimum allowed delay between consecutive messages sent by each unpriviledged user .
* Returned only in getChat .
* /
@JsonProperty ( SLOWMODEDELAY_FIELD )
private Integer slowModeDelay ;
2020-11-01 23:46:36 +01:00
@JsonProperty ( BIO_FIELD )
private String bio ; ///< Optional. Bio of the other party in a private chat. Returned only in getChat.
/ * *
* Optional .
* Unique identifier for the linked chat ,
* i . e . the discussion group identifier for a channel and vice versa ; for supergroups and channel chats .
* This identifier may be greater than 32 bits and some programming
* languages may have difficulty / silent defects in interpreting it .
* But it is smaller than 52 bits , so a signed 64 bit integer or
* double - precision float type are safe for storing this identifier .
* Returned only in getChat .
* /
@JsonProperty ( LINKEDCHATID_FIELD )
private Long linkedChatId ;
@JsonProperty ( LOCATION_FIELD )
private ChatLocation location ; ///< Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
2021-03-09 11:59:28 +01:00
@JsonProperty ( MESSAGEAUTODELETETIME_FIELD )
private Integer messageAutoDeleteTime ; ///< Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
2021-12-07 22:03:25 +01:00
/ * *
* Optional .
* True , if messages from the chat can be forwarded to other chats .
* Returned only in getChat .
* /
@JsonProperty ( ALLOWSAVINGCONTENT_FIELD )
private Boolean allowSavingContent ;
/ * *
* Optional .
* True , if privacy settings of the other party in the private chat allows to use tg : //user?id=<user_id>
* links only in chats with the user .
* Returned only in getChat .
* /
@JsonProperty ( HASPRIVATEFORWARDS_FIELD )
private Boolean hasPrivateForwards ;
2016-01-14 01:14:53 +01:00
2020-10-31 18:43:32 +01:00
@JsonIgnore
2016-01-14 01:14:53 +01:00
public Boolean isGroupChat ( ) {
return GROUPCHATTYPE . equals ( type ) ;
}
2020-10-31 18:43:32 +01:00
@JsonIgnore
2016-01-14 01:14:53 +01:00
public Boolean isChannelChat ( ) {
return CHANNELCHATTYPE . equals ( type ) ;
}
2020-10-31 18:43:32 +01:00
@JsonIgnore
2016-01-14 01:14:53 +01:00
public Boolean isUserChat ( ) {
return USERCHATTYPE . equals ( type ) ;
}
2020-10-31 18:43:32 +01:00
@JsonIgnore
2016-01-14 01:14:53 +01:00
public Boolean isSuperGroupChat ( ) {
return SUPERGROUPCHATTYPE . equals ( type ) ;
}
}