Compare commits

...

5 Commits

Author SHA1 Message Date
TingPing 52a685238c Fix comment typo 2016-03-19 13:01:28 -04:00
TingPing 951b7563bf Consistently use bools 2016-03-19 13:01:28 -04:00
TingPing 2ea12bce1d Don't mark own messages as new message 2016-03-19 13:01:28 -04:00
TingPing 382908ab6d Add support for self-message
See: https://github.com/ircv3/ircv3-specifications/blob/master/extensions/self-message-3.2.md
2016-03-19 13:01:28 -04:00
TingPing e3838a6e67 Clean up finding correct context for messages/actions
Don't ever print actions in the wrong tab
and warn if you can't find the correct one
2016-03-19 13:00:53 -04:00
6 changed files with 102 additions and 43 deletions

View File

@ -93,6 +93,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
server *serv = sess->server;
char outbuf[1024];
int ctcp_offset = 2;
gboolean fromme = FALSE;
if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') )
ctcp_offset = 3;
@ -129,7 +130,10 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
goto generic;
inbound_action (sess, to, nick, ip, msg + 7, FALSE, id, tags_data);
if (!serv->p_cmp (nick, serv->nick))
fromme = TRUE;
inbound_action (sess, to, nick, ip, msg + 7, fromme, FALSE, id, tags_data);
return;
}

View File

@ -549,10 +549,10 @@ dcc_chat_line (struct DCC *dcc, char *line)
if (po)
po[0] = 0;
inbound_action (sess, dcc->serv->nick, dcc->nick, "", line + 8, FALSE,
FALSE, &no_tags);
TRUE, FALSE, &no_tags);
} else
{
inbound_privmsg (dcc->serv, dcc->nick, "", line, FALSE, &no_tags);
inbound_privmsg (dcc->serv, dcc->nick, NULL, "", line, FALSE, &no_tags);
}
g_free (line);
return 0;

View File

