
use strict;
use warnings;
use Xchat qw(:all);
use Data::Dumper;

hook_command( "get_list", \&cmd_get_list );
sub cmd_get_list {
	my $list = $_[0][1];

	return
		unless $list
			and grep { $list eq $_ }
			qw(channels dcc ignore notify users networks);

	my $filter = $_[0][2];
	my ($key, $value);
	if( $filter ) {
		($key, $value) = split /=/, $filter;
		undef $filter unless $key && $value;
	}
	
	local $Data::Dumper::Terse = 1;
	local $Data::Dumper::Sortkeys = 1;
	for my $item ( get_list $list ) {
		if( $filter ) {
			next unless $item->{$key} eq $value;
		}
		prnt '-' x 100;
		for my $key ( sort keys %{ $item } ) {
			prnt "$key\t"
				. Dumper( $item->{$key} );

			if( $key eq 'autojoins' ) {
				prnt "$item->{$key}";
				prnt Dumper( [@{$item->{$key}->as_array}] );
				prnt Dumper( {%{$item->{$key}->as_hash}} );
			}
		}
		prnt "\n";
	}

	return EAT_ALL;
}

