no update logging
This commit is contained in:
parent
8b67f1d8a2
commit
0e7e4408ac
|
@ -90,19 +90,15 @@ public class TelegramAPI implements Runnable {
|
||||||
async.enque(task);
|
async.enque(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void request(String request, String parameter, boolean async) {
|
public void requestAsync(String request, String parameter) {
|
||||||
if(async) {
|
this.async.enque(request, parameter);
|
||||||
this.async.enque(request, parameter);
|
}
|
||||||
} else {
|
|
||||||
try {
|
public JSONObject request(String request, String parameter) throws IOException {
|
||||||
request(request, parameter);
|
return request(request, parameter, true);
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject request(String request, String parameter) throws IOException {
|
public JSONObject request(String request, String parameter, boolean logging) throws IOException {
|
||||||
//do https stuff
|
//do https stuff
|
||||||
URL url = new URL(API_URL + apikey + "/" + request);
|
URL url = new URL(API_URL + apikey + "/" + request);
|
||||||
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
|
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
|
||||||
|
@ -112,7 +108,8 @@ public class TelegramAPI implements Runnable {
|
||||||
wr.write(parameter);
|
wr.write(parameter);
|
||||||
wr.flush();
|
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) {
|
if(con.getResponseCode() == 200) {
|
||||||
return new JSONObject(readfromIS(con.getInputStream()));
|
return new JSONObject(readfromIS(con.getInputStream()));
|
||||||
|
@ -155,7 +152,7 @@ public class TelegramAPI implements Runnable {
|
||||||
t.setExceptionhandl(asyncm.excpt == null ? IOE400supressor : asyncm.excpt);
|
t.setExceptionhandl(asyncm.excpt == null ? IOE400supressor : asyncm.excpt);
|
||||||
async.enque(t);
|
async.enque(t);
|
||||||
} else {
|
} else {
|
||||||
JSONObject o = request(msg.getCommand(), msg.getQ());
|
JSONObject o = request(msg.getCommand(), msg.getQ(), true);
|
||||||
return new TMessage(o.getJSONObject("result"), this);
|
return new TMessage(o.getJSONObject("result"), this);
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
@ -179,6 +176,15 @@ public class TelegramAPI implements Runnable {
|
||||||
}).start();
|
}).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) {
|
public void updateCaption(final String newCaption, int chatid, int msg_id, TReplyMarkup rm, boolean async, Callback<JSONObject, ?> clb) {
|
||||||
try {
|
try {
|
||||||
String rply = "";
|
String rply = "";
|
||||||
|
@ -233,7 +239,7 @@ public class TelegramAPI implements Runnable {
|
||||||
|
|
||||||
private void fetchUpdates() {
|
private void fetchUpdates() {
|
||||||
try {
|
try {
|
||||||
processUpdates(request("getUpdates", "offset=" + msg_offset));
|
processUpdates(request("getUpdates", "offset=" + msg_offset, false));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log("error getting updates.", e);
|
log.log("error getting updates.", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue