Added support for cancelling certain Telegram events

This commit is contained in:
mastercake10 2018-05-20 14:33:55 +02:00
parent 06923bec46
commit 2a4273afe1
4 changed files with 18 additions and 5 deletions

View File

@ -140,9 +140,9 @@ public class Telegram {
actionListener.onSendToTelegram(chat); actionListener.onSendToTelegram(chat);
} }
Gson gson = new Gson(); Gson gson = new Gson();
if(!chat.isCancelled()){
post("sendMessage", gson.toJson(chat, ChatMessageToTelegram.class)); post("sendMessage", gson.toJson(chat, ChatMessageToTelegram.class));
}
} }
public void sendAll(final ChatMessageToTelegram chat) { public void sendAll(final ChatMessageToTelegram chat) {

View File

@ -0,0 +1,13 @@
package de.Linus122.TelegramComponents;
public class Cancellable {
private boolean isCancelled = false;
public boolean isCancelled() {
return isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
}

View File

@ -2,7 +2,7 @@ package de.Linus122.TelegramComponents;
import java.util.UUID; import java.util.UUID;
public class ChatMessageToMc { public class ChatMessageToMc extends Cancellable{
UUID uuid_sender; UUID uuid_sender;
String content; String content;
int chatID_sender; int chatID_sender;

View File

@ -1,6 +1,6 @@
package de.Linus122.TelegramComponents; package de.Linus122.TelegramComponents;
public class ChatMessageToTelegram { public class ChatMessageToTelegram extends Cancellable{
public String text; public String text;
public int chat_id; public int chat_id;
public String parse_mode; public String parse_mode;