mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Receive 'self messages' in the right query window
Original patch by hondza <sedaj2@gmail.com>, from FS#833. I applied several needed style changes, and rebased to current HEAD. This implements the IRCv3.2 self-message extension partially (we can't announce its support through CAP yet). This is also the format used by the 'privmsg' znc module, and is already implemented by several other clients.
This commit is contained in:
parent
65a2ff6459
commit
1edfcedda1
@ -242,13 +242,16 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||||
const char *nick, const char *address)
|
const char *nick, const char *address, const char *target)
|
||||||
{
|
{
|
||||||
QUERY_REC *query;
|
QUERY_REC *query;
|
||||||
char *freemsg = NULL;
|
char *freemsg = NULL;
|
||||||
int level = MSGLEVEL_MSGS;
|
int level = MSGLEVEL_MSGS;
|
||||||
|
|
||||||
query = query_find(server, nick);
|
/* own message returned by bouncer? */
|
||||||
|
int own = (!strcmp(nick, server->nick));
|
||||||
|
|
||||||
|
query = query_find(server, own ? target : nick);
|
||||||
|
|
||||||
if (settings_get_bool("emphasis"))
|
if (settings_get_bool("emphasis"))
|
||||||
msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
|
msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
|
||||||
@ -256,9 +259,15 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
|
|||||||
if (ignore_check(server, nick, address, NULL, msg, level | MSGLEVEL_NO_ACT))
|
if (ignore_check(server, nick, address, NULL, msg, level | MSGLEVEL_NO_ACT))
|
||||||
level |= MSGLEVEL_NO_ACT;
|
level |= MSGLEVEL_NO_ACT;
|
||||||
|
|
||||||
|
if (own) {
|
||||||
|
printformat(server, target, level,
|
||||||
|
query == NULL ? TXT_OWN_MSG_PRIVATE :
|
||||||
|
TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
|
||||||
|
} else {
|
||||||
printformat(server, nick, level,
|
printformat(server, nick, level,
|
||||||
query == NULL ? TXT_MSG_PRIVATE :
|
query == NULL ? TXT_MSG_PRIVATE :
|
||||||
TXT_MSG_PRIVATE_QUERY, nick, address, msg);
|
TXT_MSG_PRIVATE_QUERY, nick, address, msg);
|
||||||
|
}
|
||||||
|
|
||||||
g_free_not_null(freemsg);
|
g_free_not_null(freemsg);
|
||||||
}
|
}
|
||||||
|
@ -326,12 +326,15 @@ static int sig_query_autoclose(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||||
const char *nick, const char *address)
|
const char *nick, const char *address, const char *target)
|
||||||
{
|
{
|
||||||
QUERY_REC *query;
|
QUERY_REC *query;
|
||||||
|
|
||||||
|
/* own message returned by bouncer? */
|
||||||
|
int own = (!strcmp(nick, server->nick));
|
||||||
|
|
||||||
/* create query window if needed */
|
/* create query window if needed */
|
||||||
query = privmsg_get_query(server, nick, FALSE, MSGLEVEL_MSGS);
|
query = privmsg_get_query(server, own ? target : nick, FALSE, MSGLEVEL_MSGS);
|
||||||
|
|
||||||
/* reset the query's last_unread_msg timestamp */
|
/* reset the query's last_unread_msg timestamp */
|
||||||
if (query != NULL)
|
if (query != NULL)
|
||||||
|
@ -160,6 +160,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
const char *oldtarget;
|
const char *oldtarget;
|
||||||
char *freemsg = NULL;
|
char *freemsg = NULL;
|
||||||
int level;
|
int level;
|
||||||
|
int own = FALSE;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = skip_target(IRC_SERVER(server), target);
|
||||||
@ -174,10 +175,12 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
level | MSGLEVEL_NO_ACT))
|
level | MSGLEVEL_NO_ACT))
|
||||||
level |= MSGLEVEL_NO_ACT;
|
level |= MSGLEVEL_NO_ACT;
|
||||||
|
|
||||||
if (ischannel(*target))
|
if (ischannel(*target)) {
|
||||||
item = irc_channel_find(server, target);
|
item = irc_channel_find(server, target);
|
||||||
else
|
} else {
|
||||||
item = privmsg_get_query(SERVER(server), nick, FALSE, level);
|
own = (!strcmp(nick, server->nick));
|
||||||
|
item = privmsg_get_query(SERVER(server), own ? nick : target, FALSE, level);
|
||||||
|
}
|
||||||
|
|
||||||
if (settings_get_bool("emphasis"))
|
if (settings_get_bool("emphasis"))
|
||||||
msg = freemsg = expand_emphasis(item, msg);
|
msg = freemsg = expand_emphasis(item, msg);
|
||||||
@ -194,6 +197,13 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
IRCTXT_ACTION_PUBLIC_CHANNEL,
|
IRCTXT_ACTION_PUBLIC_CHANNEL,
|
||||||
nick, oldtarget, msg);
|
nick, oldtarget, msg);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (own) {
|
||||||
|
/* own action bounced */
|
||||||
|
printformat(server, target,
|
||||||
|
MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
|
||||||
|
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
|
||||||
|
server->nick, msg, oldtarget);
|
||||||
} else {
|
} else {
|
||||||
/* private action */
|
/* private action */
|
||||||
printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
|
printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
|
||||||
@ -201,6 +211,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
IRCTXT_ACTION_PRIVATE_QUERY,
|
IRCTXT_ACTION_PRIVATE_QUERY,
|
||||||
nick, address == NULL ? "" : address, msg);
|
nick, address == NULL ? "" : address, msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_free_not_null(freemsg);
|
g_free_not_null(freemsg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user