script_DATA = \
autoop.pl \
- autorejoin.pl \
clones.pl \
hello.pl \
- mail.pl \
- privmsg.pl \
- realname.pl \
- quitmsg.pl
+ mail.pl \
+ beep.pl \
+ dns.pl \
+ mail-maildir.pl
EXTRA_DIST = $(script_DATA)
+++ /dev/null
-# automatically rejoin to channel after kicked
-
-# /SET autorejoin_channels #channel1 #channel2 ...
-
-# 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
-# if you kick/get kicked all the time "just for fun" ...
-
-use strict;
-use Irssi::Irc;
-
-sub channel_rejoin {
- my ($server, $channel) = @_;
-
- # check if channel has password
- 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()
- $server->send_raw("JOIN $channel $password");
-}
-
-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;
- }
- }
-}
-
-Irssi::settings_add_str('misc', 'autorejoin_channels', '');
-Irssi::signal_add('event kick', 'event_rejoin_kick');
--- /dev/null
+# $Id$
+
+use Irssi 20020121.2020 ();
+$VERSION = "0.10";
+%IRSSI = (
+ authors => 'Jean-Yves "decadix" Lefort',
+ contact => 'jylefort\@brutele.be, decadix on IRCNet',
+ name => 'beep',
+ description => 'Replaces your terminal bell by a command specified via /set; adds a beep_when_not_away setting',
+ license => 'BSD',
+ changed => '$Date$ ',
+);
+
+# /set's:
+#
+# beep_when_not_away opposite of builtin beep_when_away
+#
+# beep_command if not empty, the specified command will be
+# executed instead of the normal terminal bell
+
+use strict;
+
+sub beep {
+ my $server = Irssi::active_server;
+ if ($server && ! $server->{usermode_away}
+ && ! Irssi::settings_get_bool("beep_when_not_away")) {
+ Irssi::signal_stop();
+ } else {
+ if (my $command = Irssi::settings_get_str("beep_command")) {
+ system($command);
+ Irssi::signal_stop();
+ }
+ }
+}
+
+Irssi::settings_add_bool("lookandfeel", "beep_when_not_away", 0);
+Irssi::settings_add_str("misc", "beep_command",
+ "esdplay ~/sound/events/beep.wav &");
+
+Irssi::signal_add("beep", "beep");
--- /dev/null
+# /DNS <nick>|<host>|<ip> ...
+# for irssi 0.7.99 by Timo Sirainen
+# version 2.0
+
+use strict;
+use Socket;
+use POSIX;
+
+my (%resolve_hosts, %resolve_nicks, %resolve_print); # resolve queues
+my $userhosts; # number of USERHOSTs currently waiting for reply
+my $lookup_waiting; # 1 if we're waiting a reply for host lookup
+
+# for the current host lookup
+my ($print_server, $print_host, $print_name, @print_ips);
+my ($input_skip_next, $input_query);
+
+my $pipe_tag;
+
+sub cmd_dns {
+ my ($nicks, $server) = @_;
+ return if !$nicks;
+
+ # get list of nicks/hosts we want to know
+ my $tag = !$server ? undef : $server->{tag};
+ my $ask_nicks = "";
+ my $print_error = 0;
+ foreach my $nick (split(" ", $nicks)) {
+ if ($nick =~ /[\.:]/) {
+ # it's an IP or hostname
+ $resolve_hosts{$nick} = $tag;
+ } else {
+ # it's nick
+ if (!$print_error && (!$server || !$server->{connected})) {
+ $print_error = 1;
+ Irssi::print("Not connected to server");
+ } else {
+ $resolve_nicks{$nick} = 1;
+ $ask_nicks .= "$nick ";
+ }
+ }
+ }
+
+ if ($ask_nicks ne "") {
+ # send the USERHOST query
+ $userhosts++;
+ $server->redirect_event('userhost', 1, $ask_nicks, 0, 'redir dns failure', {
+ 'event 302' => 'redir dns host',
+ '' => 'event empty' } );
+ $server->send_raw("USERHOST :$nicks");
+ }
+
+ # ask the IPs/hostnames immediately
+ host_lookup() if (!$lookup_waiting);
+}
+
+sub sig_failure {
+ Irssi::print("Error getting hostname for nick");
+ %resolve_nicks = () if (--$userhosts == 0);
+}
+
+sub sig_userhost {
+ my ($server, $data) = @_;
+ $data =~ s/^[^ ]* :?//;
+ my @hosts = split(/ +/, $data);
+
+ # move resolve_nicks -> resolve_hosts
+ foreach my $host (@hosts) {
+ if ($host =~ /^([^=\*]*)\*?=.(.*)@(.*)/) {
+ my $nick = $1;
+ my $user = $2;
+ $host = $3;
+
+ $resolve_hosts{$host} = $resolve_nicks{$nick};
+ delete $resolve_nicks{$nick};
+ $resolve_print{$host} = "[$nick!$user"."@"."$host]";
+ }
+ }
+
+ if (--$userhosts == 0 && %resolve_nicks) {
+ # unknown nicks - they didn't contain . or : so it can't be
+ # IP or hostname.
+ Irssi::print("Unknown nicks: ".join(' ', keys %resolve_nicks));
+ %resolve_nicks = ();
+ }
+
+ host_lookup() if (!$lookup_waiting);
+}
+
+sub host_lookup {
+ return if (!%resolve_hosts);
+
+ my ($host) = keys %resolve_hosts;
+ $print_server = $resolve_hosts{$host};
+
+ $print_host = undef;
+ $print_name = $resolve_print{$host};
+ @print_ips = ();
+
+ delete $resolve_hosts{$host};
+ delete $resolve_print{$host};
+
+ $input_query = $host;
+ $input_skip_next = 0;
+
+ # pipe is used to get the reply from child
+ my ($rh, $wh);
+ pipe($rh, $wh);
+
+ # non-blocking host lookups with fork()ing
+ my $pid = fork();
+ if (!defined($pid)) {
+ %resolve_hosts = ();
+ %resolve_print = ();
+ Irssi::print("Can't fork() - aborting");
+ close($rh); close($wh);
+ return;
+ }
+ $lookup_waiting++;
+
+ if ($pid > 0) {
+ # parent, wait for reply
+ close($wh);
+ Irssi::pidwait_add($pid);
+ $pipe_tag = Irssi::input_add(fileno($rh), INPUT_READ, \&pipe_input, $rh);
+ return;
+ }
+
+ my $text;
+ eval {
+ # child, do the lookup
+ my $name = "";
+ if ($host =~ /^[0-9\.]*$/) {
+ # ip -> host
+ $name = gethostbyaddr(inet_aton($host), AF_INET);
+ } else {
+ # host -> ip
+ my @addrs = gethostbyname($host);
+ if (@addrs) {
+ @addrs = map { inet_ntoa($_) } @addrs[4 .. $#addrs];
+ $name = join (" ", @addrs);
+ }
+ }
+
+ $print_name = $input_query if !$print_name;
+ if (!$name) {
+ $text = "No information for $print_name";
+ } else {
+ $text = "$print_name: $name";
+ }
+ };
+ $text = $! if (!$text);
+
+ eval {
+ # write the reply
+ print($wh $text);
+ close($wh);
+ };
+ POSIX::_exit(1);
+}
+
+sub pipe_input {
+ my $rh = shift;
+ my $text = <$rh>;
+ close($rh);
+
+ Irssi::input_remove($pipe_tag);
+ $pipe_tag = -1;
+
+ my $server = Irssi::server_find_tag($print_server);
+ if ($server) {
+ $server->print('', $text);
+ } else {
+ Irssi::print($text);
+ }
+
+ $lookup_waiting--;
+ host_lookup();
+}
+
+Irssi::command_bind('dns', 'cmd_dns');
+Irssi::signal_add( {
+ 'redir dns failure' => \&sig_failure,
+ 'redir dns host' => \&sig_userhost } );
--- /dev/null
+# $Id$
+
+$VERSION = "1.8";
+%IRSSI = (
+ authors => "Matti Hiljanen",
+ contact => "qvr\@staff.peliportti.net",
+ name => "mail-maildir",
+ description => "Mail counter statusbar item with maildir support",
+ license => "Public Domain",
+ url => "http://matin.maapallo.org/softa/irssi",
+);
+
+# Mail counter statusbar item
+# for irssi 0.7.99 by Timo Sirainen
+#
+# Maildir support added by Matti Hiljanen
+#
+# /SET maildir_mode - ON/OFF
+# /SET mail_file - specifies mbox file/Maildir location
+# /SET mail_refresh_time - in seconds, how often to check for new mail
+
+use Irssi::TextUI;
+
+my $maildirmode = 0; # maildir=1, file(spools)=0
+
+my $last_refresh_time, $refresh_tag;
+
+# for mbox caching
+my $last_size, $last_mtime, $last_mailcount, $last_mode;
+
+sub mbox_count {
+ my $mailfile = shift;
+ my $count;
+ my $maildirmode=Irssi::settings_get_bool('maildir_mode');
+ if (!$maildirmode) {
+ my @stat = stat($mailfile);
+ my $size = $stat[7];
+ my $mtime = $stat[9];
+
+ # if the file hasn't changed, get the count from cache
+ return $last_mailcount if ($last_size == $size && $last_mtime == $mtime);
+ $last_size = $size;
+ $last_mtime = $mtime;
+
+ my $f = gensym;
+ return 0 if (!open($f, $mailfile));
+
+ while (<$f>) {
+ $count++ if (/^From /);
+ $count-- if (/^Subject: .*FOLDER INTERNAL DATA/);
+ }
+ close($f);
+ $last_mailcount = $count;
+ } else {
+ opendir(DIR, "$mailfile/cur") or return 0;
+ while (defined(my $file = readdir(DIR))) {
+ next if $file =~ /S/ || $file =~ /^(.|..)$/;
+ $count++;
+ }
+ closedir(DIR);
+
+ opendir(DIR, "$mailfile/new") or return 0;
+ while (defined(my $file = readdir(DIR))) {
+ next if $file =~ /^(.|..)$/;
+ $count++;
+ }
+ closedir(DIR);
+ }
+ return $count;
+}
+
+sub mail {
+ my ($item, $get_size_only) = @_;
+
+ $count = mbox_count(Irssi::settings_get_str('mail_file'));
+ if ($count == 0) {
+ # no mail - don't print the [Mail: ] at all
+ if ($get_size_only) {
+ $item->{min_size} = $item->{max_size} = 0;
+ }
+ } else {
+ $item->default_handler($get_size_only, undef, $count, 1);
+ }
+}
+
+sub refresh_mail {
+ Irssi::statusbar_items_redraw('mail');
+}
+
+sub read_settings {
+ my $time = Irssi::settings_get_int('mail_refresh_time');
+ my $mode = Irssi::settings_get_bool('maildir_mode');
+ unless ($time == $last_refresh_time) {
+ $last_refresh_time = $time;
+ Irssi::timeout_remove($refresh_tag) if ($refresh_tag);
+ $refresh_tag = Irssi::timeout_add($time*1000, 'refresh_mail', undef);
+ }
+ return if ($mode == $last_mode);
+ $last_mode = $mode;
+ if (!$mode) {
+ Irssi::settings_set_str('mail_file', "$ENV{'MAIL'}");
+ } else {
+ Irssi::settings_set_str('mail_file', "$ENV{'HOME'}/Maildir");
+ }
+ refresh_mail;
+}
+
+if (!$maildirmode) {
+ Irssi::settings_add_str('misc', 'mail_file', $ENV{'MAIL'});
+} else {
+ Irssi::settings_add_str('misc', 'mail_file', "$ENV{'HOME'}/Maildir");
+}
+Irssi::settings_add_int('misc', 'mail_refresh_time', 60);
+Irssi::settings_add_bool('misc', 'maildir_mode', "$maildirmode");
+
+Irssi::statusbar_item_register('mail', '{sb Mail: $0-}', 'mail');
+
+read_settings();
+Irssi::signal_add('setup changed', 'read_settings');
+++ /dev/null
-# /MLOCK <channel> <mode>
-#
-# Locks the channel mode to <mode>, if someone else tries to change the mode
-# Irssi will automatically change it back. +k and +l are a bit special since
-# they require the parameter. If you omit the parameter, like setting the
-# mode to "+ntlk", Irssi will allow all +k and +l (or -lk) mode changes.
-
-use Irssi;
-use Irssi::Irc;
-use strict;
-
-my %keep_channels;
-
-sub cmd_mlock {
- my ($data, $server) = @_;
- my ($channel, $mode) = split(/ /, $data, 2);
-
- $keep_channels{$channel} = $mode;
- mlock_check_mode($server, $channel);
-}
-
-sub mlock_check_mode {
- my ($server, $channame) = @_;
-
- my $channel = $server->channel_find($channame);
- return if (!$channel || !$channel->{chanop});
-
- 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/) {
- $newkey = $newmodes[1];
- $limit = $newmodes[2];
- } elsif ($keep_mode =~ /l.*k/) {
- $limit = $newmodes[1];
- $newkey = $newmodes[2];
- } else {
- $newkey = $newmodes[1];
- }
- } elsif ($keep_mode =~ /l/) {
- $limit = $newmodes[1];
- }
-
- # check the differences
- my %allmodes;
- $keep_mode =~ s/^\+//;
- for (my $n = 0; $n < length($keep_mode); $n++) {
- my $modechar = substr($keep_mode, $n, 1);
- $allmodes{$modechar} = '+';
- }
-
- 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) ||
- ($modechar eq "l" && $limit != $oldlimit));
- delete $allmodes{$modechar};
- } else {
- $allmodes{$modechar} = '-';
- }
- }
-
- # create the mode change string
- my ($modecmd, $extracmd);
- foreach my $mode (keys %allmodes) {
- Irssi::print("key = '$mode':".$allmodes{$mode});
- if ($mode eq "k") {
- if ($allmodes{$mode} eq '+') {
- next if ($newkey eq "");
- if ($oldkey ne "") {
- # we need to get rid of old key too
- $modecmd .= "-k";
- $extracmd .= " $oldkey";
- }
- $extracmd .= " $newkey";
- } else {
- $extracmd .= " $oldkey";
- }
- }
- if ($mode eq "l" && $allmodes{$mode} eq '+') {
- next if ($limit <= 0);
- $extracmd .= " $limit";
- }
- $modecmd .= $allmodes{$mode}.$mode;
- }
-
- if ($modecmd ne "") {
- $channel->{server}->command("/mode $channame $modecmd$extracmd");
- }
-}
-
-sub mlock_mode_changed {
- my ($server, $data) = @_;
- my ($channel, $mode) = split(/ /, $data, 2);
-
- mlock_check_mode($server, $channel);
-}
-
-sub mlock_synced {
- my $channel = $_[0];
-
- mlock_check_mode($channel->{server}, $channel->{name});
-}
-
-Irssi::command_bind('mlock', 'cmd_mlock');
-Irssi::signal_add_last("event mode", "mlock_mode_changed");
-Irssi::signal_add("channel synced", "mlock_synced");
+++ /dev/null
-# listen PRIVMSGs - send a notice to yourself when your nick is meantioned
-
-use Irssi;
-use strict;
-
-sub event_privmsg {
- my ($server, $data, $nick, $address) = @_;
- my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
-
- return if (!$server->ischannel($target));
-
- my $mynick = $server->{nick};
- return if ($text !~ /\b$mynick\b/);
-
- $server->command("/notice $mynick In channel $target, $nick!$address said: $text");
-}
-
-Irssi::signal_add("event privmsg", "event_privmsg");
+++ /dev/null
-# If quit message isn't given, quit with a random message
-# read from ~/.irssi/irssi.quit
-
-use Irssi;
-use Irssi::Irc;
-use strict;
-
-my $quitfile = glob "~/.irssi/irssi.quit";
-
-sub cmd_quit {
- my ($data, $server, $channel) = @_;
- return if ($data ne "");
-
- open (f, $quitfile) || return;
- my $lines = 0; while(<f>) { $lines++; };
-
- my $line = int(rand($lines))+1;
-
- my $quitmsg;
- seek(f, 0, 0); $. = 0;
- while(<f>) {
- next if ($. != $line);
-
- chomp;
- $quitmsg = $_;
- last;
- }
- close(f);
-
- foreach my $server (Irssi::servers) {
- $server->command("/disconnect ".$server->{tag}." $quitmsg");
- }
-}
-
-Irssi::command_bind('quit', 'cmd_quit');
+++ /dev/null
-# /RN - display real name of nick
-
-use Irssi;
-use Irssi::Irc;
-use strict;
-
-sub cmd_realname {
- my ($data, $server, $channel) = @_;
-
- $server->send_raw("WHOIS :$data");
-
- # ignore all whois replies except "No such nick" or the
- # first line of the WHOIS reply
- $server->redirect_event($data, 2,
- "event 318", "event empty", -1,
- "event 402", "event 402", -1,
- "event 401", "event 401", 1,
- "event 311", "redir whois", 1,
- "event 301", "event empty", 1,
- "event 312", "event empty", 1,
- "event 313", "event empty", 1,
- "event 317", "event empty", 1,
- "event 319", "event empty", 1);
-}
-
-sub event_rn_whois {
- my ($num, $nick, $user, $host, $empty, $realname) = split(/ +/, $_[1], 6);
- $realname =~ s/^://;
-
- Irssi::print("%_$nick%_ is $realname");
-}
-
-Irssi::command_bind('rn', 'cmd_realname');
-Irssi::signal_add('redir whois', 'event_rn_whois');