degesch: further logging cleanup
This commit is contained in:
parent
ed349cb1d3
commit
3e47abdfbb
92
degesch.c
92
degesch.c
|
@ -4064,6 +4064,20 @@ irc_is_highlight (struct server *s, const char *message)
|
|||
return result;
|
||||
}
|
||||
|
||||
static const char *
|
||||
irc_get_privmsg_prefix (struct server *s, struct user *user, const char *target)
|
||||
{
|
||||
if (user && irc_is_channel (s, target))
|
||||
{
|
||||
struct channel *channel;
|
||||
struct channel_user *channel_user;
|
||||
if ((channel = str_map_find (&s->irc_channels, target))
|
||||
&& (channel_user = irc_channel_get_user (channel, user)))
|
||||
return channel_user->prefixes.str;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// --- Mode processor ----------------------------------------------------------
|
||||
|
||||
struct mode_processor
|
||||
|
@ -4587,18 +4601,17 @@ irc_handle_notice_text (struct server *s,
|
|||
{
|
||||
const char *target = msg->params.vector[0];
|
||||
struct buffer *buffer = irc_get_buffer_for_message (s, msg, target);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
char *nick = irc_cut_nickname (msg->prefix);
|
||||
// IRCv3.2 echo-message could otherwise cause us to highlight ourselves
|
||||
if (!irc_is_this_us (s, msg->prefix) && irc_is_highlight (s, text->str))
|
||||
log_server (s, buffer, BUFFER_LINE_STATUS | BUFFER_LINE_HIGHLIGHT,
|
||||
"#a#s(#S)#r: #m", ATTR_HIGHLIGHT, "Notice", nick, text->str);
|
||||
else
|
||||
log_outcoming_notice (s, buffer, msg->prefix, text->str);
|
||||
free (nick);
|
||||
}
|
||||
char *nick = irc_cut_nickname (msg->prefix);
|
||||
// IRCv3.2 echo-message could otherwise cause us to highlight ourselves
|
||||
if (!irc_is_this_us (s, msg->prefix) && irc_is_highlight (s, text->str))
|
||||
log_server (s, buffer, BUFFER_LINE_STATUS | BUFFER_LINE_HIGHLIGHT,
|
||||
"#a#s(#S)#r: #m", ATTR_HIGHLIGHT, "Notice", nick, text->str);
|
||||
else
|
||||
log_outcoming_notice (s, buffer, msg->prefix, text->str);
|
||||
free (nick);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4752,39 +4765,29 @@ irc_handle_privmsg_text (struct server *s,
|
|||
{
|
||||
const char *target = msg->params.vector[0];
|
||||
struct buffer *buffer = irc_get_buffer_for_message (s, msg, target);
|
||||
char *nick = irc_cut_nickname (msg->prefix);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
const char *prefixes = "";
|
||||
if (irc_is_channel (s, target))
|
||||
{
|
||||
struct user *user;
|
||||
struct channel *channel;
|
||||
struct channel_user *channel_user;
|
||||
if ((user = str_map_find (&s->irc_users, nick))
|
||||
&& (channel = str_map_find (&s->irc_channels, target))
|
||||
&& (channel_user = irc_channel_get_user (channel, user)))
|
||||
prefixes = channel_user->prefixes.str;
|
||||
}
|
||||
char *nickname = irc_cut_nickname (msg->prefix);
|
||||
const char *prefixes = irc_get_privmsg_prefix
|
||||
(s, str_map_find (&s->irc_users, nickname), target);
|
||||
|
||||
if (buffer)
|
||||
// IRCv3.2 echo-message could otherwise cause us to highlight ourselves
|
||||
if (irc_is_this_us (s, msg->prefix) || !irc_is_highlight (s, text->str))
|
||||
{
|
||||
// IRCv3.2 echo-message could otherwise cause us to highlight ourselves
|
||||
if (irc_is_this_us (s, msg->prefix) || !irc_is_highlight (s, text->str))
|
||||
{
|
||||
if (is_action)
|
||||
log_outcoming_action (s, buffer, nick, text->str);
|
||||
else
|
||||
log_outcoming_privmsg (s, buffer, prefixes, nick, text->str);
|
||||
}
|
||||
else if (is_action)
|
||||
log_server (s, buffer, BUFFER_LINE_HIGHLIGHT,
|
||||
" #a*#r #n #m", ATTR_HIGHLIGHT, msg->prefix, text->str);
|
||||
if (is_action)
|
||||
log_outcoming_action (s, buffer, nickname, text->str);
|
||||
else
|
||||
log_server (s, buffer, BUFFER_LINE_HIGHLIGHT,
|
||||
"#a<#s#s>#r #m", ATTR_HIGHLIGHT, prefixes, nick, text->str);
|
||||
log_outcoming_privmsg (s, buffer, prefixes, nickname, text->str);
|
||||
}
|
||||
else if (is_action)
|
||||
log_server (s, buffer, BUFFER_LINE_HIGHLIGHT,
|
||||
" #a*#r #n #m", ATTR_HIGHLIGHT, msg->prefix, text->str);
|
||||
else
|
||||
log_server (s, buffer, BUFFER_LINE_HIGHLIGHT,
|
||||
"#a<#s#s>#r #m", ATTR_HIGHLIGHT, prefixes, nickname, text->str);
|
||||
|
||||
free (nick);
|
||||
free (nickname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5722,18 +5725,7 @@ static void
|
|||
log_autosplit_privmsg (struct server *s,
|
||||
struct send_autosplit_args *a, struct buffer *buffer, const char *line)
|
||||
{
|
||||
const char *prefixes = "";
|
||||
if (irc_is_channel (s, a->target))
|
||||
{
|
||||
struct user *user;
|
||||
struct channel *channel;
|
||||
struct channel_user *channel_user;
|
||||
if ((user = s->irc_user)
|
||||
&& (channel = str_map_find (&s->irc_channels, a->target))
|
||||
&& (channel_user = irc_channel_get_user (channel, user)))
|
||||
prefixes = channel_user->prefixes.str;
|
||||
}
|
||||
|
||||
const char *prefixes = irc_get_privmsg_prefix (s, s->irc_user, a->target);
|
||||
if (buffer && soft_assert (s->irc_user))
|
||||
log_outcoming_privmsg (s, buffer,
|
||||
prefixes, s->irc_user->nickname, line);
|
||||
|
|
Loading…
Reference in New Issue