process return of sendAudio correctly
This commit is contained in:
parent
7a9a704aa0
commit
334b25b296
@ -138,6 +138,9 @@ public class Message implements IBotApiObject {
|
||||
if (jsonObject.has(VIDEO_FIELD)) {
|
||||
this.video = new Video(jsonObject.getJSONObject(VIDEO_FIELD));
|
||||
}
|
||||
if(jsonObject.has(AUDIO_FIELD)){
|
||||
this.audio = new Audio(jsonObject.getJSONObject(AUDIO_FIELD));
|
||||
}
|
||||
if (jsonObject.has(CONTACT_FIELD)) {
|
||||
this.contact = new Contact(jsonObject.getJSONObject(CONTACT_FIELD));
|
||||
}
|
||||
|
@ -519,11 +519,16 @@ public abstract class AbsSender {
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject(responseContent);
|
||||
if (!jsonObject.getBoolean("ok")) {
|
||||
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
|
||||
}
|
||||
|
||||
return new Message(jsonObject);
|
||||
if(jsonObject.has("result")){
|
||||
return new Message(jsonObject.getJSONObject("result"));
|
||||
}
|
||||
|
||||
//and if not, there should be a field in our jsonObject that represents a boolean "false" with a key of "ok"
|
||||
//{"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
|
||||
// for example. and can throw an exception, cause there was an error...
|
||||
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user