All pastes #16800 Raw Edit

Close Queries v0.1

public text v1 · immutable
#16800 ·published 2005-07-03 18:42 UTC
rendered paste body
#!/usr/bin/perl

package Xchat::Script::CloseQueries;

use warnings;
use strict;

use constant COMMAND => 'clq';
use constant {
	NAME 		=> 'Close Queries',
	VERSION		=> '0.1',
	DESCRIPTION	=> 'Closes all query windows on /' . COMMAND
};

Xchat::register(NAME, VERSION, DESCRIPTION);
Xchat::hook_command('clq', \&close_queries);

sub close_queries {
	my @channels = Xchat::get_list('channels');
	my $context = Xchat::get_context();
	my $closed = 0;
	foreach my $channel (@channels) {
		if ($channel->{'type'} == 3) {
			Xchat::set_context($channel->{'context'});
			Xchat::command('close');
			$closed++;
		}
	}
	Xchat::set_context($context);
	Xchat::print('Queries closed: ' . $closed);
}