degesch: don't show joins etc. as new activity

It's mostly just spam that shouldn't get your attention.
This commit is contained in:
Přemysl Eric Janouch 2015-08-08 21:17:32 +02:00
parent cdf6544c94
commit e188de5501
1 changed files with 19 additions and 11 deletions

View File

@ -968,7 +968,8 @@ enum buffer_line_flags
BUFFER_LINE_ERROR = 1 << 1, ///< Error message BUFFER_LINE_ERROR = 1 << 1, ///< Error message
BUFFER_LINE_HIGHLIGHT = 1 << 2, ///< The user was highlighted by this BUFFER_LINE_HIGHLIGHT = 1 << 2, ///< The user was highlighted by this
BUFFER_LINE_SKIP_FILE = 1 << 3, ///< Don't log this to file BUFFER_LINE_SKIP_FILE = 1 << 3, ///< Don't log this to file
BUFFER_LINE_INDENT = 1 << 4 ///< Just indent the line BUFFER_LINE_INDENT = 1 << 4, ///< Just indent the line
BUFFER_LINE_UNIMPORTANT = 1 << 5 ///< Joins, parts, similar spam
}; };
struct buffer_line struct buffer_line
@ -1022,6 +1023,7 @@ struct buffer
unsigned lines_count; ///< How many lines we have unsigned lines_count; ///< How many lines we have
unsigned unseen_messages_count; ///< # messages since last visited unsigned unseen_messages_count; ///< # messages since last visited
unsigned unseen_unimportant_count; ///< How much of that is unimportant
bool highlighted; ///< We've been highlighted bool highlighted; ///< We've been highlighted
FILE *log_file; ///< Log file FILE *log_file; ///< Log file
@ -2898,6 +2900,8 @@ log_formatter (struct app_context *ctx,
if (!displayed) if (!displayed)
{ {
buffer->unseen_messages_count++; buffer->unseen_messages_count++;
if (flags & BUFFER_LINE_UNIMPORTANT)
buffer->unseen_unimportant_count++;
if (flags & BUFFER_LINE_HIGHLIGHT) if (flags & BUFFER_LINE_HIGHLIGHT)
buffer->highlighted = true; buffer->highlighted = true;
@ -2954,9 +2958,11 @@ log_full (struct app_context *ctx, struct server *s, struct buffer *buffer,
// Lines that are used in more than one place // Lines that are used in more than one place
#define log_nick_self(s, buffer, new_) \ #define log_nick_self(s, buffer, new_) \
log_server_status ((s), (buffer), "You are now known as #n", (new_)) log_server ((s), (buffer), BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT, \
"You are now known as #n", (new_))
#define log_nick(s, buffer, old, new_) \ #define log_nick(s, buffer, old, new_) \
log_server_status ((s), (buffer), "#n is now known as #n", (old), (new_)) log_server ((s), (buffer), BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT, \
"#n is now known as #n", (old), (new_))
#define log_outcoming_notice(s, buffer, who, text) \ #define log_outcoming_notice(s, buffer, who, text) \
log_server_status ((s), (buffer), "#s(#n): #m", "Notice", (who), (text)) log_server_status ((s), (buffer), "#s(#n): #m", "Notice", (who), (text))
@ -3125,6 +3131,7 @@ buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
} }
buffer->unseen_messages_count = 0; buffer->unseen_messages_count = 0;
buffer->unseen_unimportant_count = 0;
buffer->highlighted = false; buffer->highlighted = false;
// So that it is obvious if the last line in the buffer is not from today // So that it is obvious if the last line in the buffer is not from today
@ -3830,7 +3837,8 @@ irc_disconnect (struct server *s)
str_map_iter_init (&iter, &s->irc_buffer_map); str_map_iter_init (&iter, &s->irc_buffer_map);
struct buffer *buffer; struct buffer *buffer;
while ((buffer = str_map_iter_next (&iter))) while ((buffer = str_map_iter_next (&iter)))
log_server_status (s, buffer, "Disconnected from server"); log_server (s, buffer, BUFFER_LINE_STATUS | BUFFER_LINE_UNIMPORTANT,
"Disconnected from server");
irc_cancel_timers (s); irc_cancel_timers (s);
irc_destroy_transport (s); irc_destroy_transport (s);
@ -4670,18 +4678,18 @@ irc_initiate_connect (struct server *s)
static void static void
make_unseen_prefix (struct app_context *ctx, struct str *active_buffers) make_unseen_prefix (struct app_context *ctx, struct str *active_buffers)
{ {
size_t i = 0; size_t buffer_no = 0;
LIST_FOR_EACH (struct buffer, iter, ctx->buffers) LIST_FOR_EACH (struct buffer, iter, ctx->buffers)
{ {
i++; buffer_no++;
if (!iter->unseen_messages_count) if (!(iter->unseen_messages_count - iter->unseen_unimportant_count))
continue; continue;
if (active_buffers->len) if (active_buffers->len)
str_append_c (active_buffers, ','); str_append_c (active_buffers, ',');
if (iter->highlighted) if (iter->highlighted)
str_append_c (active_buffers, '!'); str_append_c (active_buffers, '!');
str_append_printf (active_buffers, "%zu", i); str_append_printf (active_buffers, "%zu", buffer_no);
} }
} }
@ -5185,7 +5193,7 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
// Finally log the message // Finally log the message
if (buffer) if (buffer)
{ {
log_server (s, buffer, 0, "#a-->#r #N #a#s#r #S", log_server (s, buffer, BUFFER_LINE_UNIMPORTANT, "#a-->#r #N #a#s#r #S",
ATTR_JOIN, msg->prefix, ATTR_JOIN, "has joined", channel_name); ATTR_JOIN, msg->prefix, ATTR_JOIN, "has joined", channel_name);
} }
} }
@ -5487,7 +5495,7 @@ irc_handle_part (struct server *s, const struct irc_message *msg)
ATTR_PART, msg->prefix, ATTR_PART, "has left", channel_name); ATTR_PART, msg->prefix, ATTR_PART, "has left", channel_name);
if (message) if (message)
formatter_add (&f, " (#m)", message); formatter_add (&f, " (#m)", message);
log_formatter (s->ctx, buffer, 0, &f); log_formatter (s->ctx, buffer, BUFFER_LINE_UNIMPORTANT, &f);
} }
} }
@ -5644,7 +5652,7 @@ log_quit (struct server *s,
ATTR_PART, prefix, ATTR_PART, "has quit"); ATTR_PART, prefix, ATTR_PART, "has quit");
if (reason) if (reason)
formatter_add (&f, " (#m)", reason); formatter_add (&f, " (#m)", reason);
log_formatter (s->ctx, buffer, 0, &f); log_formatter (s->ctx, buffer, BUFFER_LINE_UNIMPORTANT, &f);
} }
static void static void