summary refs log tree commit diff stats
path: root/src/fe-gtk/plugin-notification.c
diff options
context:
space:
mode:
authorBakasuraRCE <bakasura@protonmail.ch>2020-07-29 09:50:12 -0500
committerPatrick <tingping@tingping.se>2021-05-23 21:17:07 -0500
commitda26097aab554c44540c25f0741dc19f6e92cc41 (patch)
tree6212a727562862d555d5970fba00d4651d82e309 /src/fe-gtk/plugin-notification.c
parente03fab07ed77db699abbde01e2b872019df07b80 (diff)
notification: Implement notification option for channels
Diffstat (limited to 'src/fe-gtk/plugin-notification.c')
-rw-r--r--src/fe-gtk/plugin-notification.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/fe-gtk/plugin-notification.c b/src/fe-gtk/plugin-notification.c
index 3ac89244..29478d7a 100644
--- a/src/fe-gtk/plugin-notification.c
+++ b/src/fe-gtk/plugin-notification.c
@@ -25,6 +25,9 @@
 
 static hexchat_plugin *ph;
 
+const int CHANNEL_FLAG_BALLOON       = 1 << 21;
+const int CHANNEL_FLAG_BALLOON_UNSET = 1 << 22;
+
 static gboolean
 should_alert (void)
 {
@@ -117,10 +120,24 @@ static int
 incoming_message_cb (char *word[], gpointer userdata)
 {
 	int message;
+	int flags;
+	int alert = 0;
+
+	flags = hexchat_list_int(ph, NULL, "flags");
+
+	/* Let sure that can alert */
+	if (should_alert()) {
+		/* Follow the channel rules if set */
+		if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
+			alert = (flags & CHANNEL_FLAG_BALLOON);
+		} else {
+			/* Else follow global environment */
+			alert = (hexchat_get_prefs(ph, "input_balloon_chans", NULL, &message) == 3 && message);
+		}
+	}
 
-	if (hexchat_get_prefs (ph, "input_balloon_chans", NULL, &message) == 3 && message && should_alert ())
-	{
-		show_notificationf (word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel"));
+	if (alert) {
+		show_notificationf(word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info(ph, "channel"));
 	}
 	return HEXCHAT_EAT_NONE;
 }
@@ -129,8 +146,23 @@ static int
 incoming_priv_cb (char *word[], gpointer userdata)
 {
 	int priv;
+	int flags;
+	int alert = 0;
+
+	flags = hexchat_list_int(ph, NULL, "flags");
+
+	/* Let sure that can alert */
+	if (should_alert()) {
+		/* Follow the private rules if set */
+		if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
+			alert = (flags & CHANNEL_FLAG_BALLOON);
+		} else {
+			/* Else follow global environment */
+			alert = (hexchat_get_prefs(ph, "input_balloon_priv", NULL, &priv) == 3 && priv);
+		}
+	}
 
-	if (hexchat_get_prefs (ph, "input_balloon_priv", NULL, &priv) == 3 && priv && should_alert ())
+	if (alert)
 	{
 		const char *network = hexchat_get_info (ph, "network");
 		if (!network)