diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/autoop.pl | 73 | ||||
-rw-r--r-- | scripts/autorejoin.pl | 71 | ||||
-rw-r--r-- | scripts/buf.pl | 17 | ||||
-rw-r--r-- | scripts/dns.pl | 22 | ||||
-rw-r--r-- | scripts/kills.pl | 9 | ||||
-rw-r--r-- | scripts/mail.pl | 4 | ||||
-rw-r--r-- | scripts/mlock.pl | 2 | ||||
-rw-r--r-- | scripts/quitmsg.pl | 4 | ||||
-rw-r--r-- | scripts/sb_search.pl | 159 | ||||
-rw-r--r-- | scripts/usercount.pl | 3 |
10 files changed, 142 insertions, 222 deletions
diff --git a/scripts/autoop.pl b/scripts/autoop.pl index f7182999..b72def15 100644 --- a/scripts/autoop.pl +++ b/scripts/autoop.pl @@ -5,13 +5,13 @@ use Irssi; 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); @@ -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; } } @@ -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; diff --git a/scripts/autorejoin.pl b/scripts/autorejoin.pl index 2d23449f..42c97da7 100644 --- a/scripts/autorejoin.pl +++ b/scripts/autorejoin.pl @@ -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 @@ -10,43 +9,49 @@ use Irssi; 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' ); diff --git a/scripts/buf.pl b/scripts/buf.pl index 43b4b3dd..da50e821 100644 --- a/scripts/buf.pl +++ b/scripts/buf.pl @@ -40,7 +40,7 @@ use Data::Dumper; 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; @@ -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]; @@ -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}; } } diff --git a/scripts/dns.pl b/scripts/dns.pl index 612fab0e..989cdc3e 100644 --- a/scripts/dns.pl +++ b/scripts/dns.pl @@ -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 @@ -28,7 +34,7 @@ my $pipe_tag; 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 = ""; diff --git a/scripts/kills.pl b/scripts/kills.pl index 7ed2d533..50d9383d 100644 --- a/scripts/kills.pl +++ b/scripts/kills.pl @@ -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); @@ -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 @@ -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; diff --git a/scripts/mail.pl b/scripts/mail.pl index 33b3c22e..190c33af 100644 --- a/scripts/mail.pl +++ b/scripts/mail.pl @@ -1,3 +1,5 @@ +use strict; +use vars qw($VERSION %IRSSI); $VERSION = "2.92"; %IRSSI = ( authors => "Timo Sirainen, Matti Hiljanen, Joost Vunderink, Bart Matthaei", @@ -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; diff --git a/scripts/mlock.pl b/scripts/mlock.pl index ed2fe52b..bf2fd002 100644 --- a/scripts/mlock.pl +++ b/scripts/mlock.pl @@ -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"); } } diff --git a/scripts/quitmsg.pl b/scripts/quitmsg.pl index 41bddaa8..e289468c 100644 --- a/scripts/quitmsg.pl +++ b/scripts/quitmsg.pl @@ -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; @@ -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"); } } diff --git a/scripts/sb_search.pl b/scripts/sb_search.pl deleted file mode 100644 index 51b9100b..00000000 --- a/scripts/sb_search.pl +++ /dev/null @@ -1,159 +0,0 @@ -# sb_search.pl - search in your scrollback, scroll to a match -# Do /HELP SCROLLBACK for help - -# Copyright (C) 2008 Wouter Coekaerts <wouter@coekaerts.be>, Emanuele Giaquinta <exg@irssi.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -use strict; -use Irssi; -use Irssi::TextUI; -use vars qw($VERSION %IRSSI); - -$VERSION = '1.1'; -%IRSSI = ( - authors => 'Wouter Coekaerts, Emanuele Giaquinta', - contact => 'wouter@coekaerts.be, exg@irssi.org', - name => 'sb_search', - description => 'search in your scrollback, scroll to a match', - license => 'GPLv2 or later', - url => 'http://wouter.coekaerts.be/irssi/', - changed => '$LastChangedDate$', -); - -sub cmd_help { - my ($args, $server, $witem) = @_; - if ($args =~ /^scrollback( search)? *$/i) { - Irssi::print ( <<SCRIPTHELP_EOF - -SCROLLBACK SEARCH [-level <level>] [-regexp] [-case] [-word] [-forward] [-all] [<pattern>] - - SEARCH: Search for text in the scrollback buffer. - - -regexp: The given text pattern is a regular expression. - -case: Performs a case-sensitive matching. - -word: The text must match full words. - -forward: Search forwards (default is backwards). - -all: Search in all windows. - - Without arguments, the last search is repeated. -SCRIPTHELP_EOF - ,MSGLEVEL_CLIENTCRAP); - } -} - -my $regex; -my $all; -my $level; - -sub cmd_sb_search { - my ($args, $server, $witem) = @_; - - ### handle options - - my ($options, $pattern) = Irssi::command_parse_options('scrollback search', $args); - - my $forward = defined(delete $options->{forward}); - - if (!%$options && !$pattern) { - return if !$regex && !defined $level; - } else { - $all = defined($options->{all}); - $level = MSGLEVEL_ALL; - undef $regex; - } - - if (defined($options->{level})) { - $level = $options->{level}; - $level =~ y/,/ /; - $level = Irssi::combine_level(0, $level); - } - - if ($pattern) { - my $flags = defined($options->{case}) ? '' : '(?i)'; - my $b = defined($options->{word}) ? '\b' : ''; - if (defined($options->{regexp})) { - local $@; - eval { - $regex = qr/$flags$b$pattern$b/; - }; - if ($@) { - my ($err) = $@ =~ /^(.*)/; - $err =~ s/\sat .* line \d+\.$//; - print CLIENTERROR $err; - return; - } - } else { - $regex = qr/$flags$b\Q$pattern\E$b/; - } - } - - - ### determine window(s) to search in - - my $current_win = ref $witem ? $witem->window() : Irssi::active_win(); - - my @windows; - if ($all) { - # cycle backward or forwards over all windows starting from current - # for example, searching backward through 5 windows, with window 3 active: search order is 3,2,1,5,4 - # if we're searching forward: 3,4,5,1,2 - my $order = $forward ? 1 : -1; - @windows = sort {$order * ($a->{refnum} cmp $b->{refnum})} Irssi::windows(); - my @before_windows = grep {($_->{refnum} cmp $current_win->{refnum}) == $order} @windows; - my @after_windows = grep {($_->{refnum} cmp $current_win->{refnum}) == -$order} @windows; - @windows = ($current_win, @before_windows, @after_windows); - } else { - @windows = ($current_win); - } - - ### do the search - - foreach my $win (@windows) { - my $view = $win->view; - - ## determine line to start from - my $line; - if ($all && $win != $current_win) { - if ($forward) { # first line - $line = $view->get_lines; - } else { # last line - $line = $view->{startline}; - while ($line->next) { - $line = $line->next - } - } - } else { # line after or before first visible line - $line = $forward ? $view->{startline}->next : $view->{startline}->prev; - } - - ## loop over the lines - while (defined $line) { - my $line_level = $line->{info}{level}; - if ($line_level & $level && $line->get_text(0) =~ $regex) { - $view->scroll_line($line); - if ($all) { - Irssi::command('window goto ' . $win->{refnum}); - } - return; - } - $line = $forward ? $line->next : $line->prev; - } - } -} - -Irssi::command_bind('scrollback search', \&cmd_sb_search); -Irssi::command_bind_last('help', \&cmd_help); -Irssi::command_set_options('scrollback search', '-level regexp case word forward all'); diff --git a/scripts/usercount.pl b/scripts/usercount.pl index 46dc0b46..613da1de 100644 --- a/scripts/usercount.pl +++ b/scripts/usercount.pl @@ -1,4 +1,6 @@ +use strict; use Irssi 20040119.2359 (); +use vars qw($VERSION %IRSSI); $VERSION = "1.19"; %IRSSI = ( authors => 'David Leadbeater, Timo Sirainen, Georg Lukas', @@ -29,7 +31,6 @@ $VERSION = "1.19"; # sb_uc_space = " "; -use strict; use Irssi::TextUI; my ($ircops, $ops, $halfops, $voices, $normal, $total); |