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

Tidy notify_room_message()

This commit is contained in:
James Booth 2016-02-04 00:45:37 +00:00
parent c14ef33906
commit e1962261a9
2 changed files with 12 additions and 18 deletions

View File

@ -305,23 +305,12 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
beep(); beep();
} }
if (!notify) { if (notify) {
return;
}
Jid *jidp = jid_create(mucwin->roomjid); Jid *jidp = jid_create(mucwin->roomjid);
int ui_index = num; notify_room_message(nick, jidp->localpart, num, message);
if (ui_index == 10) {
ui_index = 0;
}
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
notify_room_message(nick, jidp->localpart, ui_index, message);
} else {
notify_room_message(nick, jidp->localpart, ui_index, NULL);
}
jid_destroy(jidp); jid_destroy(jidp);
} }
}
void void
sv_ev_incoming_private_message(const char *const fulljid, char *message) sv_ev_incoming_private_message(const char *const fulljid, char *message)

View File

@ -117,11 +117,16 @@ notify_message(const char *const name, int num, const char *const text)
} }
void void
notify_room_message(const char *const nick, const char *const room, int win, const char *const text) notify_room_message(const char *const nick, const char *const room, int num, const char *const text)
{ {
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
GString *message = g_string_new(""); GString *message = g_string_new("");
g_string_append_printf(message, "%s in %s (win %d)", nick, room, win); g_string_append_printf(message, "%s in %s (win %d)", nick, room, ui_index);
if (text) { if (text && prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
g_string_append_printf(message, "\n%s", text); g_string_append_printf(message, "\n%s", text);
} }