chatnotifications: Add notification for broadcast messages

This commit is contained in:
Broooklyn
2020-06-04 22:31:01 -07:00
committed by Adam
parent 3379494a67
commit bd116e99e6
2 changed files with 27 additions and 0 deletions

View File

@@ -97,4 +97,15 @@ public interface ChatNotificationsConfig extends Config
{
return false;
}
@ConfigItem(
position = 6,
keyName = "notifyOnBroadcast",
name = "Notify on broadcast",
description = "Notifies you whenever you receive a broadcast message"
)
default boolean notifyOnBroadcast()
{
return false;
}
}

View File

@@ -144,6 +144,22 @@ public class ChatNotificationsPlugin extends Plugin
notifier.notify(chatMessage.getMessage());
}
break;
case BROADCAST:
if (config.notifyOnBroadcast())
{
// Some broadcasts have links attached, notated by `|` followed by a number, while others contain color tags.
// We don't want to see either in the printed notification.
String broadcast = chatMessage.getMessage();
int urlTokenIndex = broadcast.lastIndexOf('|');
if (urlTokenIndex != -1)
{
broadcast = broadcast.substring(0, urlTokenIndex);
}
notifier.notify(Text.removeFormattingTags(broadcast));
}
break;
case CONSOLE:
// Don't notify for notification messages
if (chatMessage.getName().equals(RuneLiteProperties.getTitle()))