From 9917b7e3dff8435025b90cf77fc9064c3bc0aa1d Mon Sep 17 00:00:00 2001 From: TingPing Date: Sat, 13 Apr 2013 02:02:57 -0300 Subject: hook reload command --- plugins/python/python.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugins') 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 \n\ ABOUT\n\ \n"; +/* Remove if/when HexChat supports this command for plugins */ +static const char reload[] = "Usage: RELOAD , 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 -- cgit 1.4.1