summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zyklonb.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/zyklonb.c b/src/zyklonb.c
index 919bf1d..9874961 100644
--- a/src/zyklonb.c
+++ b/src/zyklonb.c
@@ -810,9 +810,19 @@ plugin_process_message (const struct irc_message *msg,
printf ("%s\n", msg->params.vector[1]);
}
}
- else if (plugin->initialized)
+ else if (plugin->initialized && ctx->irc_ready)
{
// Pass everything else through to the IRC server
+ // XXX: when the server isn't ready yet, these messages get silently
+ // discarded, which shouldn't pose a problem most of the time.
+ // Perhaps we could send a "connected" notification on `register'
+ // if `irc_ready' is true, or after it becomes true later, so that
+ // plugins know when to start sending unprovoked IRC messages.
+ // XXX: another case is when the connection gets interrupted and the
+ // plugin tries to send something back while we're reconnecting.
+ // For that we might set up a global buffer that gets flushed out
+ // after `irc_ready' becomes true. Note that there is always some
+ // chance of messages getting lost without us even noticing it.
irc_send (ctx, "%s", raw);
}
}
@@ -872,10 +882,7 @@ on_plugin_readable (const struct pollfd *fd, struct plugin_data *plugin)
}
}
- // Hold it in the buffer while we're disconnected
- struct bot_context *ctx = plugin->ctx;
- if (ctx->irc_fd != -1 && ctx->irc_ready)
- irc_process_buffer (buf, plugin_process_message, plugin);
+ irc_process_buffer (buf, plugin_process_message, plugin);
}
static bool
@@ -1434,6 +1441,7 @@ on_irc_disconnected (struct bot_context *ctx)
xclose (ctx->irc_fd);
ctx->irc_fd = -1;
+ ctx->irc_ready = false;
// TODO: inform plugins about the disconnect event