TDLightTelegramBots/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java

259 lines
9.0 KiB
Java
Raw Normal View History

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
2022-11-08 19:33:50 +01:00
import java.util.List;
2016-01-14 01:14:53 +01:00
/**
* This object represents a Telegram chat with an user or a group
2016-01-14 01:14:53 +01:00
* @author Ruben Bermudez
2022-06-18 00:40:30 +02:00
* @version 6.1
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
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";
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 HASPRIVATEFORWARDS_FIELD = "has_private_forwards";
2022-02-26 21:03:10 +01:00
private static final String HASPROTECTEDCONTENT_FIELD = "has_protected_content";
2022-06-18 00:40:30 +02:00
private static final String JOINTOSENDMESSAGES_FIELD = "join_to_send_messages";
private static final String JOINBYREQUEST_FIELD = "join_by_request";
2022-08-15 02:42:50 +02:00
private static final String HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD = "has_restricted_voice_and_video_messages";
2022-11-08 19:33:50 +01:00
private static final String ISFORUM_FIELD = "is_forum";
private static final String ACTIVEUSERNAMES_FIELD = "active_usernames";
private static final String EMOJISTATUSCUSTOMEMOJIID_FIELD = "emoji_status_custom_emoji_id";
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-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.
*/
@JsonProperty(ID_FIELD)
2020-10-31 18:43:32 +01:00
@NonNull
private Long id;
/**
* Type of the chat, one of private, group or channel or "supergroup"
*/
2016-01-14 01:14:53 +01:00
@JsonProperty(TYPE_FIELD)
2020-10-31 18:43:32 +01:00
@NonNull
private String type;
/**
* Optional.
* Title of the chat, only for channels and group chat
*/
2016-01-14 01:14:53 +01:00
@JsonProperty(TITLE_FIELD)
private String title;
/**
* Optional
* Username of the chat, only for private chats and channels if available
*/
2016-01-14 01:14:53 +01:00
@JsonProperty(FIRSTNAME_FIELD)
private String firstName;
/**
* Optional.
* Interlocutor's first name for private chats
*/
2016-01-14 01:14:53 +01:00
@JsonProperty(LASTNAME_FIELD)
private String lastName;
/**
* Optional.
* Interlocutor's last name for private chats
*/
2016-01-14 01:14:53 +01:00
@JsonProperty(USERNAME_FIELD)
private String userName;
/**
* Optional.
* Chat photo. Returned only in getChat.
*/
2017-06-30 14:15:48 +02:00
@JsonProperty(PHOTO_FIELD)
private ChatPhoto photo;
/**
* Optional.
* Description, for groups, supergroups and channel chats. Returned only in getChat.
*/
2017-06-30 14:15:48 +02:00
@JsonProperty(DESCRIPTION_FIELD)
private String description;
/**
* Optional.
* Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
*/
2017-06-30 14:15:48 +02:00
@JsonProperty(INVITELINK_FIELD)
private String inviteLink;
/**
* Optional.
* The most recent pinned message (by sending date). Returned only in getChat.
*/
2017-08-23 09:06:32 +02:00
@JsonProperty(PINNEDMESSAGE_FIELD)
private Message pinnedMessage;
/**
* Optional.
* For supergroups, name of Group sticker set. Returned only in getChat.
*/
2017-10-11 19:27:12 +02:00
@JsonProperty(STICKERSETNAME_FIELD)
private String stickerSetName;
/**
* Optional.
* True, if the bot can change group the sticker set. Returned only in getChat.
*/
2017-10-11 19:27:12 +02:00
@JsonProperty(CANSETSTICKERSET_FIELD)
private Boolean canSetStickerSet;
/**
* Optional.
* Default chat member permissions, for groups and supergroups. Returned only in getChat.
*/
2019-07-28 22:13:58 +02:00
@JsonProperty(PERMISSIONS_FIELD)
private ChatPermissions permissions;
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;
/**
* Optional.
* Bio of the other party in a private chat. Returned only in getChat.
*/
2020-11-01 23:46:36 +01:00
@JsonProperty(BIO_FIELD)
private String bio;
2020-11-01 23:46:36 +01:00
/**
* 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;
/**
* Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
*/
2020-11-01 23:46:36 +01:00
@JsonProperty(LOCATION_FIELD)
private ChatLocation location;
/**
* Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
*/
2021-03-09 11:59:28 +01:00
@JsonProperty(MESSAGEAUTODELETETIME_FIELD)
private Integer messageAutoDeleteTime;
2021-12-07 22:03:25 +01:00
/**
* Optional.
2022-02-26 21:03:10 +01:00
* 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.
2021-12-07 22:03:25 +01:00
* Returned only in getChat.
*/
2022-02-26 21:03:10 +01:00
@JsonProperty(HASPRIVATEFORWARDS_FIELD)
private Boolean hasPrivateForwards;
2021-12-07 22:03:25 +01:00
/**
* Optional.
2022-02-26 21:03:10 +01:00
* True, if messages from the chat can't be forwarded to other chats.
2021-12-07 22:03:25 +01:00
* Returned only in getChat.
*/
2022-02-26 21:03:10 +01:00
@JsonProperty(HASPROTECTEDCONTENT_FIELD)
private Boolean HasProtectedContent;
2022-06-18 00:40:30 +02:00
/**
* Optional.
* True, if users need to join the supergroup before they can send messages.
* Returned only in getChat.
*/
@JsonProperty(JOINTOSENDMESSAGES_FIELD)
private Boolean joinToSendMessages;
/**
* Optional.
* True, if all users directly joining the supergroup need to be approved by supergroup administrators.
* Returned only in getChat.
*/
@JsonProperty(JOINBYREQUEST_FIELD)
private Boolean joinByRequest;
2022-08-15 02:42:50 +02:00
/**
* Optional.
* True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
* Returned only in getChat.
*/
@JsonProperty(HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD)
private Boolean hasRestrictedVoiceAndVideoMessages;
2016-01-14 01:14:53 +01:00
2022-11-08 19:33:50 +01:00
/**
* Optional.
* True, if the supergroup chat is a forum (has topics enabled)
*/
@JsonProperty(ISFORUM_FIELD)
private Boolean isForum;
/**
* Optional.
* If non-empty, the list of all active chat usernames; for private chats, supergroups and channels.
* Returned only in getChat.
*/
@JsonProperty(ACTIVEUSERNAMES_FIELD)
private List<String> activeUsernames;
/**
* Optional.
* Custom emoji identifier of emoji status of the other party in a private chat.
* Returned only in getChat.
*/
@JsonProperty(EMOJISTATUSCUSTOMEMOJIID_FIELD)
private String emojiStatusCustomEmojiId;
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);
}
}