summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-10 22:37:29 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-10 22:37:29 +0200
commitee1f4174fdc3465238b3e6618c015ceb8cc1e230 (patch)
tree93f7b16f4ebb7cd14d770bd438c03e605d63a99c
parentc6738826700b41ca8e4d7c011d92ddce552a7b60 (diff)
downloadxK-ee1f4174fdc3465238b3e6618c015ceb8cc1e230.tar.gz
xK-ee1f4174fdc3465238b3e6618c015ceb8cc1e230.tar.xz
xK-ee1f4174fdc3465238b3e6618c015ceb8cc1e230.zip
degesch: process INVITE
-rw-r--r--degesch.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/degesch.c b/degesch.c
index 88ba593..16aa500 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4041,6 +4041,35 @@ irc_handle_mode_user (struct server *s, char **params)
// --- Input handling ----------------------------------------------------------
static void
+irc_handle_invite (struct server *s, const struct irc_message *msg)
+{
+ if (!msg->prefix || msg->params.len < 2)
+ return;
+
+ const char *target = msg->params.vector[0];
+ const char *channel_name = msg->params.vector[1];
+
+ struct buffer *buffer;
+ if (!(buffer = str_map_find (&s->irc_buffer_map, channel_name)))
+ buffer = s->buffer;
+
+ // FIXME: logging
+ char *who = irc_cut_nickname (msg->prefix);
+ char *who_utf8 = irc_to_utf8 (s->ctx, who);
+ free (who);
+
+ // IRCv3.2 invite-notify extension allows the target to be someone else
+ if (irc_is_this_us (s, target))
+ buffer_send_status (s->ctx, buffer,
+ "%s has invited you to %s", who_utf8, channel_name);
+ else
+ buffer_send_status (s->ctx, buffer,
+ "%s has invited %s to %s", who_utf8, target, channel_name);
+
+ free (who_utf8);
+}
+
+static void
irc_handle_join (struct server *s, const struct irc_message *msg)
{
if (!msg->prefix || msg->params.len < 1)
@@ -4601,6 +4630,7 @@ static struct irc_handler
g_irc_handlers[] =
{
// This list needs to stay sorted
+ { "INVITE", irc_handle_invite },
{ "JOIN", irc_handle_join },
{ "KICK", irc_handle_kick },
{ "MODE", irc_handle_mode },