Пример #1
0
int plugin_register(struct plugin_handle* plugin, const char* config)
{
	PLUGIN_INITIALIZE(plugin, "SQLite logging plugin", "0.5", "Logs users entering and leaving the hub to SQLite database.");

	struct log_data* ldata;

	plugin->funcs.on_user_login = log_user_login;
	plugin->funcs.on_user_login_error = log_user_login_error;
	plugin->funcs.on_user_logout = log_user_logout;
	plugin->funcs.on_user_nick_change = log_change_nick;

	ldata = parse_config(config, plugin);

	if (!ldata)
		return -1;

	ldata->command_userlog_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(ldata->command_userlog_handle, plugin, "userlog", "?N?mm", auth_cred_operator, &command_userlog, "[<lines> [<column> <search pattern>]]", "Search in userlog for a value.");
	plugin->hub.command_add(plugin, ldata->command_userlog_handle);

	ldata->command_userlogcleanup_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(ldata->command_userlogcleanup_handle, plugin, "userlogcleanup", "N", auth_cred_admin, &command_userlogcleanup, "<days>", "Delete log entries.");
	plugin->hub.command_add(plugin, ldata->command_userlogcleanup_handle);

	plugin->ptr = ldata;

	create_tables(plugin);

	return 0;
}
Пример #2
0
int plugin_register(struct plugin_handle* plugin, const char* config)
{
	struct chat_history_data* data;
	PLUGIN_INITIALIZE(plugin, "SQLite chat history plugin", "1.0", "Provide a global chat history log.");

	plugin->funcs.on_user_chat_message = history_add;
	plugin->funcs.on_user_login = user_login;
	data = parse_config(config, plugin);
	
	if (!data)
		return -1;

	plugin->ptr = data;

	create_tables(plugin);

	data->command_history_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(data->command_history_handle, plugin, "history", "?N", auth_cred_guest, &command_history, "Show chat message history.");
	plugin->hub.command_add(plugin, data->command_history_handle);

	data->command_historycleanup_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(data->command_historycleanup_handle, plugin, "historycleanup", "", auth_cred_admin, &command_historycleanup, "Clean chat message history.");
	plugin->hub.command_add(plugin, data->command_historycleanup_handle);

	return 0;
}
Пример #3
0
int plugin_register(struct plugin_handle* plugin, const char* config)
{
	struct extras_data* extrasdata;
	PLUGIN_INITIALIZE(plugin, "Extras plugin", "0.1", "Plugin for extra features like hub news, releases, hublist.");

	extrasdata = parse_config(config, plugin);

	if (!extrasdata)
		return -1;
  
	extrasdata->command_hubadd_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_hubadd_handle, plugin, "hubadd", "m+m", auth_cred_admin, &command_hubadd, "<address> <hub name>", "Add hub to hublist.");
	plugin->hub.command_add(plugin, extrasdata->command_hubadd_handle);

	extrasdata->command_hubdel_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_hubdel_handle, plugin, "hubdel", "N", auth_cred_admin, &command_hubdel, "<hub id>", "Delete hub from hublist.");
	plugin->hub.command_add(plugin, extrasdata->command_hubdel_handle);

	extrasdata->command_hublist_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_hublist_handle, plugin, "hublist", "", auth_cred_user, &command_hublist, "", "List hubs in hublist.");
	plugin->hub.command_add(plugin, extrasdata->command_hublist_handle);

	extrasdata->command_newsadd_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_newsadd_handle, plugin, "newsadd", "+m", auth_cred_admin, &command_newsadd, "", "Add news item.");
	plugin->hub.command_add(plugin, extrasdata->command_newsadd_handle);

	extrasdata->command_newsdel_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_newsdel_handle, plugin, "newsdel", "N", auth_cred_admin, &command_newsdel, "<news id>", "Delete news item.");
	plugin->hub.command_add(plugin, extrasdata->command_newsdel_handle);

	extrasdata->command_news_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_news_handle, plugin, "news", "", auth_cred_user, &command_news, "", "Show hubnews.");
	plugin->hub.command_add(plugin, extrasdata->command_news_handle);

	extrasdata->command_releaseadd_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_releaseadd_handle, plugin, "releaseadd", "m+m", auth_cred_admin, &command_releaseadd, "<tth> <title>", "Add release.");
	plugin->hub.command_add(plugin, extrasdata->command_releaseadd_handle);

	extrasdata->command_releasedel_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_releasedel_handle, plugin, "releasedel", "N", auth_cred_admin, &command_releasedel, "<release id>", "Delete release.");
	plugin->hub.command_add(plugin, extrasdata->command_releasedel_handle);

	extrasdata->command_releases_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(extrasdata->command_releases_handle, plugin, "releases", "", auth_cred_user, &command_releases, "", "Show releases.");
	plugin->hub.command_add(plugin, extrasdata->command_releases_handle);

	plugin->ptr = extrasdata;
	
	create_tables(plugin);
	
	return 0;
}
Пример #4
0
static void command_register(struct plugin_handle* plugin)
{
	struct example_plugin_data* data = (struct example_plugin_data*) hub_malloc(sizeof(struct example_plugin_data));
	data->example = hub_malloc_zero(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(data->example, (void*) data, "example", "", auth_cred_guest, example_command_handler, "This is an example command that is added dynamically by loading the mod_example plug-in.");
	plugin->hub.command_add(plugin, data->example);
	plugin->ptr = data;
}
Пример #5
0
int plugin_register(struct plugin_handle* plugin, const char* config)
{
	struct topic_plugin_data* data = (struct topic_plugin_data*) hub_malloc(sizeof(struct topic_plugin_data));

	data->topic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
	data->resettopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
	data->showtopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));

	PLUGIN_INITIALIZE(plugin, "Topic plugin", "1.0", "Add commands for changing the hub topic (description)");

	PLUGIN_COMMAND_INITIALIZE(data->topic, (void*) data, "topic", "+m", auth_cred_operator, command_topic_handler, "Set new topic");
	PLUGIN_COMMAND_INITIALIZE(data->resettopic, (void*) data, "resettopic", "", auth_cred_operator, command_resettopic_handler, "Set topic to default");
	PLUGIN_COMMAND_INITIALIZE(data->showtopic, (void*) data, "showtopic", "", auth_cred_guest, command_showtopic_handler, "Shows the current topic");

	plugin->hub.command_add(plugin, data->topic);
	plugin->hub.command_add(plugin, data->resettopic);
	plugin->hub.command_add(plugin, data->showtopic);
	plugin->ptr = data;


	return 0;
}
Пример #6
0
int plugin_register(struct plugin_handle* plugin, const char* config)
{
	struct patterns_data* pdata;
	PLUGIN_INITIALIZE(plugin, "Forbidden patterns plugin", "0.4", "Searches for forbidden patterns in chat messages and user info.");

	plugin->funcs.on_chat_msg = check_mainchat;
	plugin->funcs.on_private_msg = check_pm;
	plugin->funcs.on_check_user_late = check_user_info;

	pdata = parse_config(config, plugin);

	if (!pdata)
		return -1;
	
	if(!create_patterns_table(plugin, pdata))
		return -1;
	
	if(!create_pattern_exceptions_table(plugin, pdata))
		return -1;
  
	pdata->command_patternadd_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patternadd_handle, plugin, "patternadd", "mCC+m", auth_cred_admin, &command_patternadd, "<type> <min credentials> <max credentials> <pattern>", "Add forbidden pattern.");
	plugin->hub.command_add(plugin, pdata->command_patternadd_handle);

	pdata->command_patterndel_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patterndel_handle, plugin, "patterndel", "N", auth_cred_admin, &command_patterndel, "<pattern id>", "Delete forbidden pattern.");
	plugin->hub.command_add(plugin, pdata->command_patterndel_handle);
	
	pdata->command_patternlist_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patternlist_handle, plugin, "patternlist", "", auth_cred_super, &command_patternlist, "", "List forbidden patterns.");
	plugin->hub.command_add(plugin, pdata->command_patternlist_handle);
	
	pdata->command_patterntest_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patterntest_handle, plugin, "patterntest", "N+m", auth_cred_super, &command_patterntest, "<pattern id> <test string>", "Test a pattern (must be added first).");
	plugin->hub.command_add(plugin, pdata->command_patterntest_handle);

	pdata->command_patternexadd_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patternexadd_handle, plugin, "patternexadd", "NCC+m", auth_cred_admin, &command_patternexadd, "<pattern id> <min credentials> <max credentials> <exception pattern>", "Add exception to a forbidden pattern.");
	plugin->hub.command_add(plugin, pdata->command_patternexadd_handle);

	pdata->command_patternexdel_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patternexdel_handle, plugin, "patternexdel", "N", auth_cred_admin, &command_patternexdel, "<exception id>", "Delete pattern exception.");
	plugin->hub.command_add(plugin, pdata->command_patternexdel_handle);
	
	pdata->command_patternexlist_handle = (struct plugin_command_handle*) hub_malloc(sizeof(struct plugin_command_handle));
	PLUGIN_COMMAND_INITIALIZE(pdata->command_patternexlist_handle, plugin, "patternexlist", "", auth_cred_super, &command_patternexlist, "", "List pattern exceptions.");
	plugin->hub.command_add(plugin, pdata->command_patternexlist_handle);

	plugin->ptr = pdata;
	
	return 0;
}