revert changes in Message and remove useless if clause in AbsSender
This commit is contained in:
parent
ac18b952b9
commit
6ad4491136
@ -138,9 +138,6 @@ public class Message implements IBotApiObject {
|
|||||||
if (jsonObject.has(VIDEO_FIELD)) {
|
if (jsonObject.has(VIDEO_FIELD)) {
|
||||||
this.video = new Video(jsonObject.getJSONObject(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)) {
|
if (jsonObject.has(CONTACT_FIELD)) {
|
||||||
this.contact = new Contact(jsonObject.getJSONObject(CONTACT_FIELD));
|
this.contact = new Contact(jsonObject.getJSONObject(CONTACT_FIELD));
|
||||||
}
|
}
|
||||||
|
@ -520,16 +520,16 @@ public abstract class AbsSender {
|
|||||||
|
|
||||||
JSONObject jsonObject = new JSONObject(responseContent);
|
JSONObject jsonObject = new JSONObject(responseContent);
|
||||||
|
|
||||||
//if we got an ok, then we can expect a "reseult" section. and out of this can a new Message object be built
|
/* if we got not an "ok" with false, we have a response like that
|
||||||
if(jsonObject.has("ok") && jsonObject.getBoolean("ok")){
|
*
|
||||||
return new Message(jsonObject.getJSONObject("result"));
|
* {"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
|
||||||
|
*/
|
||||||
|
if(!jsonObject.getBoolean("ok")){
|
||||||
|
throw new TelegramApiException("Error at sendAudio", jsonObject.getString("description"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//and if not, there should be a field in our jsonObject that represents a boolean "false" with a key of "ok"
|
// and if not, we can expect a "result" section. and out of this can a new Message object be built
|
||||||
//{"description":"[Error]: Bad Request: chat not found","error_code":400,"ok":false}
|
return new Message(jsonObject.getJSONObject("result"));
|
||||||
// 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