no update logging

This commit is contained in:
mrbesen 2019-02-25 00:21:31 +01:00
parent 8b67f1d8a2
commit 0e7e4408ac
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 20 additions and 14 deletions

View File

@ -90,19 +90,15 @@ public class TelegramAPI implements Runnable {
async.enque(task);
}
public void request(String request, String parameter, boolean async) {
if(async) {
this.async.enque(request, parameter);
} else {
try {
request(request, parameter);
} catch(IOException e) {
e.printStackTrace();
}
}
public void requestAsync(String request, String parameter) {
this.async.enque(request, parameter);
}
public JSONObject request(String request, String parameter) throws IOException {
return request(request, parameter, true);
}
public JSONObject request(String request, String parameter) throws IOException {
public JSONObject request(String request, String parameter, boolean logging) throws IOException {
//do https stuff
URL url = new URL(API_URL + apikey + "/" + request);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
@ -112,7 +108,8 @@ public class TelegramAPI implements Runnable {
wr.write(parameter);
wr.flush();
log.log( "request: " + request + " content " + parameter + " -> " + con.getResponseCode() + ", " + con.getResponseMessage());
if(logging)
log.log( "request: " + request + " content " + parameter + " -> " + con.getResponseCode() + ", " + con.getResponseMessage());
if(con.getResponseCode() == 200) {
return new JSONObject(readfromIS(con.getInputStream()));
@ -155,7 +152,7 @@ public class TelegramAPI implements Runnable {
t.setExceptionhandl(asyncm.excpt == null ? IOE400supressor : asyncm.excpt);
async.enque(t);
} else {
JSONObject o = request(msg.getCommand(), msg.getQ());
JSONObject o = request(msg.getCommand(), msg.getQ(), true);
return new TMessage(o.getJSONObject("result"), this);
}
} catch(IOException e) {
@ -179,6 +176,15 @@ public class TelegramAPI implements Runnable {
}).start();
}
/**
* creates internal APIEror, when message is not modyfied! TODO; run update Caption with MessageBuilder and catch that error
* @param newCaption
* @param chatid
* @param msg_id
* @param rm
* @param async
* @param clb
*/
public void updateCaption(final String newCaption, int chatid, int msg_id, TReplyMarkup rm, boolean async, Callback<JSONObject, ?> clb) {
try {
String rply = "";
@ -233,7 +239,7 @@ public class TelegramAPI implements Runnable {
private void fetchUpdates() {
try {
processUpdates(request("getUpdates", "offset=" + msg_offset));
processUpdates(request("getUpdates", "offset=" + msg_offset, false));
} catch (IOException e) {
log.log("error getting updates.", e);
}