Merge pull request #43 from rubenlagus/dev

Support editing messagess sent "via bot" upon editing
This commit is contained in:
Ruben Bermudez 2016-04-21 22:37:23 +02:00
commit 56a0cf985e
3 changed files with 18 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.Constants; import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod; import org.telegram.telegrambots.api.methods.BotApiMethod;
@ -119,7 +120,11 @@ public class EditMessageCaption extends BotApiMethod<Message> {
@Override @Override
public Message deserializeResponse(JSONObject answer) { public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) { if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT)); try {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT));
} catch (JSONException e) {
return new Message();
}
} }
return null; return null;
} }

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.Constants; import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod; import org.telegram.telegrambots.api.methods.BotApiMethod;
@ -105,7 +106,11 @@ public class EditMessageReplyMarkup extends BotApiMethod<Message> {
@Override @Override
public Message deserializeResponse(JSONObject answer) { public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) { if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT)); try {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT));
} catch (JSONException e) {
return new Message();
}
} }
return null; return null;
} }

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.Constants; import org.telegram.telegrambots.Constants;
import org.telegram.telegrambots.api.methods.BotApiMethod; import org.telegram.telegrambots.api.methods.BotApiMethod;
@ -163,7 +164,11 @@ public class EditMessageText extends BotApiMethod<Message> {
@Override @Override
public Message deserializeResponse(JSONObject answer) { public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean(Constants.RESPONSEFIELDOK)) { if (answer.getBoolean(Constants.RESPONSEFIELDOK)) {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT)); try {
return new Message(answer.getJSONObject(Constants.RESPONSEFIELDRESULT));
} catch (JSONException e) {
return new Message();
}
} }
return null; return null;
} }