Compute message entities content during Message deserialization
This commit is contained in:
parent
199152e9bf
commit
19f473cfe5
@ -219,6 +219,10 @@ public class Message implements IBotApiObject {
|
||||
if (jsonObject.has(MIGRATEFROMCHAT_FIELD)) {
|
||||
this.migrateFromChatId = jsonObject.getLong(MIGRATEFROMCHAT_FIELD);
|
||||
}
|
||||
|
||||
if (hasText() && entities != null) {
|
||||
entities.forEach(x -> x.computeText(text));
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
|
@ -45,6 +45,8 @@ public class MessageEntity implements IBotApiObject {
|
||||
@JsonProperty(URL_FIELD)
|
||||
private String url; ///< Optional. For “text_link” only, url that will be opened after user taps on the text
|
||||
|
||||
private String text; ///< Text present in the entity. Computed from offset and length
|
||||
|
||||
public MessageEntity() {
|
||||
super();
|
||||
}
|
||||
@ -75,6 +77,14 @@ public class MessageEntity implements IBotApiObject {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
protected void computeText(String message) {
|
||||
text = message.substring(offset, offset + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeStartObject();
|
||||
|
Loading…
Reference in New Issue
Block a user