Merge branch 'master' of ssh://git.mrbesen.de:2222/GamingServerGeraet/TelegramAPI
This commit is contained in:
commit
da67d9c27a
|
@ -206,6 +206,21 @@ public class TelegramAPI implements Runnable {
|
||||||
}).start();
|
}).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!
|
* creates internal APIEror, when message is not modyfied!
|
||||||
* @param newCaption
|
* @param newCaption
|
||||||
|
@ -482,8 +497,9 @@ public class TelegramAPI implements Runnable {
|
||||||
JSONObject cbq = json.getJSONObject("callback_query");
|
JSONObject cbq = json.getJSONObject("callback_query");
|
||||||
TUser from = api.getUser(cbq.getJSONObject("from"));
|
TUser from = api.getUser(cbq.getJSONObject("from"));
|
||||||
String data = cbq.getString("data");
|
String data = cbq.getString("data");
|
||||||
|
String id = cbq.getString("id");
|
||||||
TMessage msg = new TMessage(cbq.getJSONObject("message"), api);
|
TMessage msg = new TMessage(cbq.getJSONObject("message"), api);
|
||||||
getEventManager().callEvent(new UserCallbackEvent(from, data, msg));
|
getEventManager().callEvent(new UserCallbackEvent(from, data, id, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class CommandManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//do smth. with result
|
//do smth. with result
|
||||||
if(!result) {
|
if(!result && json.getChatID() < 0) {
|
||||||
TUser.sendMessage(api, json.getChatID(), api.getHelpMessage(), null, 0, true, null);
|
TUser.sendMessage(api, json.getChatID(), api.getHelpMessage(), null, 0, true, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,13 @@ public class UserCallbackEvent extends Event {
|
||||||
|
|
||||||
private final String data;
|
private final String data;
|
||||||
private final TMessage msg;
|
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);
|
super(u);
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TMessage getMsg() {
|
public TMessage getMsg() {
|
||||||
|
@ -29,4 +31,7 @@ public class UserCallbackEvent extends Event {
|
||||||
return new JSONObject(data);
|
return new JSONObject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue