Browse Source

Silent update

* Adding an option to remove the need-to-link message spamming everyone. (usefull if you don't want to configure the link FROM telegram -> TO server
* Adding an option to add only silent messages (telegram message without audio notification)
Arthessia Derven 1 year ago
parent
commit
5e9a68281c

+ 12 - 2
src/main/java/de/Linus122/Telegram/Telegram.java

@@ -156,13 +156,17 @@ public class Telegram {
 					TelegramChat.getInstance().getLogger().info("Omitted message Telegram->MC because it was sent while the server was offline.");
 				}
 			}
+		} else {
+			boolean skipIfNeedToLinkSilent = TelegramChat.getInstance().getConfig().getBoolean("omit-messages-need-to-link");
+			if (!skipIfNeedToLinkSilent) {
+				this.sendMsg(chat.getId(), Utils.formatMSG("need-to-link")[0]);
+			}
 		}
 	}
 
 	public void sendMsg(long id, String msg) {
 		ChatMessageToTelegram chat = new ChatMessageToTelegram();
 		chat.chat_id = id;
-		chat.disable_notification = true;
 		chat.text = msg;
 		sendMsg(chat);
 	}
@@ -171,6 +175,13 @@ public class Telegram {
 		for (TelegramActionListener actionListener : listeners) {
 			actionListener.onSendToTelegram(chat);
 		}
+		boolean turnNotificationToSilent = TelegramChat.getInstance().getConfig().getBoolean("turn-to-silent-notification");
+		if(turnNotificationToSilent) {
+			chat.disable_notification = true;
+		} else {
+			chat.disable_notification = false;
+		}
+		
 		Gson gson = new Gson();
 		if(!chat.isCancelled()){
 			post("sendMessage", gson.toJson(chat, ChatMessageToTelegram.class));	
@@ -182,7 +193,6 @@ public class Telegram {
 			public void run() {
 				for (long id : TelegramChat.getBackend().chat_ids) {
 					chat.chat_id = id;
-					chat.disable_notification = true;
 					// post("sendMessage", gson.toJson(chat, Chat.class));
 					sendMsg(chat);
 				}

+ 2 - 0
src/main/resources/config.yml

@@ -20,3 +20,5 @@ enable-chatmessages: true
 
 # this will prevent mass-sending unsent messages from telegram to mc upon server startup
 omit-messages-sent-while-server-was-offline: true
+omit-messages-need-to-link: false
+turn-to-silent-notification: false

+ 1 - 1
src/main/resources/plugin.yml

@@ -1,7 +1,7 @@
 name: TelegramChat
 main: de.Linus122.TelegramChat.TelegramChat
 version: ${project.version}
-authors: [Linus122]
+authors: [Linus122, Arthessia]
 softdepend: [Vault, SuperVanish, PremiumVanish]
 description: Brings minecraft chat to Telegram!
 commands: