Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot API 7.2 #372

Merged
merged 11 commits into from
Apr 7, 2024
49 changes: 49 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Birthdate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;
import java.util.Objects;

public class Birthdate implements Serializable {

private static final long serialVersionUID = 0L;

private Integer day;
private Integer month;
private Integer year;

public Integer day() {
return day;
}

public Integer month() {
return month;
}

public Integer year() {
return year;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Birthdate)) return false;
Birthdate birthdate = (Birthdate) o;
return Objects.equals(day, birthdate.day)
&& Objects.equals(month, birthdate.month)
&& Objects.equals(year, birthdate.year);
}

@Override
public int hashCode() {
return Objects.hash(day, month, year);
}

@Override
public String toString() {
return "Birthday{" +
"day=" + day +
", month=" + month +
", year=" + year +
'}';
}
}
40 changes: 39 additions & 1 deletion library/src/main/java/com/pengrad/telegrambot/model/Chat.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.pengrad.telegrambot.model;

import com.google.gson.annotations.SerializedName;
import com.pengrad.telegrambot.model.business.BusinessIntro;
import com.pengrad.telegrambot.model.business.BusinessLocation;
import com.pengrad.telegrambot.model.business.BusinessOpeningHours;
import com.pengrad.telegrambot.model.reaction.ReactionType;