@ -145,7 +145,7 @@ inbound_open_dialog (server *serv, char *from,
}
static void
inbound_make_idtext (server *serv, char *idtext, int max, int id)
inbound_make_idtext (server *serv, char *idtext, int max, gboolean id)
{
idtext[0] = 0;
if (serv->have_idmsg || serv->have_accnotify)
@ -163,28 +163,35 @@ inbound_make_idtext (server *serv, char *idtext, int max, int id)
}
void
inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, gboolean id,
const message_tags_data *tags_data)
{
session *sess;
struct User *user;
char idtext[64];
gboolean nodiag = FALSE;
char *destsess = from;
gboolean nodiag = FALSE, fromme = FALSE;
if (to && !serv->p_cmp (from, serv->nick))
{
fromme = TRUE;
destsess = to;
}
sess = find_dialog (serv, from);
if (sess || prefs.hex_gui_autoopen_dialog)
if (!fromme && (sess || prefs.hex_gui_autoopen_dialog))
{
/*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here is flud detected */
/*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here if flood is detected */
if (!sess)
{
if (flood_check (from, ip, serv, current_sess, 1))
{
/* Create a dialog session */
sess = inbound_open_dialog (serv, from, tags_data);
}
else
sess = serv->server_session;
if (!sess)
return; /* ?? */
}
if (ip && ip[0])
@ -193,11 +200,18 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
return;
}
sess = find_session_from_nick (from, serv);
sess = find_dialog (serv, destsess);
if (!sess)
{
sess = serv->front_session;
nodiag = TRUE; /* We don't want it to look like a normal message in front sess */
if (fromme && prefs.hex_gui_autoopen_dialog)
{
sess = inbound_open_dialog (serv, destsess, tags_data);
}
else
{
sess = serv->front_session;
nodiag = TRUE; /* We don't want it to look like a normal message in front sess */
}
}
user = userlist_find (sess, from);
@ -210,7 +224,16 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
inbound_make_idtext (serv, idtext, sizeof (idtext), id);
if (sess->type == SESS_DIALOG && !nodiag)
if (fromme)
{
if (sess->type == SESS_DIALOG)
EMIT_SIGNAL_TIMESTAMP (XP_TE_UCHANMSG, sess, from, text, NULL, idtext, 0,
tags_data->timestamp);
else
EMIT_SIGNAL_TIMESTAMP (XP_TE_MSGSEND, sess, to, text, NULL, NULL, 0,
tags_data->timestamp);
}
else if (sess->type == SESS_DIALOG && !nodiag)
EMIT_SIGNAL_TIMESTAMP (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0,
tags_data->timestamp);
else
@ -329,48 +352,50 @@ is_hilight (char *from, char *text, session *sess, server *serv)
void
inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
int fromme, int id, const message_tags_data *tags_data)
gboolean fromme, gboolean fake, gboolean id, const message_tags_data *tags_data)
{
session *def = sess;
server *serv = sess->server;
struct User *user;
char nickchar[2] = "\000";
char idtext[64];
int privaction = FALSE;
char *destsess = from;
if (!fromme)
if (fromme)
destsess = chan;
if (!fake) /* Fake events start in the correct sess. */
{
if (is_channel (serv, chan))
{
sess = find_channel (serv, chan);
if (!sess)
{
g_warning ("Got channel action for %s but found no channel session\n", chan);
return; /* There is no sane place to put this */
}
} else
{
/* it's a private action! */
privaction = TRUE;
/* find a dialog tab for it */
sess = find_dialog (serv, from);
sess = find_dialog (serv, destsess);
/* if non found, open a new one */
if (!sess && prefs.hex_gui_autoopen_dialog)
{
/* but only if it wouldn't flood */
if (flood_check (from, ip, serv, current_sess, 1))
sess = inbound_open_dialog (serv, from, tags_data);
if (flood_check (destsess, ip, serv, current_sess, 1))
sess = inbound_open_dialog (serv, destsess, tags_data);
else
sess = serv->server_session;
}
if (!sess)
{
sess = find_session_from_nick (from, serv);
/* still not good? */
if (!sess)
sess = serv->front_session;
sess = serv->front_session;
}
}
}
if (!sess)
sess = def;
if (sess != current_tab)
{
if (fromme)
@ -385,7 +410,7 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
lastact_update (sess);
}
user = userlist_find (sess, from);
user = userlist_find (sess, destsess);
if (user)
{
nickchar[0] = user->prefix[0];
@ -409,8 +434,19 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
}
if (fromme)
EMIT_SIGNAL_TIMESTAMP (XP_TE_UACTION, sess, from, text, nickchar, idtext,
{
if (fake || sess->type == SESS_DIALOG ||
!serv->p_cmp (sess->channel, destsess)) /* Show normally if in correct sess */
EMIT_SIGNAL_TIMESTAMP (XP_TE_UACTION, sess, from, text, nickchar, idtext,
0, tags_data->timestamp);
else /* There is no Action Send event, so we will just show it as CTCP.. */
{
char *new_text = g_strconcat ("ACTION ", text, NULL);
EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSEND, sess, destsess, new_text, NULL, NULL,
0, tags_data->timestamp);
g_free (new_text);
}
}
else if (!privaction)
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANACTION, sess, from, text, nickchar,
idtext, 0, tags_data->timestamp);
@ -424,7 +460,7 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
void
inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
char *text, char fromme, int id,
char *text, gboolean fromme, gboolean id,
const message_tags_data *tags_data)
{
struct User *user;
@ -437,8 +473,18 @@ inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
if (chan)
{
sess = find_channel (serv, chan);
if (!sess && !is_channel (serv, chan))
sess = find_dialog (serv, chan);
if (!sess)
{
if (is_channel (serv, chan))
{
g_warning ("Got channel message to %s but found no channel session\n", chan);
return;
}
else
{
sess = find_dialog (serv, chan);
}
}
} else
{
sess = find_dialog (serv, from);
@ -449,8 +495,16 @@ inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
if (sess != current_tab)
{
sess->msg_said = TRUE;
sess->new_data = FALSE;
if (fromme)
{
sess->msg_said = FALSE;
sess->new_data = TRUE;
}
else
{
sess->msg_said = TRUE;
sess->new_data = FALSE;
}
lastact_update (sess);
}
@ -936,7 +990,7 @@ find_session_from_type (int type, server *serv)
}
void
inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id,
inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, gboolean id,
const message_tags_data *tags_data)
{
char *po,*ptr=to;
@ -1724,6 +1778,7 @@ static const char * const supported_caps[] = {
/* ZNC */
"znc.in/server-time-iso",
"znc.in/server-time",
"znc.in/self-message",
/* Twitch */
"twitch.tv/membership",

View File

@ -37,7 +37,7 @@ void inbound_ukick (server *serv, char *chan, char *kicker, char *reason,
void inbound_kick (server *serv, char *chan, char *user, char *kicker,
char *reason, const message_tags_data *tags_data);
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip,
int id, const message_tags_data *tags_data);
gboolean id, const message_tags_data *tags_data);
void inbound_quit (server *serv, char *nick, char *ip, char *reason,
const message_tags_data *tags_data);
void inbound_topicnew (server *serv, char *nick, char *chan, char *topic,
@ -76,14 +76,14 @@ void inbound_login_start (session *sess, char *nick, char *servname,
void inbound_login_end (session *sess, char *text,
const message_tags_data *tags_data);
void inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
char *text, char fromme, int id,
char *text, gboolean fromme, gboolean id,
const message_tags_data *tags_data);
void clear_channel (session *sess);
void set_topic (session *sess, char *topic, char *stripped_topic);
void inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
void inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, gboolean id,
const message_tags_data *tags_data);
void inbound_action (session *sess, char *chan, char *from, char *ip,
char *text, int fromme, int id,
char *text, gboolean fromme, gboolean fake, gboolean id,
const message_tags_data *tags_data);
void inbound_newnick (server *serv, char *nick, char *newnick, int quiet,
const message_tags_data *tags_data);

View File

@ -2642,7 +2642,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
if (dcc_write_chat (sess->channel, tbuf))
{
/* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "", act, TRUE, FALSE,
inbound_action (sess, sess->channel, sess->server->nick, "", act, TRUE, TRUE, FALSE,
&no_tags);
} else
{
@ -2654,7 +2654,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
sess->server->p_action (sess->server, sess->channel, split_text);
/* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "",
split_text, TRUE, FALSE,
split_text, TRUE, TRUE, FALSE,
&no_tags);
if (*split_text)
@ -2666,7 +2666,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
sess->server->p_action (sess->server, sess->channel, act + offset);
/* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "",
act + offset, TRUE, FALSE, &no_tags);
act + offset, TRUE, TRUE, FALSE, &no_tags);
} else
{
notc_msg (sess);

View File

@ -1256,7 +1256,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
{
if (ignore_check (word[1], IG_PRIV))
return;
inbound_privmsg (serv, nick, ip, text, id, tags_data);
inbound_privmsg (serv, nick, to, ip, text, id, tags_data);
}
}
}