diff options
author | James Booth <boothj5@gmail.com> | 2015-11-23 23:43:53 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-23 23:43:53 +0000 |
commit | b79d77409fe3d7f342055dd2826b3f51f797613e (patch) | |
tree | 5ec21909a1db397f38200ea4853588c263d87e37 /src/command | |
parent | e8c0eeda8b87ed2c65f846a89834143d4da7eabd (diff) | |
download | profani-tty-b79d77409fe3d7f342055dd2826b3f51f797613e.tar.gz |
Added notify triggers WIP
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 62 | ||||
-rw-r--r-- | src/command/commands.c | 48 |
2 files changed, 98 insertions, 12 deletions
diff --git a/src/command/command.c b/src/command/command.c index bc2ee121..3ef41ecb 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1054,7 +1054,7 @@ static struct cmd_t command_defs[] = }, { "/notify", - cmd_notify, parse_args, 2, 3, &cons_notify_setting, + cmd_notify, parse_args_with_freetext, 2, 4, &cons_notify_setting, CMD_TAGS( CMD_TAG_UI, CMD_TAG_CHAT, @@ -1063,9 +1063,17 @@ static struct cmd_t command_defs[] = "/notify message on|off", "/notify message current on|off", "/notify message text on|off", + "/notify message trigger add <text>", + "/notify message trigger remove <text>", + "/notify message trigger list", + "/notify message trigger on|off", "/notify room on|off|mention", "/notify room current on|off", "/notify room text on|off", + "/notify room trigger add <text>", + "/notify room trigger remove <text>", + "/notify room trigger list", + "/notify room trigger on|off", "/notify remind <seconds>", "/notify typing on|off", "/notify typing current on|off", @@ -1074,17 +1082,25 @@ static struct cmd_t command_defs[] = CMD_DESC( "Settings for various kinds of desktop notifications.") CMD_ARGS( - { "message on|off", "Notifications for regular chat messages." }, - { "message current on|off", "Whether messages in the current window trigger notifications." }, - { "message text on|off", "Show message text in regular message notifications." }, - { "room on|off|mention", "Notifications for chat room messages, mention triggers notifications only when your nick is mentioned." }, - { "room current on|off", "Whether chat room messages in the current window trigger notifications." }, - { "room text on|off", "Show message text in chat room message notifications." }, - { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." }, - { "typing on|off", "Notifications when contacts are typing." }, - { "typing current on|off", "Whether typing notifications are triggered for the current window." }, - { "invite on|off", "Notifications for chat room invites." }, - { "sub on|off", "Notifications for subscription requests." }) + { "message on|off", "Notifications for regular chat messages." }, + { "message current on|off", "Whether messages in the current window trigger notifications." }, + { "message text on|off", "Show message text in regular message notifications." }, + { "message trigger add <text>", "Notify when specified text included in regular chat message." }, + { "message trigger remove <text>", "Remove regular chat notification for specified text." }, + { "message trigger list", "List all regular chat custom text notifications." }, + { "message trigger on|off", "Enable or disable all regular chat custom text notifications." }, + { "room on|off|mention", "Notifications for chat room messages, mention triggers notifications only when your nick is mentioned." }, + { "room current on|off", "Whether chat room messages in the current window trigger notifications." }, + { "room text on|off", "Show message text in chat room message notifications." }, + { "room trigger add <text>", "Notify when specified text included in regular chat message." }, + { "room trigger remove <text>", "Remove regular chat notification for specified text." }, + { "room trigger list", "List all regular chat custom text notifications." }, + { "room trigger on|off", "Enable or disable all regular chat custom text notifications." }, + { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." }, + { "typing on|off", "Notifications when contacts are typing." }, + { "typing current on|off", "Whether typing notifications are triggered for the current window." }, + { "invite on|off", "Notifications for chat room invites." }, + { "sub on|off", "Notifications for subscription requests." }) CMD_EXAMPLES( "/notify message on", "/notify message text on", @@ -1777,6 +1793,7 @@ static Autocomplete notify_ac; static Autocomplete notify_room_ac; static Autocomplete notify_message_ac; static Autocomplete notify_typing_ac; +static Autocomplete notify_trigger_ac; static Autocomplete prefs_ac; static Autocomplete sub_ac; static Autocomplete log_ac; @@ -1915,6 +1932,7 @@ cmd_init(void) autocomplete_add(notify_message_ac, "off"); autocomplete_add(notify_message_ac, "current"); autocomplete_add(notify_message_ac, "text"); + autocomplete_add(notify_message_ac, "trigger"); notify_room_ac = autocomplete_new(); autocomplete_add(notify_room_ac, "on"); @@ -1922,12 +1940,20 @@ cmd_init(void) autocomplete_add(notify_room_ac, "mention"); autocomplete_add(notify_room_ac, "current"); autocomplete_add(notify_room_ac, "text"); + autocomplete_add(notify_room_ac, "trigger"); notify_typing_ac = autocomplete_new(); autocomplete_add(notify_typing_ac, "on"); autocomplete_add(notify_typing_ac, "off"); autocomplete_add(notify_typing_ac, "current"); + notify_trigger_ac = autocomplete_new(); + autocomplete_add(notify_trigger_ac, "add"); + autocomplete_add(notify_trigger_ac, "remove"); + autocomplete_add(notify_trigger_ac, "list"); + autocomplete_add(notify_trigger_ac, "on"); + autocomplete_add(notify_trigger_ac, "off"); + sub_ac = autocomplete_new(); autocomplete_add(sub_ac, "request"); autocomplete_add(sub_ac, "allow"); @@ -2324,6 +2350,7 @@ cmd_uninit(void) autocomplete_free(notify_message_ac); autocomplete_free(notify_room_ac); autocomplete_free(notify_typing_ac); + autocomplete_free(notify_trigger_ac); autocomplete_free(sub_ac); autocomplete_free(titlebar_ac); autocomplete_free(log_ac); @@ -2510,6 +2537,7 @@ cmd_reset_autocomplete(ProfWin *window) autocomplete_reset(notify_message_ac); autocomplete_reset(notify_room_ac); autocomplete_reset(notify_typing_ac); + autocomplete_reset(notify_trigger_ac); autocomplete_reset(sub_ac); autocomplete_reset(who_room_ac); @@ -3127,11 +3155,21 @@ _notify_autocomplete(ProfWin *window, const char *const input) return result; } + result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_func(input, "/notify message current", prefs_autocomplete_boolean_choice); if (result) { return result; } + result = autocomplete_param_with_ac(input, "/notify message trigger", notify_trigger_ac, TRUE); + if (result) { + return result; + } + result = autocomplete_param_with_func(input, "/notify typing current", prefs_autocomplete_boolean_choice); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index c17dca43..ec30c2a8 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -4207,6 +4207,30 @@ 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 { + cons_show("Adding trigger: %s", args[3]); + } + } else if (g_strcmp0(args[2], "remove") == 0) { + if (!args[3]) { + cons_bad_cmd_usage(command); + } else { + cons_show("Removing trigger: %s", args[3]); + } + } else if (g_strcmp0(args[2], "list") == 0) { + cons_show("Listing triggers"); + } else if (g_strcmp0(args[2], "on") == 0) { + cons_show("Enabling message triggers"); + prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, TRUE); + } else if (g_strcmp0(args[2], "off") == 0) { + cons_show("Disabling message triggers"); + prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, FALSE); + } else { + cons_bad_cmd_usage(command); + } } else { cons_show("Usage: /notify message on|off"); } @@ -4242,6 +4266,30 @@ 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 { + cons_show("Adding trigger: %s", args[3]); + } + } else if (g_strcmp0(args[2], "remove") == 0) { + if (!args[3]) { + cons_bad_cmd_usage(command); + } else { + cons_show("Removing trigger: %s", args[3]); + } + } else if (g_strcmp0(args[2], "list") == 0) { + cons_show("Listing triggers"); + } else if (g_strcmp0(args[2], "on") == 0) { + cons_show("Enabling room triggers"); + prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, TRUE); + } else if (g_strcmp0(args[2], "off") == 0) { + cons_show("Disabling room triggers"); + prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, FALSE); + } else { + cons_bad_cmd_usage(command); + } } else { cons_show("Usage: /notify room on|off|mention"); } |