ZyklonB: factor out plugin_process_ipc()
This commit is contained in:
		
							
								
								
									
										28
									
								
								zyklonb.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								zyklonb.c
									
									
									
									
									
								
							@@ -854,17 +854,8 @@ plugin_send (struct plugin *plugin, const char *format, ...)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
plugin_process_message (const struct irc_message *msg,
 | 
			
		||||
	const char *raw, void *user_data)
 | 
			
		||||
plugin_process_ipc (struct plugin *plugin, const struct irc_message *msg)
 | 
			
		||||
{
 | 
			
		||||
	struct plugin *plugin = user_data;
 | 
			
		||||
	struct bot_context *ctx = plugin->ctx;
 | 
			
		||||
 | 
			
		||||
	if (g_debug_mode)
 | 
			
		||||
		fprintf (stderr, "[%s] --> \"%s\"\n", plugin->name, raw);
 | 
			
		||||
 | 
			
		||||
	if (!strcasecmp (msg->command, plugin_ipc_command))
 | 
			
		||||
	{
 | 
			
		||||
	// Replies are sent in the order in which they came in, so there's
 | 
			
		||||
	// no need to attach a special identifier to them.  It might be
 | 
			
		||||
	// desirable in some cases, though.
 | 
			
		||||
@@ -897,7 +888,7 @@ plugin_process_message (const struct irc_message *msg,
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		const char *value =
 | 
			
		||||
				str_map_find (&ctx->config, msg->params.vector[1]);
 | 
			
		||||
			str_map_find (&plugin->ctx->config, msg->params.vector[1]);
 | 
			
		||||
		// TODO: escape the value (although there's no need to ATM)
 | 
			
		||||
		plugin_send (plugin, "%s :%s",
 | 
			
		||||
			plugin_ipc_command, value ? value : "");
 | 
			
		||||
@@ -909,7 +900,20 @@ plugin_process_message (const struct irc_message *msg,
 | 
			
		||||
 | 
			
		||||
		printf ("%s\n", msg->params.vector[1]);
 | 
			
		||||
	}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
plugin_process_message (const struct irc_message *msg,
 | 
			
		||||
	const char *raw, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
	struct plugin *plugin = user_data;
 | 
			
		||||
	struct bot_context *ctx = plugin->ctx;
 | 
			
		||||
 | 
			
		||||
	if (g_debug_mode)
 | 
			
		||||
		fprintf (stderr, "[%s] --> \"%s\"\n", plugin->name, raw);
 | 
			
		||||
 | 
			
		||||
	if (!strcasecmp (msg->command, plugin_ipc_command))
 | 
			
		||||
		plugin_process_ipc (plugin, msg);
 | 
			
		||||
	else if (plugin->initialized && ctx->irc_registered)
 | 
			
		||||
	{
 | 
			
		||||
		// Pass everything else through to the IRC server
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user