about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorStefan Ott <stefan@ott.net>2022-04-14 04:25:30 +0200
committerStefan Ott <stefan@ott.net>2022-04-23 02:42:23 +0200
commit8044c82614ad63b60cc0805b0335150eaccb50aa (patch)
tree50a6f61ab49f2a6e38f82cf4c2177bbde5164be0 /src/command
parent652d30bb7f7ce4dc89eebcbb4b796f10249a8be1 (diff)
downloadprofani-tty-8044c82614ad63b60cc0805b0335150eaccb50aa.tar.gz
Add support for offline MUC notifications
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c11
-rw-r--r--src/command/cmd_defs.c3
-rw-r--r--src/command/cmd_funcs.c10
3 files changed, 24 insertions, 0 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 3024ab17..ac4e3726 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -146,6 +146,7 @@ static Autocomplete notify_chat_ac;
 static Autocomplete notify_room_ac;
 static Autocomplete notify_typing_ac;
 static Autocomplete notify_mention_ac;
+static Autocomplete notify_offline_ac;
 static Autocomplete notify_trigger_ac;
 static Autocomplete prefs_ac;
 static Autocomplete sub_ac;
@@ -344,6 +345,7 @@ cmd_ac_init(void)
     autocomplete_add(notify_room_ac, "on");
     autocomplete_add(notify_room_ac, "off");
     autocomplete_add(notify_room_ac, "mention");
+    autocomplete_add(notify_room_ac, "offline");
     autocomplete_add(notify_room_ac, "current");
     autocomplete_add(notify_room_ac, "text");
     autocomplete_add(notify_room_ac, "trigger");
@@ -361,6 +363,10 @@ cmd_ac_init(void)
     autocomplete_add(notify_mention_ac, "word_whole");
     autocomplete_add(notify_mention_ac, "word_part");
 
+    notify_offline_ac = autocomplete_new();
+    autocomplete_add(notify_offline_ac, "on");
+    autocomplete_add(notify_offline_ac, "off");
+
     notify_trigger_ac = autocomplete_new();
     autocomplete_add(notify_trigger_ac, "add");
     autocomplete_add(notify_trigger_ac, "remove");
@@ -2338,6 +2344,11 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
         return result;
     }
 
+    result = autocomplete_param_with_ac(input, "/notify room offline", notify_offline_ac, TRUE, previous);
+    if (result) {
+        return result;
+    }
+
     result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE, previous);
     if (result) {
         return result;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 281d21c6..e18b3bff 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1436,6 +1436,7 @@ static struct cmd_t command_defs[] = {
               "/notify room mention on|off",
               "/notify room mention case_sensitive|case_insensitive",
               "/notify room mention word_whole|word_part",
+              "/notify room offline on|off",
               "/notify room current on|off",
               "/notify room text on|off",
               "/notify room trigger add <text>",
@@ -1464,6 +1465,7 @@ static struct cmd_t command_defs[] = {
               { "room mention case_insensitive", "Set room mention notifications as case insensitive." },
               { "room mention word_whole", "Set room mention notifications only on whole word match, i.e. when nickname is not part of a larger word." },
               { "room mention word_part", "Set room mention notifications on partial word match, i.e. nickname may be part of a larger word." },
+              { "room offline on|off", "Notifications for chat room messages that were sent while you were offline." },
               { "room current on|off", "Whether to show all chat room messages notifications when the window is focused." },
               { "room text on|off", "Show message text in chat room message notifications." },
               { "room trigger add <text>", "Notify when specified text included in all chat room messages." },
@@ -1483,6 +1485,7 @@ static struct cmd_t command_defs[] = {
               "/notify chat on",
               "/notify chat text on",
               "/notify room mention on",
+              "/notify room offline on",
               "/notify room trigger add beer",
               "/notify room trigger on",
               "/notify room current off",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 15bf5d7c..fccb937e 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -5775,6 +5775,16 @@ cmd_notify(ProfWin* window, const char* const command, gchar** args)
             } else {
                 cons_show("Usage: /notify room mention on|off");
             }
+        } else if (g_strcmp0(args[1], "offline") == 0) {
+            if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Room notifications for offline messages enabled.");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_OFFLINE, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Room notifications for offline messages disabled.");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_OFFLINE, FALSE);
+            } else {
+                cons_show("Usage: /notify room offline on|off");
+            }
         } else if (g_strcmp0(args[1], "current") == 0) {
             if (g_strcmp0(args[2], "on") == 0) {
                 cons_show("Current window chat room message notifications enabled.");