From 3582789cf51f0bf02b274429b5817d0f143441d4 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Mon, 15 Jun 2015 01:03:34 +0200
Subject: ZyklonB: unfuck registration
---
zyklonb.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/zyklonb.c b/zyklonb.c
index 3c147a5..dcb9223 100644
--- a/zyklonb.c
+++ b/zyklonb.c
@@ -126,7 +126,7 @@ struct bot_context
int irc_fd; ///< Socket FD of the server
struct str read_buffer; ///< Input yet to be processed
struct poller_fd irc_event; ///< IRC FD event
- bool irc_ready; ///< Whether we may send messages now
+ bool irc_registered; ///< Whether we may send messages now
struct poller_fd signal_event; ///< Signal FD event
struct poller_timer ping_tmr; ///< We should send a ping
@@ -158,7 +158,7 @@ bot_context_init (struct bot_context *self)
self->irc_fd = -1;
str_init (&self->read_buffer);
- self->irc_ready = false;
+ self->irc_registered = false;
self->ssl = NULL;
self->ssl_ctx = NULL;
@@ -910,7 +910,7 @@ plugin_process_message (const struct irc_message *msg,
printf ("%s\n", msg->params.vector[1]);
}
}
- else if (plugin->initialized && ctx->irc_ready)
+ else if (plugin->initialized && ctx->irc_registered)
{
// Pass everything else through to the IRC server
// XXX: when the server isn't ready yet, these messages get silently
@@ -1371,7 +1371,7 @@ static void
irc_forward_message_to_plugins (struct bot_context *ctx, const char *raw)
{
// For consistency with plugin_process_message()
- if (!ctx->irc_ready)
+ if (!ctx->irc_registered)
return;
for (struct plugin *plugin = ctx->plugins;
@@ -1411,12 +1411,10 @@ irc_process_message (const struct irc_message *msg,
else
irc_send (ctx, "PONG");
}
- else if (!ctx->irc_ready && (!strcasecmp (msg->command, "MODE")
- || !strcasecmp (msg->command, "376") // RPL_ENDOFMOTD
- || !strcasecmp (msg->command, "422"))) // ERR_NOMOTD
+ else if (!ctx->irc_registered && !strcasecmp (msg->command, "001"))
{
print_status ("successfully connected");
- ctx->irc_ready = true;
+ ctx->irc_registered = true;
const char *autojoin = str_map_find (&ctx->config, "autojoin");
if (autojoin)
@@ -1544,7 +1542,7 @@ on_irc_disconnected (struct bot_context *ctx)
xclose (ctx->irc_fd);
ctx->irc_fd = -1;
- ctx->irc_ready = false;
+ ctx->irc_registered = false;
ctx->irc_event.closed = true;
poller_fd_reset (&ctx->irc_event);
--
cgit v1.2.3-70-g09d2