Skip to content

Commit b869134

Browse files
committed
Added the fields open_period and close_date to the Poll object
1 parent 9bec91c commit b869134

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public enum Type {
2525
private Integer correct_option_id;
2626
private String explanation;
2727
private MessageEntity[] explanation_entities;
28+
private Integer open_period;
29+
private Integer close_date;
2830

2931
public String id() {
3032
return id;
@@ -70,6 +72,14 @@ public MessageEntity[] explanationEntities() {
7072
return explanation_entities;
7173
}
7274

75+
public Integer openPeriod() {
76+
return open_period;
77+
}
78+
79+
public Integer closeDate() {
80+
return close_date;
81+
}
82+
7383
@Override
7484
public boolean equals(Object o) {
7585
if (this == o) return true;
@@ -92,7 +102,9 @@ public boolean equals(Object o) {
92102
return false;
93103
if (explanation != null ? !explanation.equals(poll.explanation) : poll.explanation != null) return false;
94104
// Probably incorrect - comparing Object[] arrays with Arrays.equals
95-
return Arrays.equals(explanation_entities, poll.explanation_entities);
105+
if (!Arrays.equals(explanation_entities, poll.explanation_entities)) return false;
106+
if (open_period != null ? !open_period.equals(poll.open_period) : poll.open_period != null) return false;
107+
return close_date != null ? close_date.equals(poll.close_date) : poll.close_date == null;
96108
}
97109

98110
@Override
@@ -114,6 +126,8 @@ public String toString() {
114126
", correct_option_id=" + correct_option_id +
115127
", explanation='" + explanation + '\'' +
116128
", explanation_entities=" + Arrays.toString(explanation_entities) +
129+
", open_period=" + open_period +
130+
", close_date=" + close_date +
117131
'}';
118132
}
119133
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ public void sendPoll() {
16951695
assertEquals("Some explanation of poll", poll.explanation());
16961696
assertEquals(1, poll.explanationEntities().length);
16971697
assertEquals(MessageEntity.Type.underline, poll.explanationEntities()[0].type());
1698+
assertTrue(poll.openPeriod() >= 495 && poll.openPeriod() <= 500);
16981699
}
16991700

17001701
@Test
@@ -1720,6 +1721,7 @@ public void sendPollWithKeyboard() {
17201721
assertEquals(poll.totalVoterCount(), Integer.valueOf(0));
17211722
assertEquals(poll.type(), Poll.Type.regular);
17221723
assertTrue(poll.allowsMultipleAnswers());
1724+
assertEquals(closeDate, poll.closeDate().longValue());
17231725
}
17241726

17251727
@Test

0 commit comments

Comments
 (0)