Skip to content

Commit cfaefca

Browse files
authored
Merge pull request #372 from anfanik/master
Bot API 7.2
2 parents c8307c3 + d057ff1 commit cfaefca

26 files changed

+753
-17
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
import java.util.Objects;
5+
6+
public class Birthdate implements Serializable {
7+
8+
private static final long serialVersionUID = 0L;
9+
10+
private Integer day;
11+
private Integer month;
12+
private Integer year;
13+
14+
public Integer day() {
15+
return day;
16+
}
17+
18+
public Integer month() {
19+
return month;
20+
}
21+
22+
public Integer year() {
23+
return year;
24+
}
25+
26+
@Override
27+
public boolean equals(Object o) {
28+
if (this == o) return true;
29+
if (!(o instanceof Birthdate)) return false;
30+
Birthdate birthdate = (Birthdate) o;
31+
return Objects.equals(day, birthdate.day)
32+
&& Objects.equals(month, birthdate.month)
33+
&& Objects.equals(year, birthdate.year);
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
return Objects.hash(day, month, year);
39+
}
40+
41+
@Override
42+
public String toString() {
43+
return "Birthday{" +
44+
"day=" + day +
45+
", month=" + month +
46+
", year=" + year +
47+
'}';
48+
}
49+
}

library/src/main/java/com/pengrad/telegrambot/model/Chat.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.pengrad.telegrambot.model;
22

33
import com.google.gson.annotations.SerializedName;
4+
import com.pengrad.telegrambot.model.business.BusinessIntro;
5+
import com.pengrad.telegrambot.model.business.BusinessLocation;
6+
import com.pengrad.telegrambot.model.business.BusinessOpeningHours;
47
import com.pengrad.telegrambot.model.reaction.ReactionType;
58

69

