mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Removed regular chat message triggers
This commit is contained in:
parent
60305de0d9
commit
2fc984e673
@ -1063,10 +1063,6 @@ 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",
|
"/notify room on|off",
|
||||||
"/notify room mention on|off",
|
"/notify room mention on|off",
|
||||||
"/notify room current on|off",
|
"/notify room current on|off",
|
||||||
@ -1089,10 +1085,6 @@ 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 to show regular chat message notifications when the window is focussed." },
|
{ "message current on|off", "Whether to show regular chat message notifications when the window is focussed." },
|
||||||
{ "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 notification triggers." },
|
|
||||||
{ "room on|off", "Notifications for all chat room messages, 'mention' only notifies when your nick is mentioned." },
|
{ "room on|off", "Notifications for all chat room messages, 'mention' only notifies when your nick is mentioned." },
|
||||||
{ "room mention on|off", "Notifications for all chat room messages when your nick is mentioned." },
|
{ "room mention on|off", "Notifications for all chat room messages when your nick is mentioned." },
|
||||||
{ "room current on|off", "Whether to show all chat room messages notifications when the window is focussed." },
|
{ "room current on|off", "Whether to show all chat room messages notifications when the window is focussed." },
|
||||||
@ -1113,6 +1105,8 @@ static struct cmd_t command_defs[] =
|
|||||||
"/notify message on",
|
"/notify message on",
|
||||||
"/notify message text on",
|
"/notify message text on",
|
||||||
"/notify room mention on",
|
"/notify room mention on",
|
||||||
|
"/notify room trigger add beer",
|
||||||
|
"/notify room trigger on",
|
||||||
"/notify room current off",
|
"/notify room current off",
|
||||||
"/notify room text off",
|
"/notify room text off",
|
||||||
"/notify remind 10",
|
"/notify remind 10",
|
||||||
@ -1958,7 +1952,6 @@ 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");
|
||||||
@ -2662,7 +2655,6 @@ cmd_reset_autocomplete(ProfWin *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bookmark_autocomplete_reset();
|
bookmark_autocomplete_reset();
|
||||||
prefs_reset_message_trigger_ac();
|
|
||||||
prefs_reset_room_trigger_ac();
|
prefs_reset_room_trigger_ac();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3178,11 +3170,6 @@ _notify_autocomplete(ProfWin *window, const char *const input)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
result = autocomplete_param_with_func(input, "/notify message trigger remove", prefs_autocomplete_message_trigger);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = autocomplete_param_with_func(input, "/notify room trigger remove", prefs_autocomplete_room_trigger);
|
result = autocomplete_param_with_func(input, "/notify room trigger remove", prefs_autocomplete_room_trigger);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
@ -3203,11 +3190,6 @@ _notify_autocomplete(ProfWin *window, const char *const input)
|
|||||||
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_ac(input, "/notify room", notify_room_ac, TRUE);
|
result = autocomplete_param_with_ac(input, "/notify room", notify_room_ac, TRUE);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -4334,53 +4334,6 @@ 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 {
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// chat room settings
|
// chat room settings
|
||||||
|
@ -65,7 +65,6 @@ static GKeyFile *prefs;
|
|||||||
gint log_maxsize = 0;
|
gint log_maxsize = 0;
|
||||||
|
|
||||||
static Autocomplete boolean_choice_ac;
|
static Autocomplete boolean_choice_ac;
|
||||||
static Autocomplete message_trigger_ac;
|
|
||||||
static Autocomplete room_trigger_ac;
|
static Autocomplete room_trigger_ac;
|
||||||
|
|
||||||
static void _save_prefs(void);
|
static void _save_prefs(void);
|
||||||
@ -149,20 +148,11 @@ prefs_load(void)
|
|||||||
autocomplete_add(boolean_choice_ac, "on");
|
autocomplete_add(boolean_choice_ac, "on");
|
||||||
autocomplete_add(boolean_choice_ac, "off");
|
autocomplete_add(boolean_choice_ac, "off");
|
||||||
|
|
||||||
message_trigger_ac = autocomplete_new();
|
|
||||||
gsize len = 0;
|
|
||||||
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
autocomplete_add(message_trigger_ac, triggers[i]);
|
|
||||||
}
|
|
||||||
g_strfreev(triggers);
|
|
||||||
|
|
||||||
room_trigger_ac = autocomplete_new();
|
room_trigger_ac = autocomplete_new();
|
||||||
len = 0;
|
gsize len = 0;
|
||||||
triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
autocomplete_add(room_trigger_ac, triggers[i]);
|
autocomplete_add(room_trigger_ac, triggers[i]);
|
||||||
}
|
}
|
||||||
@ -173,7 +163,6 @@ void
|
|||||||
prefs_close(void)
|
prefs_close(void)
|
||||||
{
|
{
|
||||||
autocomplete_free(boolean_choice_ac);
|
autocomplete_free(boolean_choice_ac);
|
||||||
autocomplete_free(message_trigger_ac);
|
|
||||||
autocomplete_free(room_trigger_ac);
|
autocomplete_free(room_trigger_ac);
|
||||||
g_key_file_free(prefs);
|
g_key_file_free(prefs);
|
||||||
prefs = NULL;
|
prefs = NULL;
|
||||||
@ -191,18 +180,6 @@ prefs_reset_boolean_choice(void)
|
|||||||
autocomplete_reset(boolean_choice_ac);
|
autocomplete_reset(boolean_choice_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
|
||||||
prefs_autocomplete_message_trigger(const char *const prefix)
|
|
||||||
{
|
|
||||||
return autocomplete_complete(message_trigger_ac, prefix, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
prefs_reset_message_trigger_ac(void)
|
|
||||||
{
|
|
||||||
autocomplete_reset(message_trigger_ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
prefs_autocomplete_room_trigger(const char *const prefix)
|
prefs_autocomplete_room_trigger(const char *const prefix)
|
||||||
{
|
{
|
||||||
@ -232,30 +209,6 @@ prefs_do_chat_notify(gboolean current_win, const char *const message)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean notify_trigger = prefs_get_boolean(PREF_NOTIFY_MESSAGE_TRIGGER);
|
|
||||||
if (notify_trigger) {
|
|
||||||
gboolean trigger_found = FALSE;
|
|
||||||
char *message_lower = g_utf8_strdown(message, -1);
|
|
||||||
gsize len = 0;
|
|
||||||
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
char *trigger_lower = g_utf8_strdown(triggers[i], -1);
|
|
||||||
if (g_strrstr(message_lower, trigger_lower)) {
|
|
||||||
trigger_found = TRUE;
|
|
||||||
g_free(trigger_lower);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_free(trigger_lower);
|
|
||||||
}
|
|
||||||
g_strfreev(triggers);
|
|
||||||
g_free(message_lower);
|
|
||||||
|
|
||||||
if (trigger_found) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,49 +806,6 @@ prefs_set_roster_presence_indent(gint value)
|
|||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
prefs_add_msg_notify_trigger(const char * const text)
|
|
||||||
{
|
|
||||||
gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
|
|
||||||
_save_prefs();
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
autocomplete_add(message_trigger_ac, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
prefs_remove_msg_notify_trigger(const char * const text)
|
|
||||||
{
|
|
||||||
gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
|
|
||||||
_save_prefs();
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
autocomplete_remove(message_trigger_ac, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
GList*
|
|
||||||
prefs_get_msg_notify_triggers(void)
|
|
||||||
{
|
|
||||||
GList *result = NULL;
|
|
||||||
gsize len = 0;
|
|
||||||
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
result = g_list_append(result, strdup(triggers[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev(triggers);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
prefs_add_room_notify_trigger(const char * const text)
|
prefs_add_room_notify_trigger(const char * const text)
|
||||||
{
|
{
|
||||||
@ -1113,7 +1023,6 @@ _get_group(preference_t pref)
|
|||||||
case PREF_NOTIFY_TYPING:
|
case PREF_NOTIFY_TYPING:
|
||||||
case PREF_NOTIFY_TYPING_CURRENT:
|
case PREF_NOTIFY_TYPING_CURRENT:
|
||||||
case PREF_NOTIFY_MESSAGE:
|
case PREF_NOTIFY_MESSAGE:
|
||||||
case PREF_NOTIFY_MESSAGE_TRIGGER:
|
|
||||||
case PREF_NOTIFY_MESSAGE_CURRENT:
|
case PREF_NOTIFY_MESSAGE_CURRENT:
|
||||||
case PREF_NOTIFY_MESSAGE_TEXT:
|
case PREF_NOTIFY_MESSAGE_TEXT:
|
||||||
case PREF_NOTIFY_ROOM:
|
case PREF_NOTIFY_ROOM:
|
||||||
@ -1207,8 +1116,6 @@ _get_key(preference_t pref)
|
|||||||
return "typing.current";
|
return "typing.current";
|
||||||
case PREF_NOTIFY_MESSAGE:
|
case PREF_NOTIFY_MESSAGE:
|
||||||
return "message";
|
return "message";
|
||||||
case PREF_NOTIFY_MESSAGE_TRIGGER:
|
|
||||||
return "message.trigger";
|
|
||||||
case PREF_NOTIFY_MESSAGE_CURRENT:
|
case PREF_NOTIFY_MESSAGE_CURRENT:
|
||||||
return "message.current";
|
return "message.current";
|
||||||
case PREF_NOTIFY_MESSAGE_TEXT:
|
case PREF_NOTIFY_MESSAGE_TEXT:
|
||||||
|
@ -94,7 +94,6 @@ typedef enum {
|
|||||||
PREF_NOTIFY_TYPING,
|
PREF_NOTIFY_TYPING,
|
||||||
PREF_NOTIFY_TYPING_CURRENT,
|
PREF_NOTIFY_TYPING_CURRENT,
|
||||||
PREF_NOTIFY_MESSAGE,
|
PREF_NOTIFY_MESSAGE,
|
||||||
PREF_NOTIFY_MESSAGE_TRIGGER,
|
|
||||||
PREF_NOTIFY_MESSAGE_CURRENT,
|
PREF_NOTIFY_MESSAGE_CURRENT,
|
||||||
PREF_NOTIFY_MESSAGE_TEXT,
|
PREF_NOTIFY_MESSAGE_TEXT,
|
||||||
PREF_NOTIFY_ROOM,
|
PREF_NOTIFY_ROOM,
|
||||||
@ -140,8 +139,6 @@ void prefs_reset_login_search(void);
|
|||||||
char* prefs_autocomplete_boolean_choice(const char *const prefix);
|
char* prefs_autocomplete_boolean_choice(const char *const prefix);
|
||||||
void prefs_reset_boolean_choice(void);
|
void prefs_reset_boolean_choice(void);
|
||||||
|
|
||||||
char* prefs_autocomplete_message_trigger(const char *const prefix);
|
|
||||||
void prefs_reset_message_trigger_ac(void);
|
|
||||||
char* prefs_autocomplete_room_trigger(const char *const prefix);
|
char* prefs_autocomplete_room_trigger(const char *const prefix);
|
||||||
void prefs_reset_room_trigger_ac(void);
|
void prefs_reset_room_trigger_ac(void);
|
||||||
|
|
||||||
@ -201,11 +198,8 @@ char* prefs_get_alias(const char *const name);
|
|||||||
GList* prefs_get_aliases(void);
|
GList* prefs_get_aliases(void);
|
||||||
void prefs_free_aliases(GList *aliases);
|
void prefs_free_aliases(GList *aliases);
|
||||||
|
|
||||||
gboolean prefs_add_msg_notify_trigger(const char * const text);
|
|
||||||
gboolean prefs_add_room_notify_trigger(const char * const text);
|
gboolean prefs_add_room_notify_trigger(const char * const text);
|
||||||
gboolean prefs_remove_msg_notify_trigger(const char * const text);
|
|
||||||
gboolean prefs_remove_room_notify_trigger(const char * const text);
|
gboolean prefs_remove_room_notify_trigger(const char * const text);
|
||||||
GList* prefs_get_msg_notify_triggers(void);
|
|
||||||
GList* prefs_get_room_notify_triggers(void);
|
GList* prefs_get_room_notify_triggers(void);
|
||||||
|
|
||||||
gboolean prefs_get_boolean(preference_t pref);
|
gboolean prefs_get_boolean(preference_t pref);
|
||||||
|
@ -1329,11 +1329,6 @@ cons_notify_setting(void)
|
|||||||
else
|
else
|
||||||
cons_show("Messages (/notify message) : OFF");
|
cons_show("Messages (/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");
|
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT))
|
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT))
|
||||||
cons_show("Messages current (/notify message) : ON");
|
cons_show("Messages current (/notify message) : ON");
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user