Added support for dynamic commands.
Dynamic commands are user commands that can be added dynamically to the hub by a plugin. The example plugin (mod_example.c) adds a !example command that when invoked send a message to the user who invoked it.
This commit is contained in:
@@ -289,7 +289,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc
|
||||
}
|
||||
else
|
||||
{
|
||||
relay = command_dipatcher(hub, u, message);
|
||||
relay = command_invoke(hub->commands, u, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,6 +813,9 @@ struct hub_info* hub_start_service(struct hub_config* config)
|
||||
hub->status = hub_status_running;
|
||||
|
||||
g_hub = hub;
|
||||
|
||||
// Start the hub command sub-system
|
||||
hub->commands = command_initialize(hub);
|
||||
return hub;
|
||||
}
|
||||
|
||||
@@ -836,6 +839,7 @@ void hub_shutdown_service(struct hub_info* hub)
|
||||
list_destroy(hub->chat_history);
|
||||
list_clear(hub->logout_info, &hub_free);
|
||||
list_destroy(hub->logout_info);
|
||||
command_shutdown(hub->commands);
|
||||
hub_free(hub);
|
||||
hub = 0;
|
||||
g_hub = 0;
|
||||
@@ -851,7 +855,7 @@ int hub_plugins_load(struct hub_info* hub)
|
||||
if (!hub->plugins)
|
||||
return -1;
|
||||
|
||||
if (plugin_initialize(hub->config, hub->plugins) < 0)
|
||||
if (plugin_initialize(hub->config, hub) < 0)
|
||||
{
|
||||
hub_free(hub->plugins);
|
||||
hub->plugins = 0;
|
||||
|
||||
Reference in New Issue
Block a user