@@ -35,6 +38,11 @@ public enum Type {
3538
private Boolean is_forum;
3639
private ChatPhoto photo;
3740
private String[] active_usernames;
41+
private Birthdate birthdate;
42+
private BusinessIntro business_intro;
43+
private BusinessLocation business_location;
44+
private BusinessOpeningHours business_opening_hours;
45+
private Chat personal_chat;
3846
private ReactionType[] available_reactions;
3947
private Integer accent_color_id;
4048
private String background_custom_emoji_id;
@@ -108,7 +116,26 @@ public String[] activeUsernames() {
108116
return active_usernames;
109117
}
110118

111-
@Deprecated
119+
public Birthdate birthdate() {
120+
return birthdate;
121+
}
122+
123+
public BusinessIntro businessIntro() {
124+
return business_intro;
125+
}
126+
127+
public BusinessLocation businessLocation() {
128+
return business_location;
129+
}
130+
131+
public BusinessOpeningHours businessOpeningHours() {
132+
return business_opening_hours;
133+
}
134+
135+
public Chat personalChat() {
136+
return personal_chat;
137+
}
138+
112139
public ReactionType[] availableReactions() {
113140
return available_reactions;
114141
}
@@ -132,6 +159,7 @@ public String profileBackgroundCustomEmojiId() {
132159
/**
133160
* @deprecated Use emojiStatusCustomEmojiId() instead
134161
*/
162+
@Deprecated
135163
public String getEmojiStatusCustomEmojiId() {
136164
return emoji_status_custom_emoji_id;
137165
}
@@ -242,6 +270,11 @@ public boolean equals(Object o) {
242270
Objects.equals(title, chat.title) &&
243271
Objects.equals(photo, chat.photo) &&
244272
Arrays.equals(active_usernames, chat.active_usernames) &&
273+
Objects.equals(birthdate, chat.birthdate) &&
274+
Objects.equals(business_intro, chat.business_intro) &&
275+
Objects.equals(business_location, chat.business_location) &&
276+
Objects.equals(business_opening_hours, chat.business_opening_hours) &&
277+
Objects.equals(personal_chat, chat.personal_chat) &&
245278
Arrays.equals(available_reactions, chat.available_reactions) &&
246279
Objects.equals(accent_color_id, chat.accent_color_id) &&
247280
Objects.equals(background_custom_emoji_id, chat.background_custom_emoji_id) &&
@@ -289,6 +322,11 @@ public String toString() {
289322
", title='" + title + '\'' +
290323
", photo=" + photo +
291324
", active_usernames=" + Arrays.toString(active_usernames) +
325+
", birthdate=" + birthdate +
326+
", business_intro=" + business_intro +
327+
", business_location=" + business_location +
328+
", business_opening_hours=" + business_opening_hours +
329+
", personal_chat=" + personal_chat +
292330
", available_reactions=" + Arrays.toString(available_reactions) +
293331
", accent_color_id=" + accent_color_id +
294332
", background_custom_emoji_id='" + background_custom_emoji_id + '\'' +
Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.pengrad.telegrambot.model;
22

33
import java.io.Serializable;
4+
import java.util.Arrays;
45
import java.util.Objects;
56

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

910
private Integer request_id;
1011
private Long chat_id;
12+
private String title;
13+
private String username;
14+
private PhotoSize[] photo;
1115

1216
public Integer requestId() {
1317
return request_id;
@@ -17,28 +21,49 @@ public Long chatId() {
1721
return chat_id;
1822
}
1923

24+
public String title() {
25+
return title;
26+
}
27+
28+
public String username() {
29+
return username;
30+
}
31+
32+
public PhotoSize[] photo() {
33+
return photo;
34+
}
35+
2036
@Override
2137
public boolean equals(Object o) {
2238
if (this == o) return true;
2339
if (o == null || getClass() != o.getClass()) return false;
2440

2541
ChatShared that = (ChatShared) o;
2642

27-
return Objects.equals(request_id, that.request_id) &&
28-
Objects.equals(chat_id, that.chat_id);
43+
return Objects.equals(request_id, that.request_id)
44+
&& Objects.equals(chat_id, that.chat_id)
45+
&& Objects.equals(title, that.title)
46+
&& Objects.equals(username, that.username)
47+
&& Arrays.equals(photo, that.photo);
2948
}
3049

3150
@Override
3251
public int hashCode() {
3352
return Objects.hash(request_id,
34-
chat_id);
53+
chat_id,
54+
title,
55+
username,
56+
Arrays.hashCode(photo));
3557
}
3658

3759
@Override
3860
public String toString() {
3961
return "ChatShared{" +
40-
"request_id='" + request_id + '\'' +
41-
", chat_id='" + chat_id + '\'' +
42-
'}';
62+
"request_id=" + request_id +
63+
", chat_id=" + chat_id +
64+
", title='" + title + '\'' +
65+
", username='" + username + '\'' +
66+
", photo=" + Arrays.toString(photo) +
67+
'}';
4368
}
4469
}

library/src/main/java/com/pengrad/telegrambot/model/Message.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.pengrad.telegrambot.model;
22

3+
import com.pengrad.telegrambot.model.business.BusinessConnection;
34
import com.pengrad.telegrambot.model.chatboost.ChatBoostAdded;
45
import com.pengrad.telegrambot.model.message.MaybeInaccessibleMessage;
56
import com.pengrad.telegrambot.model.message.origin.*;
@@ -21,6 +22,8 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
2122
private User from;
2223
private Chat sender_chat;
2324
private Integer sender_boost_count;
25+
private User sender_business_bot;
26+
private BusinessConnection business_connection;
2427
private MessageOrigin forward_origin;
2528
private Boolean is_topic_message;
2629
private Boolean is_automatic_forward;
@@ -31,6 +34,7 @@ public class Message extends MaybeInaccessibleMessage implements Serializable {
3134
private User via_bot;
3235
private Integer edit_date;
3336
private Boolean has_protected_content;
37+
private Boolean is_from_offline;
3438
private Boolean has_media_spoiler;
3539
private String media_group_id;
3640
private String author_signature;
@@ -106,6 +110,14 @@ public Integer senderBoostCount() {
106110
return sender_boost_count;
107111
}
108112

113+
public User senderBusinessBot() {
114+
return sender_business_bot;
115+
}
116+
117+
public BusinessConnection businessConnection() {
118+
return business_connection;
119+
}
120+
109121
public MessageOrigin forwardOrigin() {
110122
return forward_origin;
111123
}
@@ -216,11 +228,15 @@ public Integer editDate() {
216228
}
217229

218230
public Boolean hasProtectedContent() {
219-
return has_protected_content;
231+
return has_protected_content != null && has_protected_content;
232+
}
233+
234+
public Boolean isFromOffline() {
235+
return is_from_offline != null && is_from_offline;
220236
}
221237

222238
public Boolean hasMediaSpoiler() {
223-
return has_media_spoiler;
239+
return has_media_spoiler != null && has_media_spoiler;
224240
}
225241

226242

@@ -483,6 +499,8 @@ public boolean equals(Object o) {
483499
Objects.equals(sender_chat, message.sender_chat) &&
484500
Objects.equals(sender_boost_count, message.sender_boost_count) &&
485501
Objects.equals(date, message.date) &&
502+
Objects.equals(sender_business_bot, message.sender_business_bot) &&
503+
Objects.equals(business_connection, message.business_connection) &&
486504
Objects.equals(chat, message.chat) &&
487505
Objects.equals(forward_origin, message.forward_origin) &&
488506
Objects.equals(is_topic_message, message.is_topic_message) &&
@@ -494,6 +512,7 @@ public boolean equals(Object o) {
494512
Objects.equals(via_bot, message.via_bot) &&
495513
Objects.equals(edit_date, message.edit_date) &&
496514
Objects.equals(has_protected_content, message.has_protected_content) &&
515+
Objects.equals(is_from_offline, message.is_from_offline) &&
497516
Objects.equals(has_media_spoiler, message.has_media_spoiler) &&
498517
Objects.equals(media_group_id, message.media_group_id) &&
499518
Objects.equals(author_signature, message.author_signature) &&
@@ -567,6 +586,8 @@ public String toString() {
567586
", sender_chat=" + sender_chat +
568587
", sender_boost_count=" + sender_boost_count +
569588
", date=" + date +
589+
", sender_business_bot=" + sender_business_bot +
590+
", business_connection=" + business_connection +
570591
", chat=" + chat +
571592
", forward_origin=" + forward_origin +
572593
", is_topic_message=" + is_topic_message +
@@ -578,6 +599,7 @@ public String toString() {
578599
", via_bot=" + via_bot +
579600
", edit_date=" + edit_date +
580601
", has_protected_content=" + has_protected_content+
602+
", is_from_offline=" + is_from_offline +
581603
", has_media_spoiler=" + has_media_spoiler+
582604
", media_group_id='" + media_group_id + '\'' +
583605
", author_signature='" + author_signature + '\'' +

library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public Type stickerType() {
3535
return sticker_type;
3636
}
3737

38+
/**
39+
* @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2
40+
*/
41+
@Deprecated
3842
public Boolean isAnimated() {
3943
return is_animated;
4044
}
@@ -63,6 +67,10 @@ public PhotoSize thumb() {
6367
return thumbnail();
6468
}
6569

70+
/**
71+
* @deprecated StickerSets can contain both animated and non-animated stickers since Bot API 7.2
72+
*/
73+
@Deprecated
6674
public Boolean isVideo() {
6775
return is_video;
6876
}

library/src/main/java/com/pengrad/telegrambot/model/Update.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.pengrad.telegrambot.model;
22

3+
import com.pengrad.telegrambot.model.business.BusinessConnection;
4+
import com.pengrad.telegrambot.model.business.BusinessMessageDeleted;
35
import com.pengrad.telegrambot.model.chatboost.ChatBoostRemoved;
46
import com.pengrad.telegrambot.model.chatboost.ChatBoostUpdated;
57

@@ -18,6 +20,10 @@ public class Update implements Serializable {
1820
private Message edited_message;
1921
private Message channel_post;
2022
private Message edited_channel_post;
23+
private BusinessConnection business_connection;
24+
private Message business_message;
25+
private Message edited_business_message;
26+
private BusinessMessageDeleted deleted_business_messages;
2127
private InlineQuery inline_query;
2228
private ChosenInlineResult chosen_inline_result;
2329
private CallbackQuery callback_query;
@@ -53,6 +59,22 @@ public Message editedChannelPost() {
5359
return edited_channel_post;
5460
}
5561

62+
public BusinessConnection businessConnection() {
63+
return business_connection;
64+
}
65+
66+
public Message businessMessage() {
67+
return business_message;
68+
}
69+
70+
public Message editedBusinessMessage() {
71+
return edited_business_message;
72+
}
73+
74+
public BusinessMessageDeleted deletedBusinessMessages() {
75+
return deleted_business_messages;
76+
}
77+
5678
public InlineQuery inlineQuery() {
5779
return inline_query;
5880
}
@@ -119,6 +141,10 @@ public boolean equals(Object o) {
119141
Objects.equals(edited_message, update.edited_message) &&
120142
Objects.equals(channel_post, update.channel_post) &&
121143
Objects.equals(edited_channel_post, update.edited_channel_post) &&
144+
Objects.equals(business_connection, update.business_connection) &&
145+
Objects.equals(business_message, update.business_message) &&
146+
Objects.equals(edited_business_message, update.edited_business_message) &&
147+
Objects.equals(deleted_business_messages, update.deleted_business_messages) &&
122148
Objects.equals(inline_query, update.inline_query) &&
123149
Objects.equals(chosen_inline_result, update.chosen_inline_result) &&
124150
Objects.equals(callback_query, update.callback_query) &&
@@ -148,6 +174,10 @@ public String toString() {
148174
", edited_message=" + edited_message +
149175
", channel_post=" + channel_post +
150176
", edited_channel_post=" + edited_channel_post +
177+
", business_connection=" + business_connection +
178+
", business_message=" + business_message +
179+
", edited_business_message=" + edited_business_message +
180+
", deleted_business_messages=" + deleted_business_messages +
151181
", inline_query=" + inline_query +
152182
", chosen_inline_result=" + chosen_inline_result +
153183
", callback_query=" + callback_query +

0 commit comments

Comments
 (0)