mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added /notify room mention setting
This commit is contained in:
parent
7d90d218c0
commit
866d87af79
@ -468,24 +468,24 @@ static struct cmd_t command_defs[] =
|
||||
NULL } } },
|
||||
|
||||
{ "/notify",
|
||||
cmd_notify, parse_args, 2, 2, &cons_notify_setting,
|
||||
{ "/notify type value", "Control various desktop noficiations.",
|
||||
{ "/notify type value",
|
||||
"------------------",
|
||||
cmd_notify, parse_args, 2, 3, &cons_notify_setting,
|
||||
{ "/notify [type value]", "Control various desktop noficiations.",
|
||||
{ "/notify [type value]",
|
||||
"--------------------",
|
||||
"Settings for various desktop notifications where type is one of:",
|
||||
"message : Notificaitons for regular messages.",
|
||||
" : on|off",
|
||||
"room : Notificaitons for chat room messages.",
|
||||
" : on|off",
|
||||
"remind : Notification reminders of unread messages.",
|
||||
" : where value is the reminder period in seconds,",
|
||||
" : use 0 to disable.",
|
||||
"typing : Notifications when contacts are typing.",
|
||||
" : on|off",
|
||||
"invite : Notifications for chat room invites.",
|
||||
" : on|off",
|
||||
"sub : Notifications for subscription requests.",
|
||||
" : on|off",
|
||||
"message : Notificaitons for regular messages.",
|
||||
" : on|off",
|
||||
"room : Notificaitons for chat room messages.",
|
||||
" : on|off|mention",
|
||||
"remind : Notification reminders of unread messages.",
|
||||
" : where value is the reminder period in seconds,",
|
||||
" : use 0 to disable.",
|
||||
"typing : Notifications when contacts are typing.",
|
||||
" : on|off",
|
||||
"invite : Notifications for chat room invites.",
|
||||
" : on|off",
|
||||
"sub : Notifications for subscription requests.",
|
||||
" : on|off",
|
||||
"",
|
||||
"Example : /notify message on (enable message notifications)",
|
||||
"Example : /notify message on (enable chat room notifications)",
|
||||
@ -877,6 +877,7 @@ static Autocomplete commands_ac;
|
||||
static Autocomplete who_ac;
|
||||
static Autocomplete help_ac;
|
||||
static Autocomplete notify_ac;
|
||||
static Autocomplete notify_room_ac;
|
||||
static Autocomplete prefs_ac;
|
||||
static Autocomplete sub_ac;
|
||||
static Autocomplete log_ac;
|
||||
@ -973,6 +974,11 @@ cmd_init(void)
|
||||
autocomplete_add(notify_ac, "invite");
|
||||
autocomplete_add(notify_ac, "sub");
|
||||
|
||||
notify_room_ac = autocomplete_new();
|
||||
autocomplete_add(notify_room_ac, "on");
|
||||
autocomplete_add(notify_room_ac, "off");
|
||||
autocomplete_add(notify_room_ac, "mention");
|
||||
|
||||
sub_ac = autocomplete_new();
|
||||
autocomplete_add(sub_ac, "request");
|
||||
autocomplete_add(sub_ac, "allow");
|
||||
@ -1147,6 +1153,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(who_ac);
|
||||
autocomplete_free(help_ac);
|
||||
autocomplete_free(notify_ac);
|
||||
autocomplete_free(notify_room_ac);
|
||||
autocomplete_free(sub_ac);
|
||||
autocomplete_free(titlebar_ac);
|
||||
autocomplete_free(log_ac);
|
||||
@ -1259,6 +1266,7 @@ cmd_reset_autocomplete()
|
||||
presence_reset_sub_request_search();
|
||||
autocomplete_reset(help_ac);
|
||||
autocomplete_reset(notify_ac);
|
||||
autocomplete_reset(notify_room_ac);
|
||||
autocomplete_reset(sub_ac);
|
||||
|
||||
if (ui_current_win_type() == WIN_MUC) {
|
||||
@ -1774,8 +1782,13 @@ _notify_autocomplete(char *input, int *size)
|
||||
int i = 0;
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/notify room", notify_room_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar *boolean_choices[] = { "/notify message", "/notify typing",
|
||||
"/notify invite", "/notify sub", "/notify room" };
|
||||
"/notify invite", "/notify sub" };
|
||||
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, size, boolean_choices[i],
|
||||
prefs_autocomplete_boolean_choice);
|
||||
|
@ -2219,12 +2219,15 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
} else if (strcmp(kind, "room") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
cons_show("Chat room notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE);
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "on");
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
cons_show("Chat room notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE);
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "off");
|
||||
} else if (strcmp(value, "mention") == 0) {
|
||||
cons_show("Chat room notifications enable on mention.");
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "mention");
|
||||
} else {
|
||||
cons_show("Usage: /notify room on|off");
|
||||
cons_show("Usage: /notify room on|off|mention");
|
||||
}
|
||||
|
||||
// set typing setting
|
||||
|
@ -519,6 +519,7 @@ _get_default_string(preference_t pref)
|
||||
switch (pref)
|
||||
{
|
||||
case PREF_AUTOAWAY_MODE:
|
||||
case PREF_NOTIFY_ROOM:
|
||||
return "off";
|
||||
case PREF_OTR_LOG:
|
||||
return "redact";
|
||||
|
@ -87,6 +87,7 @@ void prefs_set_gone(gint value);
|
||||
|
||||
void prefs_set_notify_remind(gint period);
|
||||
gint prefs_get_notify_remind(void);
|
||||
|
||||
void prefs_set_max_log_size(gint value);
|
||||
gint prefs_get_max_log_size(void);
|
||||
gint prefs_get_priority(void);
|
||||
|
@ -1163,10 +1163,8 @@ _cons_notify_setting(void)
|
||||
else
|
||||
cons_show("Messages (/notify message) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_ROOM))
|
||||
cons_show("Messages (/notify room) : ON");
|
||||
else
|
||||
cons_show("Messages (/notify room) : OFF");
|
||||
char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
|
||||
cons_show ("Chat room messages (/notify room) : %s", room_setting);
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_TYPING))
|
||||
cons_show("Composing (/notify typing) : ON");
|
||||
|
@ -1696,7 +1696,15 @@ _ui_room_message(const char * const room_jid, const char * const nick,
|
||||
if (prefs_get_boolean(PREF_BEEP)) {
|
||||
beep();
|
||||
}
|
||||
if (prefs_get_boolean(PREF_NOTIFY_ROOM)) {
|
||||
char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
|
||||
gboolean notify = FALSE;
|
||||
if (g_strcmp0(room_setting, "on") == 0) {
|
||||
notify = TRUE;
|
||||
}
|
||||
if ( (g_strcmp0(room_setting, "mention") == 0) && (g_strrstr(message, nick) != NULL) ) {
|
||||
notify = TRUE;
|
||||
}
|
||||
if (notify) {
|
||||
Jid *jidp = jid_create(room_jid);
|
||||
notify_room_message(nick, jidp->localpart, ui_index);
|
||||
jid_destroy(jidp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user