Add plugin to send user commands.

Adds a mod_ucmd plugin which uses the previously added user command
plugin functions to send user commands when users log in. These are read
from a text file in a simple format. They can be restricted to users
with certain credentials, and can have multiple actions (e.g., send a PM
and a message in the main chat).

A sample user command file for the standard uhub commands is at
doc/ucmd.conf, and will be automatically installed if appropriate.

This currently won't send commands to existing users (e.g., if the
plugin is (re)loaded after the hub is already up and running). To
support this, a plugin function to list all current users would need to
be added.

I'm not sure how efficient this would be due to the volume of
messages needed to delete the existing commands on shutdown and send
them again on startup. As the commands are reloaded properly within the
plugin, it may be easier to require users to reconnect after the
configuration changes (and, of course, an admin could force this by
restarting the hub).
This commit is contained in:
Blair Bonnett
2012-08-08 19:19:27 +12:00
parent 30ec879cd2
commit 2e7f0f9c12
4 changed files with 673 additions and 1 deletions

View File

@@ -237,6 +237,9 @@ plugin_chat_only_TARGET := mod_chat_only.so
plugin_topic_SOURCES := src/plugins/mod_topic.c
plugin_topic_TARGET := mod_topic.so
plugin_ucmd_SOURCES := src/plugins/mod_ucmd.c
plugin_ucmd_TARGET := mod_ucmd.so
# Source to objects
libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o)
libutils_OBJECTS := $(libutils_SOURCES:.c=.o)
@@ -256,7 +259,8 @@ all_plugins := \
$(plugin_welcome_TARGET) \
$(plugin_chat_history_TARGET) \
$(plugin_chat_only_TARGET) \
$(plugin_topic_TARGET)
$(plugin_topic_TARGET) \
$(plugin_ucmd_TARGET)
all_OBJECTS := \
$(libuhub_OBJECTS) \
@@ -315,6 +319,8 @@ $(plugin_welcome_TARGET): $(plugin_welcome_SOURCES) $(libutils_OBJECTS)
$(plugin_topic_TARGET): $(plugin_topic_SOURCES) $(libutils_OBJECTS)
$(MSG_CC) $(CC) -shared -fPIC -o $@ $^ $(CFLAGS)
$(plugin_ucmd_TARGET): $(plugin_ucmd_SOURCES) $(libutils_OBJECTS)
$(MSG_CC) $(CC) -shared -fPIC -o $@ $^ $(CFLAGS)
$(adcrush_BINARY): $(adcrush_OBJECTS) $(libuhub_OBJECTS) $(libutils_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
@@ -365,6 +371,7 @@ install: all
@if [ ! -f $(UHUB_CONF_DIR)/uhub.conf ]; then cp doc/uhub.conf $(UHUB_CONF_DIR); fi
@if [ ! -f $(UHUB_CONF_DIR)/rules.txt ]; then cp doc/rules.txt $(UHUB_CONF_DIR); fi
@if [ ! -f $(UHUB_CONF_DIR)/plugins.conf ]; then cp doc/plugins.conf $(UHUB_CONF_DIR); fi
@if [ ! -f $(UHUB_CONF_DIR)/ucmd.conf ]; then cp doc/ucmd.conf $(UHUB_CONF_DIR); fi
@if [ ! -d $(UHUB_MOD_DIR) ]; then echo Creating $(UHUB_MOD_DIR); mkdir -p $(UHUB_MOD_DIR); fi
@cp -f mod_*.so $(UHUB_MOD_DIR)
@touch $(UHUB_CONF_DIR)/motd.txt