Merge pull request #11 from Clevero/add-sendaudio-duration-support
add DURATION_FIELD merged
This commit is contained in:
commit
3d643cc9ae
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user