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