1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-30 06:45:25 +00: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:
Timo Sirainen 2001-07-16 20:22:45 +00:00 committed by cras
parent 0d3b5c729f
commit 69a6096b8b
8 changed files with 37 additions and 31 deletions

View File

@ -1,8 +1,9 @@
# /AUTOOP <*|#channel> [<nickmasks>]
use Irssi;
use strict;
my %opnicks, %temp_opped;
my (%opnicks, %temp_opped);
sub cmd_autoop {
my ($data) = @_;
@ -12,7 +13,7 @@ sub cmd_autoop {
if (!%opnicks) {
Irssi::print("Usage: /AUTOOP <*|#channel> [<nickmasks>]");
Irssi::print("No-one's being auto-opped currently.");
return 1;
return;
}
Irssi::print("Currently auto-opping in channels:");
@ -25,7 +26,7 @@ sub cmd_autoop {
Irssi::print("$channel: $masks");
}
}
return 1;
return;
}
if ($masks eq "") {
@ -39,17 +40,16 @@ sub cmd_autoop {
} else {
Irssi::print("$channel: Now auto-opping: $masks");
}
return 1;
}
sub autoop {
my ($channel, $masks, @nicks) = @_;
my $server, $nickrec;
my ($server, $nickrec);
$server = $channel->{server};
foreach $nickrec (@nicks) {
$nick = $nickrec->{nick};
$host = $nickrec->{host};
my $nick = $nickrec->{nick};
my $host = $nickrec->{host};
if (!$temp_opped{$nick} &&
$server->masks_match($masks, $nick, $host)) {

View File

@ -6,6 +6,7 @@
use Irssi;
use Irssi::Irc;
use strict;
sub event_rejoin_kick {
my ($server, $data) = @_;
@ -14,8 +15,8 @@ sub event_rejoin_kick {
return if ($server->{nick} ne $nick);
# check if channel has password
$chanrec = $server->channel_find($channel);
$password = $chanrec->{key} if ($chanrec);
my $chanrec = $server->channel_find($channel);
my $password = $chanrec->{key} if ($chanrec);
# We have to use send_raw() because the channel record still
# exists and irssi won't even try to join to it with command()

View File

@ -1,10 +1,11 @@
# /CLONES - display real name of nick
use Irssi;
use strict;
sub cmd_clones {
my ($data, $server, $channel) = @_;
my %hostnames, $host, @nicks, $nick;
my (%hostnames, $host, @nicks, $nick);
@nicks = $channel->nicks();
@ -19,7 +20,6 @@ sub cmd_clones {
$channel->print("$host: $clones");
}
}
return 1;
}
Irssi::command_bind('clones', 'cmd_clones');

View File

@ -1,12 +1,12 @@
# "Hello, world!" script :) /hello <nick> sends "Hello, world!" to <nick>
use Irssi;
use strict;
sub cmd_hello {
my ($data, $server, $channel) = @_;
$server->command("/msg $data Hello, world!");
return 1;
}
Irssi::command_bind('hello', 'cmd_hello');

View File

@ -7,6 +7,9 @@
use Irssi;
use Irssi::Irc;
use strict;
my %keep_channels;
sub cmd_mlock {
my ($data, $server) = @_;
@ -14,25 +17,26 @@ sub cmd_mlock {
$keep_channels{$channel} = $mode;
mlock_check_mode($server, $channel);
return 1;
}
sub mlock_check_mode {
my ($server, $channame) = @_;
$channel = $server->channel_find($channame);
return if (!channel || !$channel->{chanop});
my $channel = $server->channel_find($channame);
return if (!$channel || !$channel->{chanop});
$keep_mode = $keep_channels{$channame};
my $keep_mode = $keep_channels{$channame};
return if (!$keep_mode);
# old channel mode
my ($oldmode, $oldkey, $oldlimit);
$oldmode = $channel->{mode};
$oldmode =~ s/^([^ ]*).*/\1/;
$oldkey = $channel->{key};
$oldlimit = $channel->{limit};
# get the new channel key/limit
my (@newmodes, $newkey, $limit);
@newmodes = split(/ /, $keep_mode); $keep_mode = $newmodes[0];
if ($keep_mode =~ /k/) {
if ($keep_mode =~ /k.*l/) {
@ -49,15 +53,15 @@ sub mlock_check_mode {
}
# check the differences
undef %allmodes;
my %allmodes;
$keep_mode =~ s/^\+//;
for ($n = 0; $n < length($keep_mode); $n++) {
$modechar = substr($keep_mode, $n, 1);
for (my $n = 0; $n < length($keep_mode); $n++) {
my $modechar = substr($keep_mode, $n, 1);
$allmodes{$modechar} = '+';
}
for ($n = 0; $n < length($oldmode); $n++) {
$modechar = substr($oldmode, $n, 1);
for (my $n = 0; $n < length($oldmode); $n++) {
my $modechar = substr($oldmode, $n, 1);
if ($allmodes{$modechar} eq '+') {
next if (($modechar eq "k" && $newkey ne $oldkey) ||
@ -69,8 +73,8 @@ sub mlock_check_mode {
}
# create the mode change string
$modecmd = ""; $extracmd = "";
foreach $mode (keys %allmodes) {
my ($modecmd, $extracmd);
foreach my $mode (keys %allmodes) {
Irssi::print("key = '$mode':".$allmodes{$mode});
if ($mode eq "k") {
if ($allmodes{$mode} eq '+') {

View File

@ -1,6 +1,7 @@
# listen PRIVMSGs - send a notice to yourself when your nick is meantioned
use Irssi;
use strict;
sub event_privmsg {
my ($server, $data, $nick, $address) = @_;
@ -8,7 +9,7 @@ sub event_privmsg {
return if (!$server->ischannel($target));
$mynick = $server->{nick};
my $mynick = $server->{nick};
return if ($text !~ /\b$mynick\b/);
$server->command("/notice $mynick In channel $target, $nick!$address said: $text");

View File

@ -2,17 +2,19 @@
use Irssi;
use Irssi::Irc;
use strict;
$quitfile = "$ENV{HOME}/.irssi/irssi.quit";
my $quitfile = glob "~/.irssi/irssi.quit";
sub cmd_quit {
my ($data, $server, $channel) = @_;
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;
while(<f>) {
next if ($. != $line);
@ -23,8 +25,7 @@ sub cmd_quit {
}
close(f);
@servers = Irssi::servers;
foreach $server (@servers) {
foreach my $server (Irssi::servers) {
$server->command("/disconnect ".$server->{tag}." $quitmsg");
}
}

View File

@ -2,6 +2,7 @@
use Irssi;
use Irssi::Irc;
use strict;
sub cmd_realname {
my ($data, $server, $channel) = @_;
@ -20,7 +21,6 @@ sub cmd_realname {
"event 313", "event empty", 1,
"event 317", "event empty", 1,
"event 319", "event empty", 1);
return 1;
}
sub event_rn_whois {
@ -28,7 +28,6 @@ sub event_rn_whois {
$realname =~ s/^://;
Irssi::print("%_$nick%_ is $realname");
return 1;
}
Irssi::command_bind('rn', 'cmd_realname');