Fix plugin autoload

I was trying to be too smart about holding up IRC messages coming from
plugins while the bot is disconnected.
This commit is contained in:
Přemysl Eric Janouch 2014-08-01 00:29:17 +02:00
parent 2b90aa097e
commit a4e18d306e
1 changed files with 13 additions and 5 deletions

View File

@ -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,9 +882,6 @@ 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);
}
@ -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