diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/chanfull.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/chanfull.pl')
-rw-r--r-- | scripts/chanfull.pl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/chanfull.pl b/scripts/chanfull.pl new file mode 100644 index 0000000..f0e6d5a --- /dev/null +++ b/scripts/chanfull.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +use strict; +use vars qw($VERSION %IRSSI); + +$VERSION = "2003011700"; +%IRSSI = ( + authors => "Joern 'Wulf' Heissler", + contact => "wulf\@wulf.eu.org", + name => "chanfull", + description => "Notifies the user when some channel limit is reached", + license => "GPLv2", + url => "", + changed => "$VERSION" +); + +use Irssi; + +# draws a nice box, author is Stefan 'tommie' Tomanek +sub draw_box ($$$) { + my ($title, $text, $footer) = @_; + my $box = ''; + $box .= '%R,--[%n%9%U'.$title.'%U%9%R]%n'."\n"; + foreach (split(/\n/, $text)) { + $box .= '%R|%n '.$_."\n"; + } + $box .= '%R`--<%n'.$footer.'%R>->%n'; + return $box; +} + +sub event_message_join ($$$$) { + my ($server, $channel, $nick, $address) = @_; + my $c=Irssi::channel_find($channel); + my $users=scalar @{[$c->nicks]}; + return if($c->{limit} == 0); + my $left = $c->{limit} - $users; + if($left < 4) { + if($left<=0) { + $c->print(draw_box('warning', 'Channel is full!!', 'chanfull'), MSGLEVEL_CLIENTCRAP); + } else { + $c->print(draw_box('warning', 'Channel is nearly full! ('.$left.' client'.(($left==1)?'':'s').' left)', 'chanfull'), MSGLEVEL_CLIENTCRAP); + } + } +} + +Irssi::signal_add('message join', 'event_message_join'); + +Irssi::print '%B>>%n '.$IRSSI{name}.' '.$VERSION.' loaded.', MSGLEVEL_CLIENTCRAP; |