ソースを参照

Merge branch 'master' of ssh://git.mrbesen.de:2222/GamingServerGeraet/TelegramAPI

master
MrBesen 1ヶ月前
コミット
da67d9c27a
署名者: MrBesen <y.g.2@gmx.de> GPGキーID: 596B2350DCD67504
3個のファイルの変更24行の追加3行の削除
  1. +17
    -1
      src/main/java/de/mrbesen/telegram/TelegramAPI.java
  2. +1
    -1
      src/main/java/de/mrbesen/telegram/commands/CommandManager.java
  3. +6
    -1
      src/main/java/de/mrbesen/telegram/event/events/UserCallbackEvent.java

+ 17
- 1
src/main/java/de/mrbesen/telegram/TelegramAPI.java ファイルの表示

@@ -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
@@ -482,8 +497,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));
}
}


+ 1
- 1
src/main/java/de/mrbesen/telegram/commands/CommandManager.java ファイルの表示

@@ -47,7 +47,7 @@ public class CommandManager {
}
}
//do smth. with result
if(!result) {
if(!result && json.getChatID() < 0) {
TUser.sendMessage(api, json.getChatID(), api.getHelpMessage(), null, 0, true, null);
}
}

+ 6
- 1
src/main/java/de/mrbesen/telegram/event/events/UserCallbackEvent.java ファイルの表示

@@ -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;
}
}

読み込み中…
キャンセル
保存