1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added notify triggers WIP

This commit is contained in:
James Booth 2015-11-23 23:43:53 +00:00
parent e8c0eeda8b
commit b79d77409f
5 changed files with 116 additions and 12 deletions

View File

@ -1054,7 +1054,7 @@ static struct cmd_t command_defs[] =
}, },
{ "/notify", { "/notify",
cmd_notify, parse_args, 2, 3, &cons_notify_setting, cmd_notify, parse_args_with_freetext, 2, 4, &cons_notify_setting,
CMD_TAGS( CMD_TAGS(
CMD_TAG_UI, CMD_TAG_UI,
CMD_TAG_CHAT, CMD_TAG_CHAT,
@ -1063,9 +1063,17 @@ static struct cmd_t command_defs[] =
"/notify message on|off", "/notify message on|off",
"/notify message current on|off", "/notify message current on|off",
"/notify message text 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 on|off|mention",
"/notify room current on|off", "/notify room current on|off",
"/notify room text 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 remind <seconds>",
"/notify typing on|off", "/notify typing on|off",
"/notify typing current on|off", "/notify typing current on|off",
@ -1077,9 +1085,17 @@ static struct cmd_t command_defs[] =
{ "message on|off", "Notifications for regular chat messages." }, { "message on|off", "Notifications for regular chat messages." },
{ "message current on|off", "Whether messages in the current window trigger notifications." }, { "message current on|off", "Whether messages in the current window trigger notifications." },
{ "message text on|off", "Show message text in regular message 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 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 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 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." }, { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." },
{ "typing on|off", "Notifications when contacts are typing." }, { "typing on|off", "Notifications when contacts are typing." },
{ "typing current on|off", "Whether typing notifications are triggered for the current window." }, { "typing current on|off", "Whether typing notifications are triggered for the current window." },
@ -1777,6 +1793,7 @@ static Autocomplete notify_ac;
static Autocomplete notify_room_ac; static Autocomplete notify_room_ac;
static Autocomplete notify_message_ac; static Autocomplete notify_message_ac;
static Autocomplete notify_typing_ac; static Autocomplete notify_typing_ac;
static Autocomplete notify_trigger_ac;
static Autocomplete prefs_ac; static Autocomplete prefs_ac;
static Autocomplete sub_ac; static Autocomplete sub_ac;
static Autocomplete log_ac; static Autocomplete log_ac;
@ -1915,6 +1932,7 @@ cmd_init(void)
autocomplete_add(notify_message_ac, "off"); autocomplete_add(notify_message_ac, "off");
autocomplete_add(notify_message_ac, "current"); autocomplete_add(notify_message_ac, "current");
autocomplete_add(notify_message_ac, "text"); autocomplete_add(notify_message_ac, "text");
autocomplete_add(notify_message_ac, "trigger");
notify_room_ac = autocomplete_new(); notify_room_ac = autocomplete_new();
autocomplete_add(notify_room_ac, "on"); autocomplete_add(notify_room_ac, "on");
@ -1922,12 +1940,20 @@ cmd_init(void)
autocomplete_add(notify_room_ac, "mention"); autocomplete_add(notify_room_ac, "mention");
autocomplete_add(notify_room_ac, "current"); autocomplete_add(notify_room_ac, "current");
autocomplete_add(notify_room_ac, "text"); autocomplete_add(notify_room_ac, "text");
autocomplete_add(notify_room_ac, "trigger");
notify_typing_ac = autocomplete_new(); notify_typing_ac = autocomplete_new();
autocomplete_add(notify_typing_ac, "on"); autocomplete_add(notify_typing_ac, "on");
autocomplete_add(notify_typing_ac, "off"); autocomplete_add(notify_typing_ac, "off");
autocomplete_add(notify_typing_ac, "current"); 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(); sub_ac = autocomplete_new();
autocomplete_add(sub_ac, "request"); autocomplete_add(sub_ac, "request");
autocomplete_add(sub_ac, "allow"); autocomplete_add(sub_ac, "allow");
@ -2324,6 +2350,7 @@ cmd_uninit(void)
autocomplete_free(notify_message_ac); autocomplete_free(notify_message_ac);
autocomplete_free(notify_room_ac); autocomplete_free(notify_room_ac);
autocomplete_free(notify_typing_ac); autocomplete_free(notify_typing_ac);
autocomplete_free(notify_trigger_ac);
autocomplete_free(sub_ac); autocomplete_free(sub_ac);
autocomplete_free(titlebar_ac); autocomplete_free(titlebar_ac);
autocomplete_free(log_ac); autocomplete_free(log_ac);
@ -2510,6 +2537,7 @@ cmd_reset_autocomplete(ProfWin *window)
autocomplete_reset(notify_message_ac); autocomplete_reset(notify_message_ac);
autocomplete_reset(notify_room_ac); autocomplete_reset(notify_room_ac);
autocomplete_reset(notify_typing_ac); autocomplete_reset(notify_typing_ac);
autocomplete_reset(notify_trigger_ac);
autocomplete_reset(sub_ac); autocomplete_reset(sub_ac);
autocomplete_reset(who_room_ac); autocomplete_reset(who_room_ac);
@ -3127,11 +3155,21 @@ _notify_autocomplete(ProfWin *window, const char *const input)
return result; 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); result = autocomplete_param_with_func(input, "/notify message current", prefs_autocomplete_boolean_choice);
if (result) { if (result) {
return 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); result = autocomplete_param_with_func(input, "/notify typing current", prefs_autocomplete_boolean_choice);
if (result) { if (result) {
return result; return result;

View File

@ -4207,6 +4207,30 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
cons_show("Usage: /notify message text on|off"); 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 { } else {
cons_show("Usage: /notify message on|off"); cons_show("Usage: /notify message on|off");
} }
@ -4242,6 +4266,30 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
cons_show("Usage: /notify room text on|off"); 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 { } else {
cons_show("Usage: /notify room on|off|mention"); cons_show("Usage: /notify room on|off|mention");
} }

View File

@ -782,9 +782,11 @@ _get_group(preference_t pref)
case PREF_NOTIFY_MESSAGE: case PREF_NOTIFY_MESSAGE:
case PREF_NOTIFY_MESSAGE_CURRENT: case PREF_NOTIFY_MESSAGE_CURRENT:
case PREF_NOTIFY_MESSAGE_TEXT: case PREF_NOTIFY_MESSAGE_TEXT:
case PREF_NOTIFY_MESSAGE_TRIGGER:
case PREF_NOTIFY_ROOM: case PREF_NOTIFY_ROOM:
case PREF_NOTIFY_ROOM_CURRENT: case PREF_NOTIFY_ROOM_CURRENT:
case PREF_NOTIFY_ROOM_TEXT: case PREF_NOTIFY_ROOM_TEXT:
case PREF_NOTIFY_ROOM_TRIGGER:
case PREF_NOTIFY_INVITE: case PREF_NOTIFY_INVITE:
case PREF_NOTIFY_SUB: case PREF_NOTIFY_SUB:
return PREF_GROUP_NOTIFICATIONS; return PREF_GROUP_NOTIFICATIONS;
@ -875,12 +877,16 @@ _get_key(preference_t pref)
return "message.current"; return "message.current";
case PREF_NOTIFY_MESSAGE_TEXT: case PREF_NOTIFY_MESSAGE_TEXT:
return "message.text"; return "message.text";
case PREF_NOTIFY_MESSAGE_TRIGGER:
return "message.trigger";
case PREF_NOTIFY_ROOM: case PREF_NOTIFY_ROOM:
return "room"; return "room";
case PREF_NOTIFY_ROOM_CURRENT: case PREF_NOTIFY_ROOM_CURRENT:
return "room.current"; return "room.current";
case PREF_NOTIFY_ROOM_TEXT: case PREF_NOTIFY_ROOM_TEXT:
return "room.text"; return "room.text";
case PREF_NOTIFY_ROOM_TRIGGER:
return "room.trigger";
case PREF_NOTIFY_INVITE: case PREF_NOTIFY_INVITE:
return "invite"; return "invite";
case PREF_NOTIFY_SUB: case PREF_NOTIFY_SUB:

View File

@ -96,9 +96,11 @@ typedef enum {
PREF_NOTIFY_MESSAGE, PREF_NOTIFY_MESSAGE,
PREF_NOTIFY_MESSAGE_CURRENT, PREF_NOTIFY_MESSAGE_CURRENT,
PREF_NOTIFY_MESSAGE_TEXT, PREF_NOTIFY_MESSAGE_TEXT,
PREF_NOTIFY_MESSAGE_TRIGGER,
PREF_NOTIFY_ROOM, PREF_NOTIFY_ROOM,
PREF_NOTIFY_ROOM_CURRENT, PREF_NOTIFY_ROOM_CURRENT,
PREF_NOTIFY_ROOM_TEXT, PREF_NOTIFY_ROOM_TEXT,
PREF_NOTIFY_ROOM_TRIGGER,
PREF_NOTIFY_INVITE, PREF_NOTIFY_INVITE,
PREF_NOTIFY_SUB, PREF_NOTIFY_SUB,
PREF_CHLOG, PREF_CHLOG,

View File

@ -1339,6 +1339,11 @@ cons_notify_setting(void)
else else
cons_show("Messages text (/notify message) : OFF"); cons_show("Messages text (/notify message) : OFF");
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TRIGGER))
cons_show("Messages trigger (/notify message) : ON");
else
cons_show("Messages trigger (/notify message) : OFF");
char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM); char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
if (g_strcmp0(room_setting, "on") == 0) { if (g_strcmp0(room_setting, "on") == 0) {
cons_show ("Room messages (/notify room) : ON"); cons_show ("Room messages (/notify room) : ON");
@ -1359,6 +1364,11 @@ cons_notify_setting(void)
else else
cons_show("Room text (/notify room) : OFF"); cons_show("Room text (/notify room) : OFF");
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER))
cons_show("Room trigger (/notify room) : ON");
else
cons_show("Room trigger (/notify room) : OFF");
if (prefs_get_boolean(PREF_NOTIFY_TYPING)) if (prefs_get_boolean(PREF_NOTIFY_TYPING))
cons_show("Composing (/notify typing) : ON"); cons_show("Composing (/notify typing) : ON");
else else