mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
parent
2bda22c3d6
commit
5ff36c14c0
@ -211,6 +211,29 @@ prefs_do_chat_notify(gboolean current_win, const char *const message)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
prefs_message_contains_trigger(const char *const message)
|
||||||
|
{
|
||||||
|
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, "room.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);
|
||||||
|
|
||||||
|
return trigger_found;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick,
|
prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick,
|
||||||
const char *const message)
|
const char *const message)
|
||||||
@ -258,27 +281,8 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char
|
|||||||
} else {
|
} else {
|
||||||
notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER);
|
notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER);
|
||||||
}
|
}
|
||||||
if (notify_trigger) {
|
if (notify_trigger && prefs_message_contains_trigger(message)) {
|
||||||
gboolean trigger_found = FALSE;
|
return TRUE;
|
||||||
char *message_lower = g_utf8_strdown(message, -1);
|
|
||||||
gsize len = 0;
|
|
||||||
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.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;
|
||||||
|
@ -226,6 +226,7 @@ void prefs_set_string(preference_t pref, char *value);
|
|||||||
|
|
||||||
gboolean prefs_do_chat_notify(gboolean current_win, const char *const message);
|
gboolean prefs_do_chat_notify(gboolean current_win, const char *const message);
|
||||||
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message);
|
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message);
|
||||||
|
gboolean prefs_message_contains_trigger(const char *const message);
|
||||||
|
|
||||||
void prefs_set_room_notify(const char *const roomjid, gboolean value);
|
void prefs_set_room_notify(const char *const roomjid, gboolean value);
|
||||||
void prefs_set_room_notify_mention(const char *const roomjid, gboolean value);
|
void prefs_set_room_notify_mention(const char *const roomjid, gboolean value);
|
||||||
|
@ -105,6 +105,7 @@ theme_init(const char *const theme_name)
|
|||||||
g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red"));
|
g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red"));
|
||||||
g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow"));
|
g_hash_table_insert(defaults, strdup("roominfo"), strdup("yellow"));
|
||||||
g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow"));
|
g_hash_table_insert(defaults, strdup("roommention"), strdup("yellow"));
|
||||||
|
g_hash_table_insert(defaults, strdup("roomtrigger"), strdup("yellow"));
|
||||||
g_hash_table_insert(defaults, strdup("online"), strdup("green"));
|
g_hash_table_insert(defaults, strdup("online"), strdup("green"));
|
||||||
g_hash_table_insert(defaults, strdup("offline"), strdup("red"));
|
g_hash_table_insert(defaults, strdup("offline"), strdup("red"));
|
||||||
g_hash_table_insert(defaults, strdup("away"), strdup("cyan"));
|
g_hash_table_insert(defaults, strdup("away"), strdup("cyan"));
|
||||||
@ -727,6 +728,7 @@ theme_attrs(theme_item_t attrs)
|
|||||||
case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", "red", lookup_str, &bold); break;
|
case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", "red", lookup_str, &bold); break;
|
||||||
case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", "yellow", lookup_str, &bold); break;
|
case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", "yellow", lookup_str, &bold); break;
|
||||||
case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", "yellow", lookup_str, &bold); break;
|
case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", "yellow", lookup_str, &bold); break;
|
||||||
|
case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", "yellow", lookup_str, &bold); break;
|
||||||
case THEME_ONLINE: _theme_prep_fgnd("online", "green", lookup_str, &bold); break;
|
case THEME_ONLINE: _theme_prep_fgnd("online", "green", lookup_str, &bold); break;
|
||||||
case THEME_OFFLINE: _theme_prep_fgnd("offline", "red", lookup_str, &bold); break;
|
case THEME_OFFLINE: _theme_prep_fgnd("offline", "red", lookup_str, &bold); break;
|
||||||
case THEME_AWAY: _theme_prep_fgnd("away", "cyan", lookup_str, &bold); break;
|
case THEME_AWAY: _theme_prep_fgnd("away", "cyan", lookup_str, &bold); break;
|
||||||
|
@ -68,6 +68,7 @@ typedef enum {
|
|||||||
THEME_THEM,
|
THEME_THEM,
|
||||||
THEME_ROOMINFO,
|
THEME_ROOMINFO,
|
||||||
THEME_ROOMMENTION,
|
THEME_ROOMMENTION,
|
||||||
|
THEME_ROOMTRIGGER,
|
||||||
THEME_ONLINE,
|
THEME_ONLINE,
|
||||||
THEME_OFFLINE,
|
THEME_OFFLINE,
|
||||||
THEME_AWAY,
|
THEME_AWAY,
|
||||||
|
@ -2125,6 +2125,7 @@ cons_theme_properties(void)
|
|||||||
|
|
||||||
_cons_theme_prop(THEME_ROOMINFO, "roominfo");
|
_cons_theme_prop(THEME_ROOMINFO, "roominfo");
|
||||||
_cons_theme_prop(THEME_ROOMMENTION, "roommention");
|
_cons_theme_prop(THEME_ROOMMENTION, "roommention");
|
||||||
|
_cons_theme_prop(THEME_ROOMTRIGGER, "roomtrigger");
|
||||||
|
|
||||||
_cons_theme_prop(THEME_ROSTER_HEADER, "roster.header");
|
_cons_theme_prop(THEME_ROSTER_HEADER, "roster.header");
|
||||||
_cons_theme_prop(THEME_ROSTER_CHAT, "roster.chat");
|
_cons_theme_prop(THEME_ROSTER_CHAT, "roster.chat");
|
||||||
|
@ -366,6 +366,8 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
|||||||
if (g_strcmp0(nick, my_nick) != 0) {
|
if (g_strcmp0(nick, my_nick) != 0) {
|
||||||
if (g_strrstr(message, my_nick)) {
|
if (g_strrstr(message, my_nick)) {
|
||||||
win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message);
|
win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message);
|
||||||
|
} else if (prefs_message_contains_trigger(message)) {
|
||||||
|
win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMTRIGGER, nick, message);
|
||||||
} else {
|
} else {
|
||||||
win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message);
|
win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,8 @@ typing=yellow
|
|||||||
gone=red
|
gone=red
|
||||||
error=red
|
error=red
|
||||||
roominfo=yellow
|
roominfo=yellow
|
||||||
roommention=bold_red
|
roommention=bold_magenta
|
||||||
|
roomtrigger=bold_cyan
|
||||||
me=blue
|
me=blue
|
||||||
them=bold_green
|
them=bold_green
|
||||||
roster.header=bold_yellow
|
roster.header=bold_yellow
|
||||||
|
Loading…
Reference in New Issue
Block a user