Check nick exists when private messaging

Show nick part of jid in private messaging
This commit is contained in:
James Booth
2013-01-11 01:35:25 +00:00
parent 1cc5353697
commit 5fbf966b9c
2 changed files with 43 additions and 13 deletions

View File

@@ -1532,19 +1532,44 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
return TRUE; return TRUE;
} }
if (msg != NULL) { if (win_current_is_groupchat()) {
jabber_send(msg, usr); char *room_name = win_current_get_recipient();
win_show_outgoing_msg("me", usr, msg); if (room_nick_in_roster(room_name, usr)) {
GString *full_jid = g_string_new(room_name);
g_string_append(full_jid, "/");
g_string_append(full_jid, usr);
if (prefs_get_chlog()) { jabber_send(msg, full_jid->str);
const char *jid = jabber_get_jid(); win_show_outgoing_msg("me", full_jid->str, msg);
chat_log_chat(jid, usr, msg, PROF_OUT_LOG, NULL);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, full_jid->str, msg, PROF_OUT_LOG, NULL);
}
g_string_free(full_jid, TRUE);
} else {
cons_show("No such nick \"%s\" in room %s.", usr, room_name);
} }
return TRUE; return TRUE;
} else { } else {
win_new_chat_win(usr); if (msg != NULL) {
return TRUE; jabber_send(msg, usr);
win_show_outgoing_msg("me", usr, msg);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, usr, msg, PROF_OUT_LOG, NULL);
}
return TRUE;
} else {
win_new_chat_win(usr);
return TRUE;
}
} }
} }

View File

@@ -326,11 +326,14 @@ void
ui_show_incoming_msg(const char * const from, const char * const message, ui_show_incoming_msg(const char * const from, const char * const message,
GTimeVal *tv_stamp, gboolean priv) GTimeVal *tv_stamp, gboolean priv)
{ {
char *display_from;
win_type_t win_type; win_type_t win_type;
if (priv) { if (priv) {
win_type = WIN_PRIVATE; win_type = WIN_PRIVATE;
display_from = room_get_nick_from_full_jid(from);
} else { } else {
win_type = WIN_CHAT; win_type = WIN_CHAT;
display_from = strdup(from);
} }
int win_index = _find_prof_win_index(from); int win_index = _find_prof_win_index(from);
@@ -390,12 +393,12 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (strncmp(message, "/me ", 4) == 0) { if (strncmp(message, "/me ", 4) == 0) {
wattron(win, COLOUR_THEM); wattron(win, COLOUR_THEM);
wprintw(win, "*%s ", from); wprintw(win, "*%s ", display_from);
wprintw(win, message + 4); wprintw(win, message + 4);
wprintw(win, "\n"); wprintw(win, "\n");
wattroff(win, COLOUR_THEM); wattroff(win, COLOUR_THEM);
} else { } else {
_win_show_user(win, from, 1); _win_show_user(win, display_from, 1);
_win_show_message(win, message); _win_show_message(win, message);
} }
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
@@ -429,12 +432,12 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (strncmp(message, "/me ", 4) == 0) { if (strncmp(message, "/me ", 4) == 0) {
wattron(win, COLOUR_THEM); wattron(win, COLOUR_THEM);
wprintw(win, "*%s ", from); wprintw(win, "*%s ", display_from);
wprintw(win, message + 4); wprintw(win, message + 4);
wprintw(win, "\n"); wprintw(win, "\n");
wattroff(win, COLOUR_THEM); wattroff(win, COLOUR_THEM);
} else { } else {
_win_show_user(win, from, 1); _win_show_user(win, display_from, 1);
_win_show_message(win, message); _win_show_message(win, message);
} }
} }
@@ -443,7 +446,9 @@ ui_show_incoming_msg(const char * const from, const char * const message,
if (prefs_get_beep()) if (prefs_get_beep())
beep(); beep();
if (prefs_get_notify_message()) if (prefs_get_notify_message())
_notify_message(from); _notify_message(display_from);
g_free(display_from);
} }
void void