Bladeren bron

Added support for cancelling certain Telegram events

mastercake10 6 jaren geleden
bovenliggende
commit
2a4273afe1

+ 3 - 3
src/main/java/de/Linus122/TelegramChat/Telegram.java

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

+ 13 - 0
src/main/java/de/Linus122/TelegramComponents/Cancellable.java

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

+ 1 - 1
src/main/java/de/Linus122/TelegramComponents/ChatMessageToMc.java

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

+ 1 - 1
src/main/java/de/Linus122/TelegramComponents/ChatMessageToTelegram.java

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