1# DESCRIPTION 2# Displays incoming ISDN calls to active window 3# Looks even nicer with entries in 4# /etc/isdn/callerid.conf - see callerid.conf(5) 5# 6# CHANGELOG 7# 17.06.04 8# Script now runs for several days without any 9# problems. Added documentation. 10 11use strict; 12use Irssi; 13use vars qw($VERSION %IRSSI); 14$VERSION = "0.3"; 15%IRSSI = ( 16 authors => "Uli Baumann", 17 contact => "f-zappa\@irc-muenster.de", 18 name => "isdn", 19 description => "Displays incoming ISDN calls", 20 license => "GPL", 21 changed => "Thu Jun 17 12:49:55 CEST 2004", 22); 23 24my $timer; 25 26sub incoming_call() # triggered by a timer; use of input_add 27 { # caused crash 28 while (my $message = <ISDNLOG>) 29 { 30 chomp($message); 31 if ($message =~ / Call to tei .* RING/) # just incoming calls 32 { 33 my $from = $message; # extract caller 34 $from =~ s/.*Call to tei.*from (.*) on.*RING.*/$1/; 35 my $to = $message; # extract callee 36 $to =~ s/.*Call to tei.*from .* on (.*) RING.*/$1/; 37 my $window = Irssi::active_win(); # write message to active win 38 $window->print("%YISDN:%n call from $from"); 39 $window->print(" to $to"); 40 } 41 } 42 } 43 44sub isdn_unload() # for a clean unload 45 { 46 close ISDNLOG; 47 Irssi::timeout_remove($timer); 48 } 49 50# when starting, open the isdnlog file and set pointer to eof 51open ISDNLOG, "< /var/log/isdn/isdnlog" or die "Can't open isdnlog"; 52seek ISDNLOG,0,2; 53# install timeout for the incoming_call subroutine 54$timer=Irssi::timeout_add(1000, \&incoming_call, \&args); 55 56# disable timer and close file when script gets unloaded 57Irssi::signal_add_first('command script unload','isdn_unload'); 58 59