archive

- Random tools & helpful resources for IRC
git clone git://git.acid.vegas/archive.git
Log | Files | Refs | Archive

takeover.pl (2186B)

      1 # Takeover (IRSSI Channel Takeover Script)
      2 # Developed by acidvegas in Perl
      3 # http://github.com/acidvegas/irssi
      4 # takeover.pl
      5 
      6 # Todo:
      7 # Detect max network modes.
      8 # Kickban comma separated nicks.
      9 
     10 use strict;
     11 use Irssi;
     12 use Irssi::Irc;
     13 
     14 sub takeover {
     15     my ($data, $server, $channel) = @_;
     16     Irssi::printformat(MSGLEVEL_CLIENTCRAP, "takeover_crap", "Not connected to server."),        return if (!$server or !$server->{connected});
     17     Irssi::printformat(MSGLEVEL_CLIENTCRAP, "takeover_crap", "No active channel in window."),    return if (!$channel or ($channel->{type} ne "CHANNEL"));
     18     my $own_prefixes = $channel->{ownnick}{prefixes};
     19     Irssi::printformat(MSGLEVEL_CLIENTCRAP, "takeover_crap", "You are not a channel operator."), return if ($own_prefixes =~ /~|&|@|%/);
     20     my ($qops, $aops, $hops, $qcount, $acount, $hcount, $modes);
     21     my $hostname      = $channel->{ownnick}{host};
     22     my $nicklist      = $channel->nicks();
     23     foreach my $nick ($channel->nicks()) {
     24         next if ($nick eq $server->{nick});
     25         if ($nick->{prefixes} =~ /~/) {
     26             $qops .= "$nick->{nick} ";
     27             $qcount++;
     28         }
     29         if ($nick->{prefixes} =~ /&/) {
     30             $aops .= "$nick->{nick} ";
     31             $acount++;
     32         }
     33         if ($nick->{halfop}) {
     34             $hops .= "$nick->{nick} ";
     35             $hcount++;
     36         }
     37     }
     38     if ($qops) {
     39         $modes = "q" x $qcount;
     40         $channel->command("mode -$modes $qops");
     41     }
     42     if ($aops) {
     43         $modes = "a" x $qcount;
     44         $channel->command("mode -$modes $aops");
     45     }
     46     if ($hops) {
     47         $modes = "h" x $qcount;
     48         $channel->command("mode -$modes $hops");
     49     }
     50     $channel->command("deop -YES *");
     51     $channel->command("devoice -YES *");
     52     foreach ($channel->nicks()) {
     53         next if ($_->{'nick'} eq $server->{nick});
     54         $channel->command("kickban $_->{'nick'}");
     55     }
     56     $channel->command("ban *!*@*");
     57     $channel->command("mode +im");
     58     $channel->command("mode +e *!$hostname");
     59     $channel->command("mode +I *!$hostname");
     60 }
     61 
     62 Irssi::theme_register(['takeover_crap', '{line_start}{hilight takeover:} $0',]);
     63 Irssi::command_bind('takeover', 'takeover');