Skip to content

Commit 2a78b2a

Browse files
committed
Added the fields explanation and explanation_entities to the Poll object
1 parent 02bffe8 commit 2a78b2a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public enum Type {
2323
private Type type;
2424
private Boolean allows_multiple_answers;
2525
private Integer correct_option_id;
26+
private String explanation;
27+
private MessageEntity[] explanation_entities;
2628

2729
public String id() {
2830
return id;
@@ -60,6 +62,14 @@ public Integer correctOptionId() {
6062
return correct_option_id;
6163
}
6264

65+
public String explanation() {
66+
return explanation;
67+
}
68+
69+
public MessageEntity[] explanationEntities() {
70+
return explanation_entities;
71+
}
72+
6373
@Override
6474
public boolean equals(Object o) {
6575
if (this == o) return true;
@@ -78,7 +88,11 @@ public boolean equals(Object o) {
7888
if (type != poll.type) return false;
7989
if (allows_multiple_answers != null ? !allows_multiple_answers.equals(poll.allows_multiple_answers) : poll.allows_multiple_answers != null)
8090
return false;
81-
return correct_option_id != null ? correct_option_id.equals(poll.correct_option_id) : poll.correct_option_id == null;
91+
if (correct_option_id != null ? !correct_option_id.equals(poll.correct_option_id) : poll.correct_option_id != null)
92+
return false;
93+
if (explanation != null ? !explanation.equals(poll.explanation) : poll.explanation != null) return false;
94+
// Probably incorrect - comparing Object[] arrays with Arrays.equals
95+
return Arrays.equals(explanation_entities, poll.explanation_entities);
8296
}
8397

8498
@Override
@@ -98,6 +112,8 @@ public String toString() {
98112
", type=" + type +
99113
", allows_multiple_answers=" + allows_multiple_answers +
100114
", correct_option_id=" + correct_option_id +
115+
", explanation='" + explanation + '\'' +
116+
", explanation_entities=" + Arrays.toString(explanation_entities) +
101117
'}';
102118
}
103119
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,9 @@ public void sendPoll() {
16911691
assertEquals(poll.totalVoterCount(), Integer.valueOf(0));
16921692
assertEquals(poll.correctOptionId(), Integer.valueOf(1));
16931693
assertTrue(poll.isClosed());
1694+
assertEquals("Some explanation of poll", poll.explanation());
1695+
assertEquals(1, poll.explanationEntities().length);
1696+
assertEquals(MessageEntity.Type.underline, poll.explanationEntities()[0].type());
16941697
}
16951698

16961699
@Test

0 commit comments

Comments
 (0)