#!/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); }