aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/degesch.c b/degesch.c
index acec999..001aba2 100644
--- a/degesch.c
+++ b/degesch.c
@@ -551,6 +551,8 @@ app_context_free (struct app_context *self)
}
static void refresh_prompt (struct app_context *ctx);
+static char *irc_cut_nickname (const char *prefix);
+static const char *irc_find_userhost (const char *prefix);
// --- Attributed output -------------------------------------------------------
@@ -884,27 +886,37 @@ buffer_line_display (struct app_context *ctx, struct buffer_line *line)
// and formatting into. We could have a varargs function to make it a bit
// more friendly, e.g. push(&x, ATTR_JOIN, "--> ", ATTR_RESET, who, NULL)
+ char *nick = NULL;
+ const char *userhost = NULL;
+
+ if (who)
+ {
+ nick = irc_cut_nickname (who);
+ userhost = irc_find_userhost (who);
+ }
+
switch (line->type)
{
case BUFFER_LINE_PRIVMSG:
- str_append_printf (&text, "<%s> %s", who, object);
+ str_append_printf (&text, "<%s> %s", nick, object);
break;
case BUFFER_LINE_ACTION:
- str_append_printf (&text, " * %s %s", who, object);
+ str_append_printf (&text, " * %s %s", nick, object);
break;
case BUFFER_LINE_NOTICE:
- str_append_printf (&text, " - Notice(%s): %s", who, object);
+ str_append_printf (&text, " - Notice(%s): %s", nick, object);
break;
case BUFFER_LINE_JOIN:
if (who)
- str_append_printf (&text, "--> %s has joined %s", who, object);
+ str_append_printf (&text, "--> %s (%s) has joined %s",
+ nick, userhost, object);
else
str_append_printf (&text, "--> You have joined %s", object);
break;
case BUFFER_LINE_PART:
if (who)
- str_append_printf (&text, "<-- %s has left %s (%s)",
- who, object, reason);
+ str_append_printf (&text, "<-- %s (%s) has left %s (%s)",
+ nick, userhost, object, reason);
else
str_append_printf (&text, "<-- You have left %s (%s)",
object, reason);
@@ -912,14 +924,15 @@ buffer_line_display (struct app_context *ctx, struct buffer_line *line)
case BUFFER_LINE_KICK:
if (who)
str_append_printf (&text, "<-- %s has kicked %s (%s)",
- who, object, reason);
+ nick, object, reason);
else
str_append_printf (&text, "<-- You have kicked %s (%s)",
object, reason);
break;
case BUFFER_LINE_QUIT:
if (who)
- str_append_printf (&text, "<-- %s has quit (%s)", who, reason);
+ str_append_printf (&text, "<-- %s (%s) has quit (%s)",
+ nick, userhost, reason);
else
str_append_printf (&text, "<-- You have quit (%s)", reason);
break;
@@ -930,6 +943,8 @@ buffer_line_display (struct app_context *ctx, struct buffer_line *line)
str_append_printf (&text, "=!= %s", object);
}
+ free (nick);
+
free (who);
free (object);
free (reason);
@@ -1212,6 +1227,13 @@ irc_cut_nickname (const char *prefix)
return xstrndup (prefix, strcspn (prefix, "!@"));
}
+static const char *
+irc_find_userhost (const char *prefix)
+{
+ const char *p = strchr (prefix, '!');
+ return p ? p + 1 : NULL;
+}
+
static bool
irc_is_this_us (struct app_context *ctx, const char *prefix)
{