summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-03-10 21:28:38 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-03-10 21:28:38 +0000
commit03c71116e044fda9d99e827a4ffb0652d508abb5 (patch)
treedf36506fb09ad6563feaf394a0a47728348cadd6 /scripts
parent1855e6cc5c84ec861bf1301c09841cb2fd9ad718 (diff)
downloadirssi-03c71116e044fda9d99e827a4ffb0652d508abb5.zip
added/removed some default scripts
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2569 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'scripts')
-rw-r--r--scripts/autoop.pl11
-rw-r--r--scripts/autorejoin.pl13
-rw-r--r--scripts/buf.pl132
-rw-r--r--scripts/clones.pl43
-rw-r--r--scripts/dns.pl193
-rw-r--r--scripts/examples/command.pl23
-rw-r--r--scripts/examples/msg-event.pl41
-rw-r--r--scripts/examples/redirect.pl (renamed from scripts/realname.pl)11
-rw-r--r--scripts/hello.pl12
-rw-r--r--scripts/kills.pl105
-rw-r--r--scripts/mlock.pl20
-rw-r--r--scripts/privmsg.pl18
-rw-r--r--scripts/quitmsg.pl10
-rw-r--r--scripts/splitlong.pl50
14 files changed, 606 insertions, 76 deletions
diff --git a/scripts/autoop.pl b/scripts/autoop.pl
index 413f5e17..d46d099e 100644
--- a/scripts/autoop.pl
+++ b/scripts/autoop.pl
@@ -1,7 +1,18 @@
# /AUTOOP <*|#channel> [<nickmasks>]
+# use friends.pl if you need more features
use Irssi;
use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'autoop',
+ description => 'Simple auto-op script',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:18 EET 2002'
+);
my (%opnicks, %temp_opped);
diff --git a/scripts/autorejoin.pl b/scripts/autorejoin.pl
index 3738f5fc..a6dd4b58 100644
--- a/scripts/autorejoin.pl
+++ b/scripts/autorejoin.pl
@@ -6,8 +6,19 @@
# 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;
use Irssi::Irc;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'autorejoin',
+ description => 'Automatically rejoin to channel after kicked',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:18 EET 2002'
+);
sub channel_rejoin {
my ($server, $channel) = @_;
diff --git a/scripts/buf.pl b/scripts/buf.pl
new file mode 100644
index 00000000..3300d2d1
--- /dev/null
+++ b/scripts/buf.pl
@@ -0,0 +1,132 @@
+# Highly experimental. use it at your own risk.
+
+use strict;
+use vars qw($VERSION %IRSSI);
+
+use Irssi 20020120; # 21/01/2002, 18:00 cvs commit
+# at http://juerd.nl/irssi/temporary.deb for debian sid
+$VERSION = "2.06";
+%IRSSI = (
+ authors => "Juerd",
+ contact => "juerd\@juerd.nl",
+ name => "Scroll buffer thingy",
+ description => "Saves the buffer for /upgrade",
+ license => "Public Domain",
+ url => "http://juerd.nl/irssi/",
+ changed => "Tue Feb 28 16:22 CET 2002",
+ changes => "+logging workaround (untested, suggested by darix)"
+);
+
+# Saves the Irssi scrollbuffer and displays it after /UPGADEing.
+# Additionaly saves your settings and layout.
+# HAS TO BE in $irssidir/scripts/autorun (don't forget to load the
+# perl module if you have to... put /load perl in $irssidir/startup)
+
+# Q: How can I get a very smooth and clean upgrade?
+# A: /set -clear upgrade_separator
+# /set upgrade_suppress_join ON (default)
+# /set channel_sync OFF
+
+# Q: Can I use color in the upgrade_separator?
+# Q: Is it possible to save my command history?
+# Q: Can I prevent the screen from blinking?
+# Q: Can you make it faster?
+# A: Probably not, but if you can do it, tell me how.
+
+use Irssi::TextUI;
+use Data::Dumper;
+
+my %suppress;
+
+sub upgrade {
+ open (BUF, sprintf('>%s/scrollbuffer', Irssi::get_irssi_dir()));
+ my $logging = Irssi::settings_get_bool('autolog') || 0;
+ print BUF join("\0", map $_->{server}->{address} . $_->{name}, Irssi::channels()), "\n";
+ print BUF "$logging\n";
+ for my $window (Irssi::windows()){
+ next unless defined $window;
+ next if $window->{name} eq 'status';
+ my $view = $window->view();
+ my $line = $view->get_lines();
+ my $lines = 0;
+ my $buf = '';
+ if (defined $line){
+ {
+ $buf .= $line->get_text(1) . "\n";
+ $line = $line->next();
+ $lines++;
+ redo if defined $line;
+ }
+ }
+ printf BUF ("%s:%s\n%s", $window->{refnum}, $lines, $buf);
+ }
+ close BUF;
+ unlink sprintf("%s/sessionconfig", Irssi::get_irssi_dir());
+ Irssi::command('/layout save');
+ Irssi::command('/set autolog off') if $logging;
+ Irssi::command('/save');
+}
+
+sub restore {
+ open (BUF, sprintf('<%s/scrollbuffer', Irssi::get_irssi_dir()));
+ my @suppress = split /\0/, <BUF>;
+ my $logging = <BUF>;
+ chomp $logging;
+ if (Irssi::settings_get_bool('upgrade_suppress_join')) {
+ chomp $suppress[-1];
+ @suppress{@suppress} = (2) x @suppress;
+ }
+ Irssi::active_win()->command('/^window scroll off');
+ while (my $bla = <BUF>){
+ chomp $bla;
+ my ($refnum, $lines) = split /:/, $bla;
+ next unless $lines;
+ my $window = Irssi::window_find_refnum($refnum);
+ unless (defined $window){
+ <BUF> for 1..$lines;
+ Irssi::print("no $refnum?");
+ next;
+ }
+ my $view = $window->view();
+ $view->remove_all_lines();
+ $view->redraw();
+ my $buf = '';
+ $buf .= <BUF> for 1..$lines;
+ my $sep = Irssi::settings_get_str('upgrade_separator');
+ $sep .= "\n" if $sep ne '';
+ $window->gui_printtext_after(undef, MSGLEVEL_CLIENTNOTICE, "$buf\cO$sep");
+ $view->redraw();
+ }
+ Irssi::active_win()->command('/^window scroll on');
+ Irssi::active_win()->command('/^scrollback end');
+ Irssi::command('/set autolog on') if $logging;
+}
+
+sub suppress {
+ my ($first, $second) = @_;
+ return unless scalar keys %suppress
+ and Irssi::settings_get_bool('upgrade_suppress_join');
+ my $key = $first->{address} .
+ (grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
+ if (exists $suppress{$key} and $suppress{$key}--) {
+ Irssi::signal_stop();
+ delete $suppress{$key} unless $suppress{$key};
+ }
+}
+
+# Don't use these :P they're for testing
+#Irssi::command_bind('emulate_upgrade', 'upgrade');
+#Irssi::command_bind('emulate_restore', 'restore');
+
+Irssi::settings_add_str('buffer', 'upgrade_separator', '=Upgrade=');
+Irssi::settings_add_bool('buffer', 'upgrade_suppress_join', 1);
+
+Irssi::signal_add_first('session save', 'upgrade');
+Irssi::signal_add_first('session restore', 'restore');
+Irssi::signal_add('event 366', 'suppress');
+Irssi::signal_add('event join', 'suppress');
+
+unless (-f sprintf('%s/scripts/autorun/buf.pl', Irssi::get_irssi_dir())) {
+ Irssi::print('PUT THIS SCRIPT IN ~/.irssi/scripts/autorun/ BEFORE /UPGRADING!!');
+ Irssi::print('And don\'t forget to /load perl using ~/.irssi/autostart');
+}
diff --git a/scripts/clones.pl b/scripts/clones.pl
deleted file mode 100644
index 59c22c3f..00000000
--- a/scripts/clones.pl
+++ /dev/null
@@ -1,43 +0,0 @@
-# /CLONES - Display clones in the active channel
-# Modified by Roi Dayan. dejavo@punkass.com
-
-use strict;
-
-sub cmd_clones {
- my ($data, $server, $channel) = @_;
- my $min_show_count = ($data =~ /^[0-9]+$/) ? $data : 2;
-
- if (!$channel || $channel->{type} ne "CHANNEL") {
- Irssi::print("No active channel in window");
- return;
- }
-
- my %hostnames = {};
- my %hostnicks = {};
- my @hosttmp = {};
- foreach my $nick ($channel->nicks()) {
- my @hosttmp = split(/\@/,$nick->{host});
- $hostnames{$hosttmp[1]}++;
- $hostnicks{$hosttmp[1]} = $hostnicks{$hosttmp[1]}.$hostnames{$hosttmp[1]}.". ".$nick->{nick}."!".$nick->{host}."\n";
- $hostnicks{$hosttmp[1]} =~ s/^,//;
-# $hostnicks{$hosttmp[1]} =~ s/\n$//;
- }
-
- foreach my $nick (keys %hostnicks) {
- $hostnicks{$nick} =~ s/\n$//;
- }
-
- my $count = 0;
- foreach my $host (keys %hostnames) {
- my $clones = $hostnames{$host};
- if ($clones >= $min_show_count) {
- $channel->print("Clones:") if ($count == 0);
- $channel->print("$host: $clones $hostnicks{$host}");
- $count++;
- }
- }
-
- $channel->print("No clones in channel") if ($count == 0);
-}
-
-Irssi::command_bind('clones', 'cmd_clones');
diff --git a/scripts/dns.pl b/scripts/dns.pl
new file mode 100644
index 00000000..612fab0e
--- /dev/null
+++ b/scripts/dns.pl
@@ -0,0 +1,193 @@
+# /DNS <nick>|<host>|<ip> ...
+
+use Irssi;
+use strict;
+use Socket;
+use POSIX;
+
+use vars qw($VERSION %IRSSI);
+$VERSION = "2.1";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'dns',
+ description => '/DNS <nick>|<host>|<ip> ...',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:23 EET 2002'
+);
+
+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)) {
+ $nick = lc($nick);
+ 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 = lc($1);
+ my $user = $2;
+ $host = lc($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 } );
diff --git a/scripts/examples/command.pl b/scripts/examples/command.pl
new file mode 100644
index 00000000..77a9d7fb
--- /dev/null
+++ b/scripts/examples/command.pl
@@ -0,0 +1,23 @@
+# Example how to create your own /commands:
+
+# /HELLO <nick> - sends a "Hello, world!" to given nick.
+
+use Irssi;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'command',
+ description => 'Command example',
+ license => 'Public Domain'
+);
+
+sub cmd_hello {
+ my ($data, $server, $channel) = @_;
+
+ $server->command("/msg $data Hello, world!");
+}
+
+Irssi::command_bind('hello', 'cmd_hello');
diff --git a/scripts/examples/msg-event.pl b/scripts/examples/msg-event.pl
new file mode 100644
index 00000000..53174e23
--- /dev/null
+++ b/scripts/examples/msg-event.pl
@@ -0,0 +1,41 @@
+# Example how to react on specific messages:
+
+# !reverse <text> sends back the text reversed.
+
+use Irssi;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'msg-event',
+ description => 'Event example',
+ license => 'Public Domain'
+);
+
+sub event_privmsg {
+ # $server = server record where the message came
+ # $data = the raw data received from server, with PRIVMSGs it is:
+ # "target :text" where target is either your nick or #channel
+ # $nick = the nick who sent the message
+ # $host = host of the nick who sent the message
+ my ($server, $data, $nick, $host) = @_;
+
+ # split data to target/text
+ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
+
+ # skip lines not beginning with !reverse
+ return if ($text !~ /!reverse (.*)/);
+ $text = $1;
+
+ if (!$server->ischannel($target)) {
+ # private message, $target contains our nick, so we'll need
+ # to change it to $nick
+ $target = $nick;
+ }
+
+ $server->command("notice $target reversed $text = ".reverse($text));
+}
+
+Irssi::signal_add('event privmsg', 'event_privmsg');
diff --git a/scripts/realname.pl b/scripts/examples/redirect.pl
index 0adbcef3..6a7e94cc 100644
--- a/scripts/realname.pl
+++ b/scripts/examples/redirect.pl
@@ -1,8 +1,19 @@
+# Example how to do redirections, we'll grab the output of /WHOIS:
+
# /RN - display real name of nick
use Irssi;
use Irssi::Irc;
use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'redirect',
+ description => 'Redirection example',
+ license => 'Public Domain'
+);
sub cmd_realname {
my ($data, $server, $channel) = @_;
diff --git a/scripts/hello.pl b/scripts/hello.pl
deleted file mode 100644
index 82adfe22..00000000
--- a/scripts/hello.pl
+++ /dev/null
@@ -1,12 +0,0 @@
-# "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!");
-}
-
-Irssi::command_bind('hello', 'cmd_hello');
diff --git a/scripts/kills.pl b/scripts/kills.pl
new file mode 100644
index 00000000..3d7d5854
--- /dev/null
+++ b/scripts/kills.pl
@@ -0,0 +1,105 @@
+# Display kills with more understandable messages.
+# for irssi 0.7.98 by Timo Sirainen
+
+# I didn't find anyone else who had done this so I had to figure everything
+# out myself, hope this works correctly and in all irc networks.
+
+# There's one kind of nick collision this script doesn't handle - if the
+# collision is detected by the server you're connected to, it won't use
+# kill as quit reason, but "Nick collision(new)" or "..(old)". This is pretty
+# easy to understand already, happens hardly ever(?) and it can be faked
+# so I thought better not change it to kill message.
+
+# There's a pretty good explanation of (ircnet) ircd's server kills in
+# http://www.irc.org/tech_docs/ircnet/kills.html
+
+use Irssi;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'kills',
+ description => 'Displays kills with more understandable messages',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:18 EET 2002'
+);
+
+Irssi::theme_register([
+ 'kill_public', '{channick $0} {chanhost $1} killed by {nick $2}$3 {reason $4}'
+]);
+
+sub msg_quit {
+ my ($server, $nick, $addr, $data) = @_;
+
+ my $localkill;
+ if ($data =~ /^Killed \(([^ ]*) \((.*)\)\)$/) {
+ # remote kill
+ $localkill = 0;
+ } elsif ($data =~ /^Local Kill by ([^ ]*) \((.*)\)/) {
+ # local kill
+ $localkill = 1;
+ } else {
+ return;
+ }
+
+ my $killer = $1;
+ my $killmsg = $2;
+ my $msg = "\002Nick collision\002: ";
+
+ my @printargs = ();
+ if ($killmsg =~ /([^ ]*) != (.*)/) {
+ # 1 != 2
+ my $server1 = $1, $server2 = $2;
+
+ $server1 =~ s/([^\[]*)\[([^\]]*)\]/\1/;
+ $msg .= "$2 != $server2";
+ } elsif ($killmsg =~ /([^ ]*) <- (.*)/) {
+ # 1 <- 2
+ my $server1 = $1, $server2 = $2;
+
+ if ($server1 =~ /^\(/) {
+ # (addr1)server1 <- (add2)server2
+ $server1 =~ s/^\(([^\)]*)\)//;
+ my $nick1 = $1;
+ $server2 =~ s/^\(([^\)]*)\)//;
+ my $nick2 = $1;
+
+ $msg .= "server $server1";
+ $msg .= " (nick from $nick1)" if $nick1;
+ $msg .= " <- ";
+ $msg .= "\002$server2\002";
+ $msg .= " (nick from \002$nick2\002)" if $nick2;
+ } elsif ($server1 =~ /\)$/ || $server2 =~ /\)$/) {
+ # server1(nick) <- server2
+ # server1 <- server2(nick)
+ $server1 =~ s/\(([^\)]*)\)$//;
+ my $oldnick = $1;
+ $server2 =~ s/\(([^\)]*)\)$//;
+ $oldnick = $1 if $1;
+ $msg = "\002Nick change collision\002: $server1 <- \002$server2\002 (old nick \002$oldnick\002)";
+ } else {
+ # server1 <- server2
+ $msg = "\002Nick/server collision\002: $server1 <- \002$server2\002";
+ }
+ } else {
+ # something else, just show it as-is
+ $msg = $killmsg;
+ }
+
+ @list = $server->nicks_get_same($nick);
+ while (@list) {
+ $channel = $list[0];
+ shift @list;
+ # skip nick record
+ shift @list;
+
+ $channel->printformat(MSGLEVEL_QUITS, 'kill_public',
+ $nick, $addr, $killer,
+ $localkill ? " (local)" : "", $msg);
+ }
+
+ Irssi::signal_stop();
+}
+
+Irssi::signal_add('message quit', 'msg_quit');
diff --git a/scripts/mlock.pl b/scripts/mlock.pl
index 35ad7856..bf2fd002 100644
--- a/scripts/mlock.pl
+++ b/scripts/mlock.pl
@@ -4,10 +4,21 @@
# 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.
+# You can remove the lock with /MODE #channel -
use Irssi;
use Irssi::Irc;
use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'mlock',
+ description => 'Channel mode locking',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:18 EET 2002'
+);
my %keep_channels;
@@ -15,8 +26,13 @@ sub cmd_mlock {
my ($data, $server) = @_;
my ($channel, $mode) = split(/ /, $data, 2);
- $keep_channels{$channel} = $mode;
- mlock_check_mode($server, $channel);
+ if ($mode eq "-") {
+ # remove checking
+ delete $keep_channels{$channel};
+ } else {
+ $keep_channels{$channel} = $mode;
+ mlock_check_mode($server, $channel);
+ }
}
sub mlock_check_mode {
diff --git a/scripts/privmsg.pl b/scripts/privmsg.pl
deleted file mode 100644
index b1d119cb..00000000
--- a/scripts/privmsg.pl
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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");
diff --git a/scripts/quitmsg.pl b/scripts/quitmsg.pl
index 981b15a0..5fd4c6ce 100644
--- a/scripts/quitmsg.pl
+++ b/scripts/quitmsg.pl
@@ -4,6 +4,16 @@
use Irssi;
use Irssi::Irc;
use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'quitmsg',
+ description => 'Random quit messages',
+ license => 'Public Domain',
+ changed => 'Sun Mar 10 23:18 EET 2002'
+);
my $quitfile = glob "~/.irssi/irssi.quit";
diff --git a/scripts/splitlong.pl b/scripts/splitlong.pl
new file mode 100644
index 00000000..ee787ed9
--- /dev/null
+++ b/scripts/splitlong.pl
@@ -0,0 +1,50 @@
+# /set splitlong_max_length
+# specifies the maximum length of a msg, automatically chosen when set to "0"
+###
+use strict;
+use vars qw($VERSION %IRSSI);
+
+#don't know which version exactly, probably even works with 0.7.98.4
+use Irssi 20011001;
+
+$VERSION = "0.15";
+%IRSSI = (
+ authors => "Bjoern \'fuchs\' Krombholz",
+ contact => "bjkro\@gmx.de",
+ name => "splitlong",
+ description => "Split overlong PRIVMSGs to msgs with length allowed by ircd",
+ changed => "Fri Jan 25 07:18:48 CET 2002"
+);
+
+sub sig_command_msg {
+ my ($cmd, $server, $winitem, $TEST) = @_;
+ my ($target, $data) = $cmd =~ /^(\S*)\s(.*)/;
+ my $maxlength = Irssi::settings_get_int('splitlong_max_length');
+
+ if ($maxlength == 0) {
+ # 497 = 510 - length(":" . "!" . " PRIVMSG " . " :");
+ $maxlength = 497 - length($server->{nick} . $server->{userhost} . $target);
+ }
+ my $maxlength2 = $maxlength + length("... ");
+
+ if (length($data) > ($maxlength)) {
+ my @spltarr;
+
+ while (length($data) > ($maxlength2)) {
+ my $pos = rindex($data, " ", $maxlength2);
+ push @spltarr, substr($data, 0, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos) . " ...";
+
+ $data = "... " . substr($data, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos+1);
+ }
+
+ push @spltarr, $data;
+ foreach (@spltarr) {
+ Irssi::signal_emit("command msg", "$target $_", $server, $winitem);
+ }
+ Irssi::signal_stop();
+ }
+}
+
+Irssi::settings_add_int('misc', 'splitlong_max_length', 0);
+
+Irssi::command_bind('msg', 'sig_command_msg');