From a854a027e791fca4393bd99182b10bcb4ec35eaa Mon Sep 17 00:00:00 2001 From: antonu17 Date: Thu, 19 May 2016 23:25:52 +0600 Subject: [PATCH] Add caption field --- .../telegram/telegrambots/api/objects/Message.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/telegram/telegrambots/api/objects/Message.java b/src/main/java/org/telegram/telegrambots/api/objects/Message.java index 126cb67f..9a1b7444 100644 --- a/src/main/java/org/telegram/telegrambots/api/objects/Message.java +++ b/src/main/java/org/telegram/telegrambots/api/objects/Message.java @@ -46,6 +46,7 @@ public class Message implements IBotApiObject { private static final String GROUPCHATCREATED_FIELD = "group_chat_created"; private static final String REPLYTOMESSAGE_FIELD = "reply_to_message"; private static final String VOICE_FIELD = "voice"; + private static final String CAPTION_FIELD = "caption"; private static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created"; private static final String CHANNELCHATCREATED_FIELD = "channel_chat_created"; private static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id"; @@ -106,6 +107,8 @@ public class Message implements IBotApiObject { private Message replyToMessage; @JsonProperty(VOICE_FIELD) private Voice voice; ///< Optional. Message is a voice message, information about the file + @JsonProperty(CAPTION_FIELD) + private String caption; ///< Optional. Caption for the document, photo or video, 0-200 characters @JsonProperty(SUPERGROUPCREATED_FIELD) private Boolean superGroupCreated; ///< Optional. Informs that the supergroup has been created @JsonProperty(CHANNELCHATCREATED_FIELD) @@ -182,6 +185,9 @@ public class Message implements IBotApiObject { if (jsonObject.has(VOICE_FIELD)) { this.voice = new Voice(jsonObject.getJSONObject(VOICE_FIELD)); } + if (jsonObject.has(CAPTION_FIELD)) { + this.caption = jsonObject.getString(CAPTION_FIELD); + } if (jsonObject.has(NEWCHATMEMBER_FIELD)) { this.newChatMember = new User(jsonObject.getJSONObject(NEWCHATMEMBER_FIELD)); } @@ -321,6 +327,10 @@ public class Message implements IBotApiObject { return voice; } + public String getCaption() { + return caption; + } + public Boolean getSuperGroupCreated() { return superGroupCreated; } @@ -431,6 +441,9 @@ public class Message implements IBotApiObject { if (voice != null) { gen.writeObjectField(VOICE_FIELD, voice); } + if (caption != null) { + gen.writeObjectField(CAPTION_FIELD, caption); + } if (newChatMember != null) { gen.writeObjectField(NEWCHATMEMBER_FIELD, newChatMember); } @@ -504,6 +517,7 @@ public class Message implements IBotApiObject { ", groupchatCreated=" + groupchatCreated + ", replyToMessage=" + replyToMessage + ", voice=" + voice + + ", caption=" + caption + ", superGroupCreated=" + superGroupCreated + ", channelChatCreated=" + channelChatCreated + ", migrateToChatId=" + migrateToChatId +