about summary refs log tree commit diff stats
path: root/src/command/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/commands.c')
-rw-r--r--src/command/commands.c109
1 files changed, 103 insertions, 6 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 5781ae5c..b87cf1f5 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4302,6 +4302,51 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
             } else {
                 cons_show("Usage: /notify message text on|off");
             }
+        } else if (g_strcmp0(args[1], "trigger") == 0) {
+            if (g_strcmp0(args[2], "add") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_add_msg_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Adding message notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Message notification trigger already exists: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "remove") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_remove_msg_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Removing message notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Message notification trigger does not exist: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "list") == 0) {
+                GList *triggers = prefs_get_msg_notify_triggers();
+                GList *curr = triggers;
+                if (curr) {
+                    cons_show("Message notification triggers:");
+                } else {
+                    cons_show("No message notification triggers");
+                }
+                while (curr) {
+                    cons_show("  %s", curr->data);
+                    curr = g_list_next(curr);
+                }
+                g_list_free_full(triggers, free);
+            } else if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Enabling message notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Disabling message notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, FALSE);
+            } else {
+                cons_bad_cmd_usage(command);
+            }
         } else {
             cons_show("Usage: /notify message on|off");
         }
@@ -4309,14 +4354,21 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
     // set room setting
     } else if (strcmp(kind, "room") == 0) {
         if (strcmp(args[1], "on") == 0) {
-            cons_show("Chat room notifications enabled.");
-            prefs_set_string(PREF_NOTIFY_ROOM, "on");
+            cons_show("Room notifications enabled.");
+            prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE);
         } else if (strcmp(args[1], "off") == 0) {
-            cons_show("Chat room notifications disabled.");
-            prefs_set_string(PREF_NOTIFY_ROOM, "off");
+            cons_show("Room notifications disabled.");
+            prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE);
         } else if (strcmp(args[1], "mention") == 0) {
-            cons_show("Chat room notifications enabled on mention.");
-            prefs_set_string(PREF_NOTIFY_ROOM, "mention");
+            if (strcmp(args[2], "on") == 0) {
+                cons_show("Room notifications with mention enabled.");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, TRUE);
+            } else if (strcmp(args[2], "off") == 0) {
+                cons_show("Room notifications with mention disabled.");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, FALSE);
+            } else {
+                cons_show("Usage: /notify room mention on|off");
+            }
         } else if (strcmp(args[1], "current") == 0) {
             if (g_strcmp0(args[2], "on") == 0) {
                 cons_show("Current window chat room message notifications enabled.");
@@ -4337,6 +4389,51 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
             } else {
                 cons_show("Usage: /notify room text on|off");
             }
+        } else if (g_strcmp0(args[1], "trigger") == 0) {
+            if (g_strcmp0(args[2], "add") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_add_room_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Adding room notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Room notification trigger already exists: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "remove") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_remove_room_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Removing room notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Room notification trigger does not exist: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "list") == 0) {
+                GList *triggers = prefs_get_room_notify_triggers();
+                GList *curr = triggers;
+                if (curr) {
+                    cons_show("Room notification triggers:");
+                } else {
+                    cons_show("No room notification triggers");
+                }
+                while (curr) {
+                    cons_show("  %s", curr->data);
+                    curr = g_list_next(curr);
+                }
+                g_list_free_full(triggers, free);
+            } else if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Enabling room notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Disabling room notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, FALSE);
+            } else {
+                cons_bad_cmd_usage(command);
+            }
         } else {
             cons_show("Usage: /notify room on|off|mention");
         }