irssi: add more scripts
This commit is contained in:
parent
0a956eca18
commit
16856bbece
|
@ -69,6 +69,7 @@ aliases = {
|
|||
dh = "UMODE -h";
|
||||
h = "UMODE +h";
|
||||
fuck = "server purge";
|
||||
isquiet = "ismuted";
|
||||
};
|
||||
|
||||
settings = {
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
use Irssi 20010920.0000 ();
|
||||
$VERSION = "2.01";
|
||||
%IRSSI = (
|
||||
authors => 'From irssi source, modified by David Leadbeater (dg)',
|
||||
name => 'clones',
|
||||
description => '/CLONES - Display clones in the active channel (with added options)',
|
||||
license => 'Same as Irssi',
|
||||
url => 'http://irssi.dgl.yi.org/',
|
||||
);
|
||||
|
||||
use strict;
|
||||
|
||||
sub cmd_clones {
|
||||
my ($data, $server, $channel) = @_;
|
||||
|
||||
my $min = $data =~ /\d/ ? $data : Irssi::settings_get_int('clones_min_show');
|
||||
|
||||
if (!$channel || $channel->{type} ne 'CHANNEL') {
|
||||
Irssi::print('No active channel in window');
|
||||
return;
|
||||
}
|
||||
|
||||
my %hostnames = {};
|
||||
my $ident = Irssi::settings_get_bool('clones_host_only');
|
||||
|
||||
foreach my $nick ($channel->nicks()) {
|
||||
my $hostname;
|
||||
if($ident) {
|
||||
($hostname = $nick->{host}) =~ s/^[^@]+@//;
|
||||
}else{
|
||||
$hostname = $nick->{host};
|
||||
}
|
||||
|
||||
$hostnames{$hostname} ||= [];
|
||||
push( @{ $hostnames{$hostname} }, $nick->{nick});
|
||||
}
|
||||
|
||||
my $count = 0;
|
||||
foreach my $host (keys %hostnames) {
|
||||
next unless ref($hostnames{$host}) eq 'ARRAY'; # sometimes a hash is here
|
||||
my @clones = @{ $hostnames{$host} };
|
||||
if (scalar @clones >= $min) {
|
||||
$channel->print('Clones:') if ($count == 0);
|
||||
$channel->print("$host: " . join(' ',@clones));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$channel->print('No clones in channel') if ($count == 0);
|
||||
}
|
||||
|
||||
Irssi::command_bind('clones', 'cmd_clones');
|
||||
Irssi::settings_add_bool('misc', 'clones_host_only', 1);
|
||||
Irssi::settings_add_int('misc', 'clones_min_show', 2);
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
use Irssi;
|
||||
use strict;
|
||||
use vars qw($VERSION %IRSSI);
|
||||
$VERSION = "1.0";
|
||||
%IRSSI = (
|
||||
authors => "David Leadbeater",
|
||||
contact => "dgl\@dgl.cx",
|
||||
url => "http://irssi.dgl.cx/",
|
||||
license => "GNU GPLv2 or later",
|
||||
name => "foreach user",
|
||||
description => "Extends the /foreach command to have /foreach user
|
||||
(users in a channel).
|
||||
Syntax: /foreach user [hostmask] command.",
|
||||
);
|
||||
|
||||
# Examples:
|
||||
# /foreach user /whois $0
|
||||
# /foreach user *!eviluser@* /k $0 evil! (consider kicks.pl ;) )
|
||||
|
||||
Irssi::command_bind('foreach user', sub {
|
||||
my($command) = @_;
|
||||
return unless length $command;
|
||||
|
||||
my $mask = '*!*@*';
|
||||
# see if it begins with a mask (kind of assumes cmdchars is /).
|
||||
if($command !~ m!^/! && $command =~ /^\S+[!@]/) {
|
||||
($mask,$command) = split / /, $command, 2;
|
||||
# make sure the mask is okay.
|
||||
$mask .= '@*' if $mask !~ /\@/;
|
||||
$mask = "*!$mask" if $mask !~ /!/;
|
||||
}
|
||||
|
||||
my $channel = ref Irssi::active_win ? Irssi::active_win->{active} : '';
|
||||
return unless ref $channel;
|
||||
|
||||
for my $nick($channel->nicks) {
|
||||
next unless ref $nick;
|
||||
next unless $channel->{server}->mask_match_address($mask, $nick->{nick},
|
||||
$nick->{host} ? $nick->{host} : '');
|
||||
|
||||
# the backtracking is only so $$0 is escaped (don't ask me why...)
|
||||
(my $tmpcommand = $command) =~ s/(?<!\$)\$(\d)/
|
||||
if($1 == 0) {
|
||||
$nick->{nick}
|
||||
}elsif($1 == 1) {
|
||||
$nick->{host}
|
||||
}elsif($1 == 2) {
|
||||
(split('@',$nick->{host}))[0];
|
||||
}elsif($1 == 3) {
|
||||
(split('@',$nick->{host}))[1];
|
||||
}elsif($1 == 4) {
|
||||
$nick->{realname}
|
||||
}
|
||||
/eg;
|
||||
$tmpcommand =~ s/\$\$(\d)/\$$1/g;
|
||||
$channel->command($tmpcommand);
|
||||
}
|
||||
} );
|
||||
|
Loading…
Reference in New Issue