Skip to content

Commit 6f43e9d

Browse files
committed
Add media_group_id to Message
1 parent 4ff3038 commit 6f43e9d

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Message implements Serializable {
2121
private Integer forward_date;
2222
private Message reply_to_message;
2323
private Integer edit_date;
24+
private String media_group_id;
2425
private String author_signature;
2526
private String text;
2627
private MessageEntity[] entities;
@@ -33,12 +34,12 @@ public class Message implements Serializable {
3334
private Video video;
3435
private Voice voice;
3536
private VideoNote video_note;
36-
private User[] new_chat_members;
3737
private String caption;
3838
private Contact contact;
3939
private Location location;
4040
private Venue venue;
4141
private User new_chat_member;
42+
private User[] new_chat_members;
4243
private User left_chat_member;
4344
private String new_chat_title;
4445
private PhotoSize[] new_chat_photo;
@@ -96,6 +97,10 @@ public Integer editDate() {
9697
return edit_date;
9798
}
9899

100+
public String mediaGroupId() {
101+
return media_group_id;
102+
}
103+
99104
public String authorSignature() {
100105
return author_signature;
101106
}
@@ -144,10 +149,6 @@ public VideoNote videoNote() {
144149
return video_note;
145150
}
146151

147-
public User[] newChatMembers() {
148-
return new_chat_members;
149-
}
150-
151152
public String caption() {
152153
return caption;
153154
}
@@ -172,6 +173,10 @@ public User newChatMember() {
172173
return new_chat_member;
173174
}
174175

176+
public User[] newChatMembers() {
177+
return new_chat_members;
178+
}
179+
175180
public User leftChatMember() {
176181
return left_chat_member;
177182
}
@@ -242,6 +247,8 @@ public boolean equals(Object o) {
242247
if (reply_to_message != null ? !reply_to_message.equals(message.reply_to_message) : message.reply_to_message != null)
243248
return false;
244249
if (edit_date != null ? !edit_date.equals(message.edit_date) : message.edit_date != null) return false;
250+
if (media_group_id != null ? !media_group_id.equals(message.media_group_id) : message.media_group_id != null)
251+
return false;
245252
if (author_signature != null ? !author_signature.equals(message.author_signature) : message.author_signature != null)
246253
return false;
247254
if (text != null ? !text.equals(message.text) : message.text != null) return false;
@@ -258,14 +265,14 @@ public boolean equals(Object o) {
258265
if (video != null ? !video.equals(message.video) : message.video != null) return false;
259266
if (voice != null ? !voice.equals(message.voice) : message.voice != null) return false;
260267
if (video_note != null ? !video_note.equals(message.video_note) : message.video_note != null) return false;
261-
// Probably incorrect - comparing Object[] arrays with Arrays.equals
262-
if (!Arrays.equals(new_chat_members, message.new_chat_members)) return false;
263268
if (caption != null ? !caption.equals(message.caption) : message.caption != null) return false;
264269
if (contact != null ? !contact.equals(message.contact) : message.contact != null) return false;
265270
if (location != null ? !location.equals(message.location) : message.location != null) return false;
266271
if (venue != null ? !venue.equals(message.venue) : message.venue != null) return false;
267272
if (new_chat_member != null ? !new_chat_member.equals(message.new_chat_member) : message.new_chat_member != null)
268273
return false;
274+
// Probably incorrect - comparing Object[] arrays with Arrays.equals
275+
if (!Arrays.equals(new_chat_members, message.new_chat_members)) return false;
269276
if (left_chat_member != null ? !left_chat_member.equals(message.left_chat_member) : message.left_chat_member != null)
270277
return false;
271278
if (new_chat_title != null ? !new_chat_title.equals(message.new_chat_title) : message.new_chat_title != null)
@@ -309,6 +316,7 @@ public String toString() {
309316
", forward_date=" + forward_date +
310317
", reply_to_message=" + reply_to_message +
311318
", edit_date=" + edit_date +
319+
", media_group_id='" + media_group_id + '\'' +
312320
", author_signature='" + author_signature + '\'' +
313321
", text='" + text + '\'' +
314322
", entities=" + Arrays.toString(entities) +
@@ -321,12 +329,12 @@ public String toString() {
321329
", video=" + video +
322330
", voice=" + voice +
323331
", video_note=" + video_note +
324-
", new_chat_members=" + Arrays.toString(new_chat_members) +
325332
", caption='" + caption + '\'' +
326333
", contact=" + contact +
327334
", location=" + location +
328335
", venue=" + venue +
329336
", new_chat_member=" + new_chat_member +
337+
", new_chat_members=" + Arrays.toString(new_chat_members) +
330338
", left_chat_member=" + left_chat_member +
331339
", new_chat_title='" + new_chat_title + '\'' +
332340
", new_chat_photo=" + Arrays.toString(new_chat_photo) +

library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,13 @@ public void sendMediaGroup() {
10371037
));
10381038
assertTrue(response.isOk());
10391039
assertEquals(6, response.messages().length);
1040+
1041+
String mediaGroupId = response.messages()[0].mediaGroupId();
1042+
assertNotNull(mediaGroupId);
1043+
10401044
int messagesWithCaption = 0;
10411045
for (Message message : response.messages()) {
1046+
assertEquals(mediaGroupId, message.mediaGroupId());
10421047
if (message.caption() != null) {
10431048
assertEquals(MessageEntity.Type.bold, message.captionEntities()[0].type());
10441049
messagesWithCaption++;

0 commit comments

Comments
 (0)