-
Notifications
You must be signed in to change notification settings - Fork 235
/
autocycle.pl
47 lines (41 loc) · 1.45 KB
/
autocycle.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
# Usage: /SET auto_regain_ops [On/Off]
# /autocycle
use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20020313 qw( settings_add_bool settings_get_bool servers command_bind timeout_add );
$VERSION = "0.4";
%IRSSI = (
authors => "Marcin Rozycki",
contact => "derwan\@irssi.pl",
name => "autocycle",
description => "Auto regain ops in empty opless channels",
url => "http://derwan.irssi.pl",
license => "GNU GPL v2",
changed => "Fri Jan 3 23:20:06 CET 2003"
);
sub check_channels {
foreach my $server (servers) {
if ($server->{usermode} !~ m/r/ and my @channels = $server->channels) {
CHANNEL: while (my $channel = shift @channels) {
my $modes = $channel->{mode};
my $test = ($modes and $modes =~ m/a/) ? 1 : 0;
if (!$test && $channel->{synced} && $channel->{name} !~ m/^[\+\!]/ && !$channel->{ownnick}->{op}) {
foreach my $nick ($channel->nicks) {
($nick->{nick} eq $server->{nick}) or goto CHANNEL;
}
$channel->print("Auto regain op in empty channel " . $channel->{name});
$channel->command("cycle");
}
}
}
}
}
sub autocycle {
if (settings_get_bool("auto_regain_ops")) {
check_channels();
}
}
settings_add_bool "misc", "auto_regain_ops", 1;
command_bind "autocycle", "check_channels";
timeout_add 60000, \&autocycle, undef;
autocycle;