ZyklonB: unfuck registration
This commit is contained in:
parent
f2998db30b
commit
3582789cf5
16
zyklonb.c
16
zyklonb.c
|
@ -126,7 +126,7 @@ struct bot_context
|
||||||
int irc_fd; ///< Socket FD of the server
|
int irc_fd; ///< Socket FD of the server
|
||||||
struct str read_buffer; ///< Input yet to be processed
|
struct str read_buffer; ///< Input yet to be processed
|
||||||
struct poller_fd irc_event; ///< IRC FD event
|
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_fd signal_event; ///< Signal FD event
|
||||||
struct poller_timer ping_tmr; ///< We should send a ping
|
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;
|
self->irc_fd = -1;
|
||||||
str_init (&self->read_buffer);
|
str_init (&self->read_buffer);
|
||||||
self->irc_ready = false;
|
self->irc_registered = false;
|
||||||
|
|
||||||
self->ssl = NULL;
|
self->ssl = NULL;
|
||||||
self->ssl_ctx = NULL;
|
self->ssl_ctx = NULL;
|
||||||
|
@ -910,7 +910,7 @@ 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 && ctx->irc_ready)
|
else if (plugin->initialized && ctx->irc_registered)
|
||||||
{
|
{
|
||||||
// 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
|
// 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)
|
irc_forward_message_to_plugins (struct bot_context *ctx, const char *raw)
|
||||||
{
|
{
|
||||||
// For consistency with plugin_process_message()
|
// For consistency with plugin_process_message()
|
||||||
if (!ctx->irc_ready)
|
if (!ctx->irc_registered)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (struct plugin *plugin = ctx->plugins;
|
for (struct plugin *plugin = ctx->plugins;
|
||||||
|
@ -1411,12 +1411,10 @@ irc_process_message (const struct irc_message *msg,
|
||||||
else
|
else
|
||||||
irc_send (ctx, "PONG");
|
irc_send (ctx, "PONG");
|
||||||
}
|
}
|
||||||
else if (!ctx->irc_ready && (!strcasecmp (msg->command, "MODE")
|
else if (!ctx->irc_registered && !strcasecmp (msg->command, "001"))
|
||||||
|| !strcasecmp (msg->command, "376") // RPL_ENDOFMOTD
|
|
||||||
|| !strcasecmp (msg->command, "422"))) // ERR_NOMOTD
|
|
||||||
{
|
{
|
||||||
print_status ("successfully connected");
|
print_status ("successfully connected");
|
||||||
ctx->irc_ready = true;
|
ctx->irc_registered = true;
|
||||||
|
|
||||||
const char *autojoin = str_map_find (&ctx->config, "autojoin");
|
const char *autojoin = str_map_find (&ctx->config, "autojoin");
|
||||||
if (autojoin)
|
if (autojoin)
|
||||||
|
@ -1544,7 +1542,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;
|
ctx->irc_registered = false;
|
||||||
|
|
||||||
ctx->irc_event.closed = true;
|
ctx->irc_event.closed = true;
|
||||||
poller_fd_reset (&ctx->irc_event);
|
poller_fd_reset (&ctx->irc_event);
|
||||||
|
|
Loading…
Reference in New Issue