diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-08-01 00:42:17 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-08-01 00:42:17 +0200 |
commit | 16852048ed0f781761c79e8f0d46c8331d5fcd25 (patch) | |
tree | db5c65f6f071717c309f0c3b9a78a30b2f45c966 | |
parent | a4e18d306ed1f21a8b40edbea982684dea6039de (diff) | |
download | xK-16852048ed0f781761c79e8f0d46c8331d5fcd25.tar.gz xK-16852048ed0f781761c79e8f0d46c8331d5fcd25.tar.xz xK-16852048ed0f781761c79e8f0d46c8331d5fcd25.zip |
Don't forward messages while !irc_ready
-rw-r--r-- | src/zyklonb.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/zyklonb.c b/src/zyklonb.c index 9874961..c99b141 100644 --- a/src/zyklonb.c +++ b/src/zyklonb.c @@ -1257,20 +1257,12 @@ process_privmsg (struct bot_context *ctx, const struct irc_message *msg) } static void -irc_process_message (const struct irc_message *msg, - const char *raw, void *user_data) +irc_forward_message_to_plugins (struct bot_context *ctx, const char *raw) { - struct bot_context *ctx = user_data; - if (g_debug_mode) - fprintf (stderr, "[%s] ==> \"%s\"\n", "IRC", raw); - - // This should be as minimal as possible, I don't want to have the whole bot - // written in C, especially when I have this overengineered plugin system. - // Therefore the very basic functionality only. - // - // I should probably even rip out the autojoin... + // For consistency with plugin_process_message() + if (!ctx->irc_ready) + return; - // First forward the message to all the plugins for (struct plugin_data *plugin = ctx->plugins; plugin; plugin = plugin->next) { @@ -1283,6 +1275,23 @@ irc_process_message (const struct irc_message *msg, // TODO: make sure that this buffer doesn't get too large either str_append_printf (&plugin->queued_output, "%s\r\n", raw); } +} + +static void +irc_process_message (const struct irc_message *msg, + const char *raw, void *user_data) +{ + struct bot_context *ctx = user_data; + if (g_debug_mode) + fprintf (stderr, "[%s] ==> \"%s\"\n", "IRC", raw); + + // This should be as minimal as possible, I don't want to have the whole bot + // written in C, especially when I have this overengineered plugin system. + // Therefore the very basic functionality only. + // + // I should probably even rip out the autojoin... + + irc_forward_message_to_plugins (ctx, raw); if (!strcasecmp (msg->command, "PING")) { |