Skip to content

Commit

Permalink
Updated the bundled scripts to their latest version (#143)
Browse files Browse the repository at this point in the history
Updated the bundled scripts to their latest version (#143)

Removed sb_search.pl which is not contributed into the script archive, I
will poke coekie about it.
  • Loading branch information
GeertHauwaerts committed Jun 12, 2015
1 parent 788f181 commit a663d2f
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 222 deletions.
73 changes: 69 additions & 4 deletions scripts/autoop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use strict;
use vars qw($VERSION %IRSSI);

$VERSION = "1.00";
$VERSION = "1.10";
%IRSSI = (
authors => 'Timo Sirainen',
authors => 'Timo Sirainen & Jostein Kjønigsen',
name => 'autoop',
description => 'Simple auto-op script',
license => 'Public Domain',
changed => 'Sun Mar 10 23:18 EET 2002'
changed => 'Fri Nov 24 12:55 GMT+1 2014'
);

my (%opnicks, %temp_opped);
Expand Down Expand Up @@ -64,7 +64,7 @@ sub autoop {

if (!$temp_opped{$nick} &&
$server->masks_match($masks, $nick, $host)) {
$channel->command("op $nick");
$channel->command("/op $nick");
$temp_opped{$nick} = 1;
}
}
Expand All @@ -89,3 +89,68 @@ sub event_massjoin {

Irssi::command_bind('autoop', 'cmd_autoop');
Irssi::signal_add_last('massjoin', 'event_massjoin');

sub load_autoops {
my($file) = Irssi::get_irssi_dir."/autoop";
my($count) = 0;
local(*CONF);

%opnicks = ();
open(CONF, "<", "$file") or return;
while (my $line = <CONF>) {
if ($line !=~ /^\s*$/) {
cmd_autoop($line);
$count++;
}
}
close(CONF);

Irssi::print("Loaded $count channels from $file");
}

# --------[ save_autoops ]------------------------------------------------

sub save_autoops {
my($auto) = @_;
my($file) = Irssi::get_irssi_dir."/autoop";
my($count) = 0;
my($channel) = "";
local(*CONF);

return if $auto;

open(CONF, ">", "$file");
foreach $channel (keys %opnicks) {
my $masks = $opnicks{$channel};
print CONF "$channel\t$masks\n";
$count++;
}
close(CONF);

Irssi::print("Saved $count channels to $file")
unless $auto;
}


# --------[ sig_setup_reread ]------------------------------------------

# main setup is reread, so let us do it too
sub sig_setup_reread {
load_autoops;
}

# --------[ sig_setup_save ]--------------------------------------------

# main config is saved, and so we should save too
sub sig_setup_save {
my($mainconf,$auto) = @_;
save_autoops($auto);
}

# persistance

Irssi::signal_add('setup saved', 'sig_setup_save');
Irssi::signal_add('setup reread', 'sig_setup_reread');

# ensure we load persisted values on start
load_autoops;
71 changes: 38 additions & 33 deletions scripts/autorejoin.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# automatically rejoin to channel after kicked

# /SET autorejoin_channels #channel1 #channel2 ...
# automatically rejoin to channel after kick
# delayed rejoin: Lam 28.10.2001 (lam@lac.pl)

# NOTE: I personally don't like this feature, in most channels I'm in it
# will just result as ban. You've probably misunderstood the idea of /KICK
Expand All @@ -10,43 +9,49 @@
use Irssi::Irc;
use strict;
use vars qw($VERSION %IRSSI);

$VERSION = "1.00";
$VERSION = "1.0.0";
%IRSSI = (
authors => 'Timo Sirainen',
name => 'autorejoin',
description => 'Automatically rejoin to channel after kicked',
license => 'Public Domain',
changed => 'Sun Mar 10 23:18 EET 2002'
authors => "Timo 'cras' Sirainen, Leszek Matok",
contact => "lam\@lac.pl",
name => "autorejoin",
description => "Automatically rejoin to channel after being kick, after a (short) user-defined delay",
license => "GPLv2",
changed => "10.3.2002 14:00"
);

sub channel_rejoin {
my ($server, $channel) = @_;

# check if channel has password
my $chanrec = $server->channel_find($channel);
my $password = $chanrec->{key} if ($chanrec);
# How many seconds to wait before the rejoin?
# TODO: make this a /setting
my $delay = 5;

my @tags;
my $acttag = 0;

sub rejoin {
my ( $data ) = @_;
my ( $tag, $servtag, $channel, $pass ) = split( / +/, $data );

# We have to use send_raw() because the channel record still
# exists and irssi won't even try to join to it with command()
$server->send_raw("JOIN $channel $password");
my $server = Irssi::server_find_tag( $servtag );
$server->send_raw( "JOIN $channel $pass" ) if ( $server );
Irssi::timeout_remove( $tags[$tag] );
}

sub event_rejoin_kick {
my ($server, $data) = @_;
my ($channel, $nick) = split(/ +/, $data);

return if ($server->{nick} ne $nick);

# check if we want to autorejoin this channel
my @chans = split(/[ ,]+/, Irssi::settings_get_str('autorejoin_channels'));
foreach my $chan (@chans) {
if (lc($chan) eq lc($channel)) {
channel_rejoin($server, $channel);
last;
}
}
my ( $server, $data ) = @_;
my ( $channel, $nick ) = split( / +/, $data );

return if ( $server->{ nick } ne $nick );

# check if channel has password
my $chanrec = $server->channel_find( $channel );
my $password = $chanrec->{ key } if ( $chanrec );
my $rejoinchan = $chanrec->{ name } if ( $chanrec );
my $servtag = $server->{ tag };

Irssi::print "Rejoining $rejoinchan in $delay seconds.";
$tags[$acttag] = Irssi::timeout_add( $delay * 1000, "rejoin", "$acttag $servtag $rejoinchan $password" );
$acttag++;
$acttag = 0 if ( $acttag > 60 );
}

Irssi::settings_add_str('misc', 'autorejoin_channels', '');
Irssi::signal_add('event kick', 'event_rejoin_kick');
Irssi::signal_add( 'event kick', 'event_rejoin_kick' );
17 changes: 8 additions & 9 deletions scripts/buf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
my %suppress;

sub upgrade {
open BUF, sprintf('>%s/scrollbuffer', get_irssi_dir) or die $!;
open BUF, q{>}, sprintf('%s/scrollbuffer', get_irssi_dir) or die $!;
print BUF join("\0", map $_->{server}->{address} . $_->{name}, channels), "\n";
for my $window (windows) {
next unless defined $window;
Expand All @@ -66,7 +66,7 @@ sub upgrade {
}

sub restore {
open BUF, sprintf('<%s/scrollbuffer', get_irssi_dir) or die $!;
open BUF, q{<}, sprintf('%s/scrollbuffer', get_irssi_dir) or die $!;
my @suppress = split /\0/, <BUF>;
if (settings_get_bool 'upgrade_suppress_join') {
chomp $suppress[-1];
Expand Down Expand Up @@ -98,14 +98,13 @@ sub restore {

sub suppress {
my ($first, $second) = @_;
return
unless scalar keys %suppress
and settings_get_bool 'upgrade_suppress_join';
my $key = $first->{address} .
(grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
return unless scalar keys %suppress and settings_get_bool 'upgrade_suppress_join';
my $key_part = (grep { /^:?[#!+&]/ } split ' ', $second)[0];
$key_part =~ s/^://;
my $key = $first->{address} . $key_part;
if (exists $suppress{$key} and $suppress{$key}--) {
signal_stop();
delete $suppress{$key} unless $suppress{$key};
signal_stop();
delete $suppress{$key} unless $suppress{$key};
}
}

Expand Down
22 changes: 14 additions & 8 deletions scripts/dns.pl
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# /DNS <nick>|<host>|<ip> ...
# version 2.1.1
#
# updated the script to fix a bug where the script would let
# a trailing whitespace go through (ex: tab completion)
# - inch <inch@stmpd.net>

use Irssi;
use strict;
use Socket;
use POSIX;

use vars qw($VERSION %IRSSI);
$VERSION = "2.1";
$VERSION = "2.1.1";
%IRSSI = (
authors => 'Timo Sirainen',
name => 'dns',
description => '/DNS <nick>|<host>|<ip> ...',
license => 'Public Domain',
changed => 'Sun Mar 10 23:23 EET 2002'
authors => "Timo \'cras\' Sirainen",
contact => "tss\@iki.fi",
name => "dns",
description => "/DNS <nick>|<host>|<ip> ...",
license => "Public Domain",
url => "http://irssi.org/",
changed => "2002-03-04T22:47+0100"
);

my (%resolve_hosts, %resolve_nicks, %resolve_print); # resolve queues
Expand All @@ -28,7 +34,7 @@
sub cmd_dns {
my ($nicks, $server) = @_;
return if !$nicks;

$nicks =~ s/\s+$//;
# get list of nicks/hosts we want to know
my $tag = !$server ? undef : $server->{tag};
my $ask_nicks = "";
Expand Down
9 changes: 5 additions & 4 deletions scripts/kills.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# There's a pretty good explanation of (ircnet) ircd's server kills in
# http://www.irc.org/tech_docs/ircnet/kills.html

use strict;
use Irssi;
use vars qw($VERSION %IRSSI);

Expand Down Expand Up @@ -47,13 +48,13 @@ sub msg_quit {
my @printargs = ();
if ($killmsg =~ /([^ ]*) != (.*)/) {
# 1 != 2
my $server1 = $1, $server2 = $2;
my $server1 = $1, my $server2 = $2;

$server1 =~ s/([^\[]*)\[([^\]]*)\]/\1/;
$msg .= "$2 != $server2";
} elsif ($killmsg =~ /([^ ]*) <- (.*)/) {
# 1 <- 2
my $server1 = $1, $server2 = $2;
my $server1 = $1, my $server2 = $2;

if ($server1 =~ /^\(/) {
# (addr1)server1 <- (add2)server2
Expand Down Expand Up @@ -84,9 +85,9 @@ sub msg_quit {
$msg = $killmsg;
}

@list = $server->nicks_get_same($nick);
my @list = $server->nicks_get_same($nick);
while (@list) {
$channel = $list[0];
my $channel = $list[0];
shift @list;
# skip nick record
shift @list;
Expand Down
4 changes: 3 additions & 1 deletion scripts/mail.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "2.92";
%IRSSI = (
authors => "Timo Sirainen, Matti Hiljanen, Joost Vunderink, Bart Matthaei",
Expand Down Expand Up @@ -114,7 +116,7 @@ sub mbox_count {
$last_mtime = $mtime;

my $f = gensym;
return 0 if (!open($f, $mailfile));
return 0 if (!open($f, "<", $mailfile));

# count new mails only
my $internal_removed = 0;
Expand Down
2 changes: 1 addition & 1 deletion scripts/mlock.pl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ sub mlock_check_mode {
}

if ($modecmd ne "") {
$channel->{server}->command("mode $channame $modecmd$extracmd");
$channel->{server}->command("/mode $channame $modecmd$extracmd");
}
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/quitmsg.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sub cmd_quit {
my ($data, $server, $channel) = @_;
return if ($data ne "");

open (f, $quitfile) || return;
open (f, "<", $quitfile) || return;
my $lines = 0; while(<f>) { $lines++; };

my $line = int(rand($lines))+1;
Expand All @@ -38,7 +38,7 @@ sub cmd_quit {
close(f);

foreach my $server (Irssi::servers) {
$server->command("disconnect ".$server->{tag}." $quitmsg");
$server->command("/disconnect ".$server->{tag}." $quitmsg");
}
}

Expand Down
Loading

0 comments on commit a663d2f

Please sign in to comment.