From 7a9a704aa001af37f3090cd6490052dc17398107 Mon Sep 17 00:00:00 2001 From: Marcel Caspar Date: Tue, 15 Mar 2016 22:58:43 +0100 Subject: [PATCH] add DURATION_FIELD --- .../telegram/telegrambots/api/methods/SendAudio.java | 11 +++++++++++ .../org/telegram/telegrambots/bots/AbsSender.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java b/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java index 04e050ff..203cc628 100644 --- a/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java +++ b/src/main/java/org/telegram/telegrambots/api/methods/SendAudio.java @@ -17,6 +17,9 @@ import org.telegram.telegrambots.api.objects.ReplyKeyboard; public class SendAudio { public static final String PATH = "sendaudio"; + public static final String DURATION_FIELD = "duration"; + private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender + public static final String CHATID_FIELD = "chat_id"; private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels) public static final String AUDIO_FIELD = "audio"; @@ -44,6 +47,14 @@ public class SendAudio { super(); } + public void setDuration(Integer duration) { + this.duration = duration; + } + + public Integer getDuration(){ + return this.duration; + } + public String getChatId() { return chatId; } diff --git a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java index 3e8b0fb1..ca0b214d 100644 --- a/src/main/java/org/telegram/telegrambots/bots/AbsSender.java +++ b/src/main/java/org/telegram/telegrambots/bots/AbsSender.java @@ -458,6 +458,7 @@ public abstract class AbsSender { public Message sendAudio(SendAudio sendAudio) throws TelegramApiException { String responseContent; + try { CloseableHttpClient httpClient = HttpClients.createDefault(); String url = getBaseUrl() + SendAudio.PATH; @@ -479,6 +480,9 @@ public abstract class AbsSender { if (sendAudio.getTitle() != null) { builder.addTextBody(SendAudio.TITLE_FIELD, sendAudio.getTitle()); } + if(sendAudio.getDuration() != null){ + builder.addTextBody(SendAudio.DURATION_FIELD, sendAudio.getDuration().toString()); + } if (sendAudio.getDisableNotification() != null) { builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString()); }