hook reload command

This commit is contained in:
TingPing 2013-04-13 02:02:57 -03:00
parent 541f221a61
commit 9917b7e3df

View File

@ -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