diff options
author | TingPing <tngpng@gmail.com> | 2013-04-13 02:02:57 -0300 |
---|---|---|
committer | TingPing <tngpng@gmail.com> | 2013-04-13 02:02:57 -0300 |
commit | 9917b7e3dff8435025b90cf77fc9064c3bc0aa1d (patch) | |
tree | 3eb934d1561cd9383558c5b14c4e2f1ce048738a /plugins/python | |
parent | 541f221a6121fe5d1ff1e103ca2fdedda33cf0af (diff) |
hook reload command
Diffstat (limited to 'plugins/python')
-rw-r--r-- | plugins/python/python.c | 15 |
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 |