From 5ca07656a12d267963263e8ea5e958140200e62e Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Thu, 24 Sep 2015 01:39:49 +0200
Subject: degesch: fix handling of status messages
That is, messages using the STATUSMSG feature.
---
degesch.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/degesch.c b/degesch.c
index 030d37b..1c8427c 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2340,6 +2340,13 @@ irc_is_channel (struct server *s, const char *ident)
!!strchr (s->irc_idchan_prefixes, *ident));
}
+// Message targets can be prefixed by a character filtering their targets
+static const char *
+irc_skip_statusmsg (struct server *s, const char *target)
+{
+ return target + (*target && strchr (s->irc_statusmsg, *target));
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// As of 2015, everything should be in UTF-8. And if it's not, we'll decode it
@@ -4850,6 +4857,9 @@ static struct buffer *
irc_get_buffer_for_message (struct server *s,
const struct irc_message *msg, const char *target)
{
+ // TODO: display such messages differently
+ target = irc_skip_statusmsg (s, target);
+
struct buffer *buffer = str_map_find (&s->irc_buffer_map, target);
if (irc_is_channel (s, target))
{
@@ -4918,6 +4928,8 @@ irc_get_privmsg_prefix (struct server *s, struct user *user, const char *target)
{
struct str prefix;
str_init (&prefix);
+
+ target = irc_skip_statusmsg (s, target);
if (user && irc_is_channel (s, target))
{
struct channel *channel;
@@ -5615,7 +5627,7 @@ irc_handle_ctcp_request (struct server *s,
struct formatter f;
formatter_init (&f, s->ctx, s);
formatter_add (&f, "CTCP requested by #n", msg->prefix);
- if (irc_is_channel (s, target))
+ if (irc_is_channel (s, irc_skip_statusmsg (s, target)))
formatter_add (&f, " (to #S)", target);
formatter_add (&f, ": #S", chunk->tag.str);
log_formatter (s->ctx, s->buffer, BUFFER_LINE_STATUS, &f);
@@ -7526,7 +7538,7 @@ handle_command_query (struct handler_args *a)
return false;
char *target = cut_word (&a->arguments);
- if (irc_is_channel (a->s, target))
+ if (irc_is_channel (a->s, irc_skip_statusmsg (a->s, target)))
log_server_error (a->s, a->s->buffer, "Cannot query a channel");
else if (!*a->arguments)
log_server_error (a->s, a->s->buffer, "No text to send");
--
cgit v1.2.3-70-g09d2