diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c index 5ba7030b..1752f9b9 100644 --- a/plugins/fishlim/plugin_hexchat.c +++ b/plugins/fishlim/plugin_hexchat.c @@ -44,7 +44,7 @@ static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less static const char plugin_version[] = "0.1.0"; static const char usage_setkey[] = "Usage: SETKEY [] [:], sets the key for a channel or nick. Modes: ECB, CBC"; -static const char usage_delkey[] = "Usage: DELKEY , deletes the key for a channel or nick"; +static const char usage_delkey[] = "Usage: DELKEY [], deletes the key for a channel or nick"; static const char usage_keyx[] = "Usage: KEYX [], performs DH1080 key-exchange with "; static const char usage_topic[] = "Usage: TOPIC+ , sets a new encrypted topic for the current channel"; static const char usage_notice[] = "Usage: NOTICE+ "; @@ -377,15 +377,22 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) { */ static int handle_delkey(char *word[], char *word_eol[], void *userdata) { const char *nick; + int ctx_type = 0; - /* Check syntax */ - if (*word[2] == '\0' || *word[3] != '\0') { - hexchat_printf(ph, "%s\n", usage_delkey); - return HEXCHAT_EAT_HEXCHAT; + /* Delete key from input */ + if (*word[2] != '\0') { + nick = g_strstrip(word_eol[2]); + } else { /* Delete key from current context */ + nick = hexchat_get_info(ph, "channel"); + ctx_type = hexchat_list_int(ph, NULL, "type"); + + /* Only allow channel or dialog */ + if (ctx_type < 2 || ctx_type > 3) { + hexchat_printf(ph, "%s\n", usage_delkey); + return HEXCHAT_EAT_HEXCHAT; + } } - nick = g_strstrip (word_eol[2]); - /* Delete the given nick from the key store */ if (keystore_delete_nick(nick)) { hexchat_printf(ph, "Deleted key for %s\n", nick);