html/fuckem.pl
1 #!/usr/bin/perl -w
2
3 ## Bugreports and Licence disclaimer.
4 #
5 # For bugreports and other improvements contact Geert Hauwaerts <geert@irssi.org>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this script; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #
21 ##
22
23 use strict;
24 use Irssi;
25 use vars qw($VERSION %IRSSI);
26
27 $VERSION = "0.05";
28
29 %IRSSI = (
30 authors => 'Geert Hauwaerts',
31 contact => 'geert@irssi.org',
32 name => 'fuckem.pl',
33 description => 'Simulates the BitchX /FUCKEM command. Deop/Dehalfop everyone on the channel including you.',
34 license => 'GNU General Public License',
35 url => 'http://irssi.hauwaerts.be/fuckem.pl',
36 changed => 'Wed Sep 17 23:00:11 CEST 2003',
37 );
38
39 Irssi::theme_register([
40 'fuckem_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.'
41 ]);
42
43 sub fuckem {
44
45 my ($data, $server, $channel) = @_;
46 my ($hops, $ops, $hcount, $ocount, $mode, $users);
47
48 if (!$server) {
49 $channel->print("You are not connected to a server.");
50 return;
51 } elsif (!$channel || $channel->{type} ne "CHANNEL") {
52 $channel->print("No active channel in this window.");
53 return;
54 } elsif (!$channel->{ownnick}{op}) {
55 $channel->print("You're no channel operator.");
56 return;
57 }
58
59 foreach my $nick ($channel->nicks()) {
60 if ($nick->{halfop}) {
61 $hops .= "$nick->{nick} ";
62 $hcount++;
63 } elsif ($nick->{op}) {
64 $ops .= "$nick->{nick} ";
65 $ocount++;
66 }
67 }
68
69 if ($ops) {
70 $mode .= 'o' x $ocount;
71 $users .= "$ops ";
72 }
73
74 if ($hops) {
75 $mode .= 'h' x $hcount;
76 $users .= "$hops ";
77 }
78
79 $mode .= 'o';
80 $users .= "$server->{nick}";
81
82 $channel->command("mode -$mode $users");
83 }
84
85 Irssi::command_bind('fuckem', 'fuckem');
86 Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'fuckem_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors});