1 # /AUTOOP <*|#channel> [<nickmasks>]
2 # use friends.pl if you need more features
6 use vars qw($VERSION %IRSSI);
10 authors => 'Timo Sirainen',
12 description => 'Simple auto-op script',
13 license => 'Public Domain',
14 changed => 'Sun Mar 10 23:18 EET 2002'
17 my (%opnicks, %temp_opped);
21 my ($channel, $masks) = split(" ", $data, 2);
25 Irssi::print("Usage: /AUTOOP <*|#channel> [<nickmasks>]");
26 Irssi::print("No-one's being auto-opped currently.");
30 Irssi::print("Currently auto-opping in channels:");
31 foreach $channel (keys %opnicks) {
32 $masks = $opnicks{$channel};
34 if ($channel eq "*") {
35 Irssi::print("All channels: $masks");
37 Irssi::print("$channel: $masks");
45 delete $opnicks{$channel};
47 $opnicks{$channel} = $masks;
49 if ($channel eq "*") {
50 Irssi::print("Now auto-opping in all channels: $masks");
52 Irssi::print("$channel: Now auto-opping: $masks");
57 my ($channel, $masks, @nicks) = @_;
58 my ($server, $nickrec);
60 $server = $channel->{server};
61 foreach $nickrec (@nicks) {
62 my $nick = $nickrec->{nick};
63 my $host = $nickrec->{host};
65 if (!$temp_opped{$nick} &&
66 $server->masks_match($masks, $nick, $host)) {
67 $channel->command("op $nick");
68 $temp_opped{$nick} = 1;
74 my ($channel, $nicks_list) = @_;
75 my @nicks = @{$nicks_list};
77 return if (!$channel->{chanop});
82 my $masks = $opnicks{$channel->{name}};
83 autoop($channel, $masks, @nicks) if ($masks);
86 $masks = $opnicks{"*"};
87 autoop($channel, $masks, @nicks) if ($masks);
90 Irssi::command_bind('autoop', 'cmd_autoop');
91 Irssi::signal_add_last('massjoin', 'event_massjoin');