-$ph = new Xchat::XPI name => 'Misc tools',
- tag => 'Tools',
- desc => 'Perl interpretor, URI escaper',
- author => 'Vincent Pit (VPIT)',
- email => 'perl@profvince.com',
- url => 'http://www.profvince.com';
+hook_command 'HGREP', sub {
+ my $txt = $_[1][1];
+ return EAT_ALL unless defined $txt;
+ $txt = qr/$txt/i;
+ my @matches;
+ for (get_list 'users') {
+ my $host = strip_code $_->{host};
+ next unless $host =~ /$txt/;
+ push @matches, [ $_->{nick}, $host ];
+ }
+ my $nbr = @matches;
+ print $ph ($nbr == 0 ? 'No' : $nbr)
+ . ' match' . ('es' x ($nbr > 1))
+ . ' to ' . $txt;
+ if (@matches < MAX_MATCHES) {
+ print $ph +(':' x ($nbr > 0)) . "\n";
+ print $ph "\002$_->[0]\002 ($_->[1])\n" for @matches;
+ } else {
+ print $ph " (too many of them, omitted)\n";
+ }
+ return EAT_ALL;
+}, {
+ help_text => 'HGREP <text>, print users in the current context whose hostname matches text'
+};
+
+$ph = Xchat::XPI->new(
+ name => 'Misc tools',
+ tag => 'Tools',
+ desc => 'Perl interpretor, URI escaper',
+ author => 'Vincent Pit (VPIT)',
+ email => 'perl@profvince.com',
+ url => 'http://www.profvince.com',
+);