summary refs log tree commit diff stats
path: root/plugins/python/python.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/python/python.c')
-rw-r--r--plugins/python/python.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 1be2c7bb..7c2e5a95 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -327,6 +327,9 @@ Usage: /PY LOAD   <filename>\n\
            ABOUT\n\
 \n";
 
+/* Remove if/when HexChat supports this command for plugins */
+static const char reload[] = "Usage: RELOAD <name>, reloads a python script";
+
 static const char about[] = "\
 \n\
 X-Chat Python Interface " VERSION "\n\
@@ -2232,6 +2235,17 @@ Command_Unload(char *word[], char *word_eol[], void *userdata)
 	return HEXCHAT_EAT_NONE;
 }
 
+static int
+Command_Reload(char *word[], char *word_eol[], void *userdata)
+{
+	int len = strlen(word[2]);
+	if (len > 3 && strcasecmp(".py", word[2]+len-3) == 0) {
+		Command_PyReload(word[2]);
+		return HEXCHAT_EAT_HEXCHAT;
+	}
+	return HEXCHAT_EAT_NONE;
+}
+
 /* ===================================================================== */
 /* Autoload function */
 
@@ -2320,6 +2334,7 @@ hexchat_plugin_init(hexchat_plugin *plugin_handle,
 	hexchat_hook_command(ph, "PY", HEXCHAT_PRI_NORM, Command_Py, usage, 0);
 	hexchat_hook_command(ph, "LOAD", HEXCHAT_PRI_NORM, Command_Load, 0, 0);
 	hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, Command_Unload, 0, 0);
+	hexchat_hook_command(ph, "RELOAD", HEXCHAT_PRI_NORM, Command_Reload, reload, 0);
 #ifdef WITH_THREAD
 	thread_timer = hexchat_hook_timer(ph, 300, Callback_ThreadTimer, NULL);
 #endif