added awnser callback
This commit is contained in:
parent
f1a1f29608
commit
356485d2cc
|
@ -206,6 +206,21 @@ public class TelegramAPI implements Runnable {
|
|||
}).start();
|
||||
}
|
||||
|
||||
public void answerCallbackQuery(String callbackid, String text, boolean async) {
|
||||
if(callbackid == null)
|
||||
return;
|
||||
|
||||
if(async) {
|
||||
requestAsync("answerCallbackQuery", "callback_query_id=" + callbackid + "&text=" + text);
|
||||
} else {
|
||||
try {
|
||||
request("answerCallbackQuery", "callback_query_id=" + callbackid + "&text=" + text);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates internal APIEror, when message is not modyfied!
|
||||
* @param newCaption
|
||||
|
@ -478,8 +493,9 @@ public class TelegramAPI implements Runnable {
|
|||
JSONObject cbq = json.getJSONObject("callback_query");
|
||||
TUser from = api.getUser(cbq.getJSONObject("from"));
|
||||
String data = cbq.getString("data");
|
||||
String id = cbq.getString("id");
|
||||
TMessage msg = new TMessage(cbq.getJSONObject("message"), api);
|
||||
getEventManager().callEvent(new UserCallbackEvent(from, data, msg));
|
||||
getEventManager().callEvent(new UserCallbackEvent(from, data, id, msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,13 @@ public class UserCallbackEvent extends Event {
|
|||
|
||||
private final String data;
|
||||
private final TMessage msg;
|
||||
private final String id;
|
||||
|
||||
public UserCallbackEvent(TUser u, String data, TMessage msg) {
|
||||
public UserCallbackEvent(TUser u, String data, String id, TMessage msg) {
|
||||
super(u);
|
||||
this.data = data;
|
||||
this.msg = msg;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public TMessage getMsg() {
|
||||
|
@ -29,4 +31,7 @@ public class UserCallbackEvent extends Event {
|
|||
return new JSONObject(data);
|
||||
}
|
||||
|
||||
public final String getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue