mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
added "use strict" for all scripts, made some small changes.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1639 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
0d3b5c729f
commit
69a6096b8b
@ -1,8 +1,9 @@
|
|||||||
# /AUTOOP <*|#channel> [<nickmasks>]
|
# /AUTOOP <*|#channel> [<nickmasks>]
|
||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
|
use strict;
|
||||||
|
|
||||||
my %opnicks, %temp_opped;
|
my (%opnicks, %temp_opped);
|
||||||
|
|
||||||
sub cmd_autoop {
|
sub cmd_autoop {
|
||||||
my ($data) = @_;
|
my ($data) = @_;
|
||||||
@ -12,7 +13,7 @@ sub cmd_autoop {
|
|||||||
if (!%opnicks) {
|
if (!%opnicks) {
|
||||||
Irssi::print("Usage: /AUTOOP <*|#channel> [<nickmasks>]");
|
Irssi::print("Usage: /AUTOOP <*|#channel> [<nickmasks>]");
|
||||||
Irssi::print("No-one's being auto-opped currently.");
|
Irssi::print("No-one's being auto-opped currently.");
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irssi::print("Currently auto-opping in channels:");
|
Irssi::print("Currently auto-opping in channels:");
|
||||||
@ -25,7 +26,7 @@ sub cmd_autoop {
|
|||||||
Irssi::print("$channel: $masks");
|
Irssi::print("$channel: $masks");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($masks eq "") {
|
if ($masks eq "") {
|
||||||
@ -39,17 +40,16 @@ sub cmd_autoop {
|
|||||||
} else {
|
} else {
|
||||||
Irssi::print("$channel: Now auto-opping: $masks");
|
Irssi::print("$channel: Now auto-opping: $masks");
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub autoop {
|
sub autoop {
|
||||||
my ($channel, $masks, @nicks) = @_;
|
my ($channel, $masks, @nicks) = @_;
|
||||||
my $server, $nickrec;
|
my ($server, $nickrec);
|
||||||
|
|
||||||
$server = $channel->{server};
|
$server = $channel->{server};
|
||||||
foreach $nickrec (@nicks) {
|
foreach $nickrec (@nicks) {
|
||||||
$nick = $nickrec->{nick};
|
my $nick = $nickrec->{nick};
|
||||||
$host = $nickrec->{host};
|
my $host = $nickrec->{host};
|
||||||
|
|
||||||
if (!$temp_opped{$nick} &&
|
if (!$temp_opped{$nick} &&
|
||||||
$server->masks_match($masks, $nick, $host)) {
|
$server->masks_match($masks, $nick, $host)) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
use Irssi::Irc;
|
use Irssi::Irc;
|
||||||
|
use strict;
|
||||||
|
|
||||||
sub event_rejoin_kick {
|
sub event_rejoin_kick {
|
||||||
my ($server, $data) = @_;
|
my ($server, $data) = @_;
|
||||||
@ -14,8 +15,8 @@ sub event_rejoin_kick {
|
|||||||
return if ($server->{nick} ne $nick);
|
return if ($server->{nick} ne $nick);
|
||||||
|
|
||||||
# check if channel has password
|
# check if channel has password
|
||||||
$chanrec = $server->channel_find($channel);
|
my $chanrec = $server->channel_find($channel);
|
||||||
$password = $chanrec->{key} if ($chanrec);
|
my $password = $chanrec->{key} if ($chanrec);
|
||||||
|
|
||||||
# We have to use send_raw() because the channel record still
|
# We have to use send_raw() because the channel record still
|
||||||
# exists and irssi won't even try to join to it with command()
|
# exists and irssi won't even try to join to it with command()
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
# /CLONES - display real name of nick
|
# /CLONES - display real name of nick
|
||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
|
use strict;
|
||||||
|
|
||||||
sub cmd_clones {
|
sub cmd_clones {
|
||||||
my ($data, $server, $channel) = @_;
|
my ($data, $server, $channel) = @_;
|
||||||
my %hostnames, $host, @nicks, $nick;
|
my (%hostnames, $host, @nicks, $nick);
|
||||||
|
|
||||||
@nicks = $channel->nicks();
|
@nicks = $channel->nicks();
|
||||||
|
|
||||||
@ -19,7 +20,6 @@ sub cmd_clones {
|
|||||||
$channel->print("$host: $clones");
|
$channel->print("$host: $clones");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Irssi::command_bind('clones', 'cmd_clones');
|
Irssi::command_bind('clones', 'cmd_clones');
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# "Hello, world!" script :) /hello <nick> sends "Hello, world!" to <nick>
|
# "Hello, world!" script :) /hello <nick> sends "Hello, world!" to <nick>
|
||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
|
use strict;
|
||||||
|
|
||||||
sub cmd_hello {
|
sub cmd_hello {
|
||||||
my ($data, $server, $channel) = @_;
|
my ($data, $server, $channel) = @_;
|
||||||
|
|
||||||
$server->command("/msg $data Hello, world!");
|
$server->command("/msg $data Hello, world!");
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Irssi::command_bind('hello', 'cmd_hello');
|
Irssi::command_bind('hello', 'cmd_hello');
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
use Irssi::Irc;
|
use Irssi::Irc;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my %keep_channels;
|
||||||
|
|
||||||
sub cmd_mlock {
|
sub cmd_mlock {
|
||||||
my ($data, $server) = @_;
|
my ($data, $server) = @_;
|
||||||
@ -14,25 +17,26 @@ sub cmd_mlock {
|
|||||||
|
|
||||||
$keep_channels{$channel} = $mode;
|
$keep_channels{$channel} = $mode;
|
||||||
mlock_check_mode($server, $channel);
|
mlock_check_mode($server, $channel);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub mlock_check_mode {
|
sub mlock_check_mode {
|
||||||
my ($server, $channame) = @_;
|
my ($server, $channame) = @_;
|
||||||
|
|
||||||
$channel = $server->channel_find($channame);
|
my $channel = $server->channel_find($channame);
|
||||||
return if (!channel || !$channel->{chanop});
|
return if (!$channel || !$channel->{chanop});
|
||||||
|
|
||||||
$keep_mode = $keep_channels{$channame};
|
my $keep_mode = $keep_channels{$channame};
|
||||||
return if (!$keep_mode);
|
return if (!$keep_mode);
|
||||||
|
|
||||||
# old channel mode
|
# old channel mode
|
||||||
|
my ($oldmode, $oldkey, $oldlimit);
|
||||||
$oldmode = $channel->{mode};
|
$oldmode = $channel->{mode};
|
||||||
$oldmode =~ s/^([^ ]*).*/\1/;
|
$oldmode =~ s/^([^ ]*).*/\1/;
|
||||||
$oldkey = $channel->{key};
|
$oldkey = $channel->{key};
|
||||||
$oldlimit = $channel->{limit};
|
$oldlimit = $channel->{limit};
|
||||||
|
|
||||||
# get the new channel key/limit
|
# get the new channel key/limit
|
||||||
|
my (@newmodes, $newkey, $limit);
|
||||||
@newmodes = split(/ /, $keep_mode); $keep_mode = $newmodes[0];
|
@newmodes = split(/ /, $keep_mode); $keep_mode = $newmodes[0];
|
||||||
if ($keep_mode =~ /k/) {
|
if ($keep_mode =~ /k/) {
|
||||||
if ($keep_mode =~ /k.*l/) {
|
if ($keep_mode =~ /k.*l/) {
|
||||||
@ -49,15 +53,15 @@ sub mlock_check_mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# check the differences
|
# check the differences
|
||||||
undef %allmodes;
|
my %allmodes;
|
||||||
$keep_mode =~ s/^\+//;
|
$keep_mode =~ s/^\+//;
|
||||||
for ($n = 0; $n < length($keep_mode); $n++) {
|
for (my $n = 0; $n < length($keep_mode); $n++) {
|
||||||
$modechar = substr($keep_mode, $n, 1);
|
my $modechar = substr($keep_mode, $n, 1);
|
||||||
$allmodes{$modechar} = '+';
|
$allmodes{$modechar} = '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($n = 0; $n < length($oldmode); $n++) {
|
for (my $n = 0; $n < length($oldmode); $n++) {
|
||||||
$modechar = substr($oldmode, $n, 1);
|
my $modechar = substr($oldmode, $n, 1);
|
||||||
|
|
||||||
if ($allmodes{$modechar} eq '+') {
|
if ($allmodes{$modechar} eq '+') {
|
||||||
next if (($modechar eq "k" && $newkey ne $oldkey) ||
|
next if (($modechar eq "k" && $newkey ne $oldkey) ||
|
||||||
@ -69,8 +73,8 @@ sub mlock_check_mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# create the mode change string
|
# create the mode change string
|
||||||
$modecmd = ""; $extracmd = "";
|
my ($modecmd, $extracmd);
|
||||||
foreach $mode (keys %allmodes) {
|
foreach my $mode (keys %allmodes) {
|
||||||
Irssi::print("key = '$mode':".$allmodes{$mode});
|
Irssi::print("key = '$mode':".$allmodes{$mode});
|
||||||
if ($mode eq "k") {
|
if ($mode eq "k") {
|
||||||
if ($allmodes{$mode} eq '+') {
|
if ($allmodes{$mode} eq '+') {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# listen PRIVMSGs - send a notice to yourself when your nick is meantioned
|
# listen PRIVMSGs - send a notice to yourself when your nick is meantioned
|
||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
|
use strict;
|
||||||
|
|
||||||
sub event_privmsg {
|
sub event_privmsg {
|
||||||
my ($server, $data, $nick, $address) = @_;
|
my ($server, $data, $nick, $address) = @_;
|
||||||
@ -8,7 +9,7 @@ sub event_privmsg {
|
|||||||
|
|
||||||
return if (!$server->ischannel($target));
|
return if (!$server->ischannel($target));
|
||||||
|
|
||||||
$mynick = $server->{nick};
|
my $mynick = $server->{nick};
|
||||||
return if ($text !~ /\b$mynick\b/);
|
return if ($text !~ /\b$mynick\b/);
|
||||||
|
|
||||||
$server->command("/notice $mynick In channel $target, $nick!$address said: $text");
|
$server->command("/notice $mynick In channel $target, $nick!$address said: $text");
|
||||||
|
@ -2,17 +2,19 @@
|
|||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
use Irssi::Irc;
|
use Irssi::Irc;
|
||||||
|
use strict;
|
||||||
|
|
||||||
$quitfile = "$ENV{HOME}/.irssi/irssi.quit";
|
my $quitfile = glob "~/.irssi/irssi.quit";
|
||||||
|
|
||||||
sub cmd_quit {
|
sub cmd_quit {
|
||||||
my ($data, $server, $channel) = @_;
|
my ($data, $server, $channel) = @_;
|
||||||
|
|
||||||
open (f, $quitfile) || return;
|
open (f, $quitfile) || return;
|
||||||
$lines = 0; while(<f>) { $lines++; };
|
my $lines = 0; while(<f>) { $lines++; };
|
||||||
|
|
||||||
$line = int(rand($lines))+1;
|
my $line = int(rand($lines))+1;
|
||||||
|
|
||||||
|
my $quitmsg;
|
||||||
seek(f, 0, 0); $. = 0;
|
seek(f, 0, 0); $. = 0;
|
||||||
while(<f>) {
|
while(<f>) {
|
||||||
next if ($. != $line);
|
next if ($. != $line);
|
||||||
@ -23,8 +25,7 @@ sub cmd_quit {
|
|||||||
}
|
}
|
||||||
close(f);
|
close(f);
|
||||||
|
|
||||||
@servers = Irssi::servers;
|
foreach my $server (Irssi::servers) {
|
||||||
foreach $server (@servers) {
|
|
||||||
$server->command("/disconnect ".$server->{tag}." $quitmsg");
|
$server->command("/disconnect ".$server->{tag}." $quitmsg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
use Irssi::Irc;
|
use Irssi::Irc;
|
||||||
|
use strict;
|
||||||
|
|
||||||
sub cmd_realname {
|
sub cmd_realname {
|
||||||
my ($data, $server, $channel) = @_;
|
my ($data, $server, $channel) = @_;
|
||||||
@ -20,7 +21,6 @@ sub cmd_realname {
|
|||||||
"event 313", "event empty", 1,
|
"event 313", "event empty", 1,
|
||||||
"event 317", "event empty", 1,
|
"event 317", "event empty", 1,
|
||||||
"event 319", "event empty", 1);
|
"event 319", "event empty", 1);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub event_rn_whois {
|
sub event_rn_whois {
|
||||||
@ -28,7 +28,6 @@ sub event_rn_whois {
|
|||||||
$realname =~ s/^://;
|
$realname =~ s/^://;
|
||||||
|
|
||||||
Irssi::print("%_$nick%_ is $realname");
|
Irssi::print("%_$nick%_ is $realname");
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Irssi::command_bind('rn', 'cmd_realname');
|
Irssi::command_bind('rn', 'cmd_realname');
|
||||||
|
Loading…
Reference in New Issue
Block a user