add DURATION_FIELD

This commit is contained in:
Marcel Caspar 2016-03-15 22:58:43 +01:00
parent bc2db06327
commit 7a9a704aa0
2 changed files with 15 additions and 0 deletions

View File

@ -17,6 +17,9 @@ import org.telegram.telegrambots.api.objects.ReplyKeyboard;
public class SendAudio { public class SendAudio {
public static final String PATH = "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"; 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) private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
public static final String AUDIO_FIELD = "audio"; public static final String AUDIO_FIELD = "audio";
@ -44,6 +47,14 @@ public class SendAudio {
super(); super();
} }
public void setDuration(Integer duration) {
this.duration = duration;
}
public Integer getDuration(){
return this.duration;
}
public String getChatId() { public String getChatId() {
return chatId; return chatId;
} }

View File

@ -458,6 +458,7 @@ public abstract class AbsSender {
public Message sendAudio(SendAudio sendAudio) throws TelegramApiException { public Message sendAudio(SendAudio sendAudio) throws TelegramApiException {
String responseContent; String responseContent;
try { try {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
String url = getBaseUrl() + SendAudio.PATH; String url = getBaseUrl() + SendAudio.PATH;
@ -479,6 +480,9 @@ public abstract class AbsSender {
if (sendAudio.getTitle() != null) { if (sendAudio.getTitle() != null) {
builder.addTextBody(SendAudio.TITLE_FIELD, sendAudio.getTitle()); builder.addTextBody(SendAudio.TITLE_FIELD, sendAudio.getTitle());
} }
if(sendAudio.getDuration() != null){
builder.addTextBody(SendAudio.DURATION_FIELD, sendAudio.getDuration().toString());
}
if (sendAudio.getDisableNotification() != null) { if (sendAudio.getDisableNotification() != null) {
builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString()); builder.addTextBody(SendAudio.DISABLENOTIFICATION_FIELD, sendAudio.getDisableNotification().toString());
} }