diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-20 21:38:04 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-20 21:38:04 +0200 |
commit | 974ce75a59c4afde362b1695e708fe44e3b270b9 (patch) | |
tree | a29a58d66de5b602067bfe15570a1724bd081e8c | |
parent | 935d671a57e24d79201a129d3c7130d1da5273d9 (diff) | |
download | xK-974ce75a59c4afde362b1695e708fe44e3b270b9.tar.gz xK-974ce75a59c4afde362b1695e708fe44e3b270b9.tar.xz xK-974ce75a59c4afde362b1695e708fe44e3b270b9.zip |
degesch: add support for IRCv3.2 echo-message
-rw-r--r-- | degesch.c | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -1060,6 +1060,8 @@ struct server struct str irc_user_mode; ///< Our current user modes char *irc_user_host; ///< Our current user@host + bool cap_echo_message; ///< Whether the server echos messages + // Server-specific information (from RPL_ISUPPORT): /// Convert an IRC identifier character to lower-case @@ -3207,6 +3209,7 @@ on_irc_disconnected (struct server *s) s->irc_user_host = NULL; // TODO: reset RPL_ISUPPORT information + s->cap_echo_message = false; // Take any relevant actions if (s->ctx->quitting) @@ -3830,14 +3833,17 @@ irc_get_buffer_for_message (struct server *s, } else if (!buffer) { - // Implying that the target is us - // Don't make user buffers for servers (they can send NOTICEs) if (!irc_find_userhost (msg->prefix)) return s->buffer; char *nickname = irc_cut_nickname (msg->prefix); - buffer = irc_get_or_make_user_buffer (s, nickname); + if (irc_is_this_us (s, target)) + buffer = irc_get_or_make_user_buffer (s, nickname); + // With the IRCv3.2 echo-message capability, we can receive messages + // as they are delivired to the target; in that case, check the origin + else if (soft_assert (irc_is_this_us (s, nickname))) + buffer = irc_get_or_make_user_buffer (s, target); free (nickname); } return buffer; @@ -4066,12 +4072,24 @@ irc_handle_cap (struct server *s, const struct irc_message *msg) split_str_ignore_empty (msg->params.vector[2], ' ', &v); const char *subcommand = msg->params.vector[1]; - if (!strcasecmp_ascii (subcommand, "ACK") - || !strcasecmp_ascii (subcommand, "NAK")) + if (!strcasecmp_ascii (subcommand, "ACK")) { - // So far we don't need to take any other actions + for (size_t i = 0; i < v.len; i++) + { + const char *cap = v.vector[i]; + bool active = true; + if (*cap == '-') + { + active = false; + cap++; + } + if (!strcasecmp_ascii (cap, "echo-message")) + s->cap_echo_message = active; + } irc_send (s, "CAP END"); } + else if (!strcasecmp_ascii (subcommand, "NAK")) + irc_send (s, "CAP END"); else if (!strcasecmp_ascii (subcommand, "LS")) { struct str_vector chosen; @@ -4082,7 +4100,8 @@ irc_handle_cap (struct server *s, const struct irc_message *msg) { const char *cap = v.vector[i]; if (!strcasecmp_ascii (cap, "multi-prefix") - || !strcasecmp_ascii (cap, "invite-notify")) + || !strcasecmp_ascii (cap, "invite-notify") + || !strcasecmp_ascii (cap, "echo-message")) str_vector_add (&chosen, cap); } @@ -5475,7 +5494,8 @@ send_autosplit_message (struct server *s, struct send_autosplit_args a) { irc_send (s, "%s %s :%s%s%s", a.command, a.target, a.prefix, lines.vector[i], a.suffix); - a.logger (s, &a, buffer, lines.vector[i]); + if (!s->cap_echo_message) + a.logger (s, &a, buffer, lines.vector[i]); } end: str_vector_free (&lines); |