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:
parent
2b90aa097e
commit
a4e18d306e
|
@ -810,9 +810,19 @@ plugin_process_message (const struct irc_message *msg,
|
||||||
printf ("%s\n", msg->params.vector[1]);
|
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
|
// 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);
|
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
|
irc_process_buffer (buf, plugin_process_message, plugin);
|
||||||
struct bot_context *ctx = plugin->ctx;
|
|
||||||
if (ctx->irc_fd != -1 && ctx->irc_ready)
|
|
||||||
irc_process_buffer (buf, plugin_process_message, plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -1434,6 +1441,7 @@ on_irc_disconnected (struct bot_context *ctx)
|
||||||
|
|
||||||
xclose (ctx->irc_fd);
|
xclose (ctx->irc_fd);
|
||||||
ctx->irc_fd = -1;
|
ctx->irc_fd = -1;
|
||||||
|
ctx->irc_ready = false;
|
||||||
|
|
||||||
// TODO: inform plugins about the disconnect event
|
// TODO: inform plugins about the disconnect event
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue