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

157 lines
5.6 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
import com.fasterxml.jackson.annotation.JsonProperty;
2016-04-02 18:20:49 +02:00
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")
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";
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";
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)
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)
private String type; ///< Type of the chat, one of “private”, “group” or “channel”
@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
*/
@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)
private String description; ///< Optional. Description, for supergroups and channel chats. Returned only in getChat.
@JsonProperty(INVITELINK_FIELD)
private String inviteLink; ///< Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
2017-08-23 09:06:32 +02:00
@JsonProperty(PINNEDMESSAGE_FIELD)
2019-04-08 02:43:46 +02:00
private Message pinnedMessage; ///< Optional. Pinned message, for groups, supergroups and channels. 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.
2016-01-14 01:14:53 +01:00
public Chat() {
super();
}
public Long getId() {
return id;
}
public Boolean isGroupChat() {
return GROUPCHATTYPE.equals(type);
}
public Boolean isChannelChat() {
return CHANNELCHATTYPE.equals(type);
}
public Boolean isUserChat() {
return USERCHATTYPE.equals(type);
}
public Boolean isSuperGroupChat() {
return SUPERGROUPCHATTYPE.equals(type);
}
public String getTitle() {
return title;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getUserName() {
return userName;
}
public Boolean getAllMembersAreAdministrators() {
return allMembersAreAdministrators;
}
2017-06-30 14:15:48 +02:00
public ChatPhoto getPhoto() {
return photo;
}
public String getDescription() {
return description;
}
public String getInviteLink() {
return inviteLink;
}
2017-08-23 09:06:32 +02:00
public Message getPinnedMessage() {
return pinnedMessage;
}
2017-10-11 19:27:12 +02:00
public String getStickerSetName() {
return stickerSetName;
}
2018-08-21 22:19:31 +02:00
public Boolean getCanSetStickerSet() {
2017-10-11 19:27:12 +02:00
return canSetStickerSet;
}
@Override
public String toString() {
return "Chat{" +
"id=" + id +
", type='" + type + '\'' +
", title='" + title + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", userName='" + userName + '\'' +
", allMembersAreAdministrators=" + allMembersAreAdministrators +
2017-06-30 14:15:48 +02:00
", photo=" + photo +
", description='" + description + '\'' +
", inviteLink='" + inviteLink + '\'' +
2017-08-23 09:06:32 +02:00
", pinnedMessage=" + pinnedMessage +
2017-10-11 19:27:12 +02:00
", stickerSetName='" + stickerSetName + '\'' +
", canSetStickerSet=" + canSetStickerSet +
'}';
}
2016-01-14 01:14:53 +01:00
}