-
Notifications
You must be signed in to change notification settings - Fork 235
/
ls.pl
51 lines (40 loc) · 1.02 KB
/
ls.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20020120;
$VERSION = "0.03";
%IRSSI = (
authors => "c0ffee",
contact => "c0ffee\@penguin-breeder.org",
name => "List nicks in channel",
description => "Use /ls <regex> to show all nicks (including ident\@host) matching regex in the current channel",
license => "Public Domain",
url => "http://www.penguin-breeder.org/irssi/",
changed => "Sun Sep 17 06:31 CEST 2017",
);
sub cmd_ls {
my ($data, $server, $channel) = @_;
if ($channel->{type} ne "CHANNEL") {
Irssi::print("You are not on a channel");
return;
}
$channel->print("--- Search results:");
my @nicks = $channel->nicks();
my $re = eval { qr/$data/i };
if (not $re) {
chomp $@;
$channel->print("Invalid regex pattern:\n$@");
return;
}
my $found;
foreach my $nick (@nicks) {
my $n = $nick->{nick} . "!" . $nick->{host};
if ($n =~ $re) {
$channel->print($n);
$found = 1;
}
}
if (not $found) {
$channel->print("No matches");
}
}
Irssi::command_bind('ls','cmd_ls');