Expand Down Expand Up @@ -35,6 +38,11 @@ public enum Type {
private Boolean is_forum;
private ChatPhoto photo;
private String[] active_usernames;
private Birthdate birthdate;
private BusinessIntro business_intro;
private BusinessLocation business_location;
private BusinessOpeningHours business_opening_hours;
private Chat personal_chat;
private ReactionType[] available_reactions;
private Integer accent_color_id;
private String background_custom_emoji_id;
Expand Down Expand Up @@ -108,7 +116,26 @@ public String[] activeUsernames() {
return active_usernames;
}

@Deprecated
public Birthdate birthdate() {
return birthdate;
}

public BusinessIntro businessIntro() {
return business_intro;
}

public BusinessLocation businessLocation() {
return business_location;
}

public BusinessOpeningHours businessOpeningHours() {
return business_opening_hours;
}

public Chat personalChat() {
return personal_chat;
}

public ReactionType[] availableReactions() {
return available_reactions;
}
Expand All @@ -132,6 +159,7 @@ public String profileBackgroundCustomEmojiId() {
/**
* @deprecated Use emojiStatusCustomEmojiId() instead
*/
@Deprecated
public String getEmojiStatusCustomEmojiId() {
return emoji_status_custom_emoji_id;
}
Expand Down Expand Up @@ -242,6 +270,11 @@ public boolean equals(Object o) {
Objects.equals(title, chat.title) &&
Objects.equals(photo, chat.photo) &&
Arrays.equals(active_usernames, chat.active_usernames) &&
Objects.equals(birthdate, chat.birthdate) &&
Objects.equals(business_intro, chat.business_intro) &&
Objects.equals(business_location, chat.business_location) &&
Objects.equals(business_opening_hours, chat.business_opening_hours) &&
Objects.equals(personal_chat, chat.personal_chat) &&
Arrays.equals(available_reactions, chat.available_reactions) &&
Objects.equals(accent_color_id, chat.accent_color_id) &&
Objects.equals(background_custom_emoji_id, chat.background_custom_emoji_id) &&
Expand Down Expand Up @@ -289,6 +322,11 @@ public String toString() {
", title='" + title + '\'' +
", photo=" + photo +
", active_usernames=" + Arrays.toString(active_usernames) +
", birthdate=" + birthdate +
", business_intro=" + business_intro +
", business_location=" + business_location +
", business_opening_hours=" + business_opening_hours +
", personal_chat=" + personal_chat +
", available_reactions=" + Arrays.toString(available_reactions) +
", accent_color_id=" + accent_color_id +
", background_custom_emoji_id='" + background_custom_emoji_id + '\'' +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class ChatShared implements Serializable {
private final static long serialVersionUID = 0L;

private Integer request_id;
private Long chat_id;
private String title;
private String username;
private PhotoSize[] photo;

public Integer requestId() {
return request_id;
Expand All @@ -17,28 +21,49 @@ public Long chatId() {
return chat_id;
}

public String title() {
return title;
}

public String username() {
return username;
}

public PhotoSize[] photo() {
return photo;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

ChatShared that = (ChatShared) o;

return Objects.equals(request_id, that.request_id) &&
Objects.equals(chat_id, that.chat_id);
return Objects.equals(request_id, that.request_id)
&& Objects.equals(chat_id, that.chat_id)
&& Objects.equals(title, that.title)
&& Objects.equals(username, that.username)
&& Arrays.equals(photo, that.photo);
}

@Override
public int hashCode() {
return Objects.hash(request_id,
chat_id);
chat_id,
title,
username,
Arrays.hashCode(photo));
}

@Override
public String toString() {
return "ChatShared{" +
"request_id='" + request_id + '\'' +
", chat_id='" + chat_id + '\'' +
'}';
"request_id=" + request_id +
", chat_id=" + chat_id +
", title='" + title + '\'' +
", username='" + username + '\'' +
", photo=" + Arrays.toString(photo) +
'}';
}
}
26 changes: 24 additions & 2 deletions library/src/main/java/com/pengrad/telegrambot/model/Message.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.business.BusinessConnection;
import com.pengrad.telegrambot.model.chatboost.ChatBoostAdded;
import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage;
import com.pengrad.telegrambot.model.message.origin.*;
Expand All @@ -21,6 +22,8 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private User from;
private Chat sender_chat;
private Integer sender_boost_count;
private User sender_business_bot;
private BusinessConnection business_connection;
private MessageOrigin forward_origin;
private Boolean is_topic_message;
private Boolean is_automatic_forward;
Expand All @@ -31,6 +34,7 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
private User via_bot;
private Integer edit_date;
private Boolean has_protected_content;
private Boolean is_from_offline;
private Boolean has_media_spoiler;
private String media_group_id;
private String author_signature;
Expand Down Expand Up @@ -106,6 +110,14 @@ public Integer senderBoostCount() {
return sender_boost_count;
}

public User senderBusinessBot() {
return sender_business_bot;
}

public BusinessConnection businessConnection() {
return business_connection;
}

public MessageOrigin forwardOrigin() {
return forward_origin;
}
Expand Down Expand Up @@ -216,11 +228,15 @@ public Integer editDate() {
}

public Boolean hasProtectedContent() {
return has_protected_content;
return has_protected_content != null && has_protected_content;
}

public Boolean isFromOffline() {
return is_from_offline != null && is_from_offline;
}

public Boolean hasMediaSpoiler() {
return has_media_spoiler;
return has_media_spoiler != null && has_media_spoiler;
}


Expand Down Expand Up @@ -483,6 +499,8 @@ public boolean equals(Object o) {
Objects.equals(sender_chat, message.sender_chat) &&
Objects.equals(sender_boost_count, message.sender_boost_count) &&
Objects.equals(date, message.date) &&
Objects.equals(sender_business_bot, message.sender_business_bot) &&
Objects.equals(business_connection, message.business_connection) &&
Objects.equals(chat, message.chat) &&
Objects.equals(forward_origin, message.forward_origin) &&
Objects.equals(is_topic_message, message.is_topic_message) &&
Expand All @@ -494,6 +512,7 @@ public boolean equals(Object o) {
Objects.equals(via_bot, message.via_bot) &&
Objects.equals(edit_date, message.edit_date) &&
Objects.equals(has_protected_content, message.has_protected_content) &&
Objects.equals(is_from_offline, message.is_from_offline) &&
Objects.equals(has_media_spoiler, message.has_media_spoiler) &&
Objects.equals(media_group_id, message.media_group_id) &&
Objects.equals(author_signature, message.author_signature) &&
Expand Down Expand Up @@ -567,6 +586,8 @@ public String toString() {
", sender_chat=" + sender_chat +
", sender_boost_count=" + sender_boost_count +
", date=" + date +
", sender_business_bot=" + sender_business_bot +
", business_connection=" + business_connection +
", chat=" + chat +
", forward_origin=" + forward_origin +
", is_topic_message=" + is_topic_message +
Expand All @@ -578,6 +599,7 @@ public String toString() {
", via_bot=" + via_bot +
", edit_date=" + edit_date +
", has_protected_content=" + has_protected_content+
", is_from_offline=" + is_from_offline +
", has_media_spoiler=" + has_media_spoiler+
", media_group_id='" + media_group_id + '\'' +
", author_signature='" + author_signature + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public Type stickerType() {
return sticker_type;
}

/**
* @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2
*/
@Deprecated
public Boolean isAnimated() {
return is_animated;
}
Expand Down Expand Up @@ -63,6 +67,10 @@ public PhotoSize thumb() {
return thumbnail();
}

/**
* @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2
*/
@Deprecated
public Boolean isVideo() {
return is_video;
}
Expand Down
30 changes: 30 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Update.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pengrad.telegrambot.model;

import com.pengrad.telegrambot.model.business.BusinessConnection;
import com.pengrad.telegrambot.model.business.BusinessMessageDeleted;
import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved;
import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated;

Expand All @@ -18,6 +20,10 @@ public class Update implements Serializable {
private Message edited_message;
private Message channel_post;
private Message edited_channel_post;
private BusinessConnection business_connection;
private Message business_message;
private Message edited_business_message;
private BusinessMessageDeleted deleted_business_messages;
private InlineQuery inline_query;
private ChosenInlineResult chosen_inline_result;
private CallbackQuery callback_query;
Expand Down Expand Up @@ -53,6 +59,22 @@ public Message editedChannelPost() {
return edited_channel_post;
}

public BusinessConnection businessConnection() {
return business_connection;
}

public Message businessMessage() {
return business_message;
}

public Message editedBusinessMessage() {
return edited_business_message;
}

public BusinessMessageDeleted deletedBusinessMessages() {
return deleted_business_messages;
}

public InlineQuery inlineQuery() {
return inline_query;
}
Expand Down Expand Up @@ -119,6 +141,10 @@ public boolean equals(Object o) {
Objects.equals(edited_message, update.edited_message) &&
Objects.equals(channel_post, update.channel_post) &&
Objects.equals(edited_channel_post, update.edited_channel_post) &&
Objects.equals(business_connection, update.business_connection) &&
Objects.equals(business_message, update.business_message) &&
Objects.equals(edited_business_message, update.edited_business_message) &&
Objects.equals(deleted_business_messages, update.deleted_business_messages) &&
Objects.equals(inline_query, update.inline_query) &&
Objects.equals(chosen_inline_result, update.chosen_inline_result) &&
Objects.equals(callback_query, update.callback_query) &&
Expand Down Expand Up @@ -148,6 +174,10 @@ public String toString() {
", edited_message=" + edited_message +
", channel_post=" + channel_post +
", edited_channel_post=" + edited_channel_post +
", business_connection=" + business_connection +
", business_message=" + business_message +
", edited_business_message=" + edited_business_message +
", deleted_business_messages=" + deleted_business_messages +
", inline_query=" + inline_query +
", chosen_inline_result=" + chosen_inline_result +
", callback_query=" + callback_query +
Expand Down
Loading
Loading