Merge pull request #11 from Clevero/add-sendaudio-duration-support

add DURATION_FIELD merged
This commit is contained in:
Ruben Bermudez 2016-03-20 20:21:07 +01:00
commit 3d643cc9ae
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 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;
}

View File

@ -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());
}