diff options
Diffstat (limited to 'root_commands.c')
| -rw-r--r-- | root_commands.c | 72 | 
1 files changed, 58 insertions, 14 deletions
| diff --git a/root_commands.c b/root_commands.c index b1ca8296..edc17855 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1207,36 +1207,80 @@ static void prplstr(GList *prpls, GString *gstr)  	g_list_free(prpls);  } +static void cmd_plugins_info(irc_t *irc, char **cmd) +{ +	GList *l; +	struct plugin_info *info; + +	MIN_ARGS(2); + +	for (l = get_plugins(); l; l = l->next) { +		info = l->data; +		if (g_strcasecmp(cmd[2], info->name) == 0) { +			break; +		} +	} + +	if (!l) { +		return; +	} + +	irc_rootmsg(irc, "%s:", info->name); +	irc_rootmsg(irc, "  Version: %s", info->version); + +	if (info->description) { +		irc_rootmsg(irc, "  Description: %s", info->description); +	} + +	if (info->author) { +		irc_rootmsg(irc, "  Author: %s", info->author); +	} + +	if (info->url) { +		irc_rootmsg(irc, "  URL: %s", info->url); +	} +} +  static void cmd_plugins(irc_t *irc, char **cmd)  {  	GList *prpls;  	GString *gstr; +	if (cmd[1] && g_strcasecmp(cmd[1], "info") == 0) { +		cmd_plugins_info(irc, cmd); +		return; +	} +  #ifdef WITH_PLUGINS  	GList *l;  	struct plugin_info *info; +	char *format; -	for (l = get_plugins(); l; l = l->next) { -		info = l->data; -		irc_rootmsg(irc, "%s:", info->name); -		irc_rootmsg(irc, "  Version: %s", info->version); +	if (strchr(irc->umode, 'b') != NULL) { +		format = "%s\t%s"; +	} else { +		format = "%-30s  %s"; +	} -		if (info->description) { -			irc_rootmsg(irc, "  Description: %s", info->description); -		} +	irc_rootmsg(irc, format, "Plugin", "Version"); -		if (info->author) { -			irc_rootmsg(irc, "  Author: %s", info->author); -		} +	for (l = get_plugins(); l; l = l->next) { +		char *c; +		info = l->data; -		if (info->url) { -			irc_rootmsg(irc, "  URL: %s", info->url); +		/* some purple plugins like to include several versions separated by newlines... */ +		if ((c = strchr(info->version, '\n'))) { +			char *version = g_strndup(info->version, c - info->version); +			irc_rootmsg(irc, format, info->name, version); +			g_free(version); +		} else { +			irc_rootmsg(irc, format, info->name, info->version);  		} - -		irc_rootmsg(irc, "");  	}  #endif +	irc_rootmsg(irc, ""); +  	gstr = g_string_new(NULL);  	prpls = get_protocols(); | 
