chatnotifications: Add notification for broadcast messages
This commit is contained in:
@@ -97,4 +97,15 @@ public interface ChatNotificationsConfig extends Config
|
|||||||
{
|
{
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,22 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
notifier.notify(chatMessage.getMessage());
|
notifier.notify(chatMessage.getMessage());
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case CONSOLE:
|
||||||
// Don't notify for notification messages
|
// Don't notify for notification messages
|
||||||
if (chatMessage.getName().equals(RuneLiteProperties.getTitle()))
|
if (chatMessage.getName().equals(RuneLiteProperties.getTitle()))
|
||||||
|
|||||||
Reference in New Issue
Block a user