Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # BASED ON...
- # $Id: answering_machine.pl,v 1.2 1998/09/08 12:22:45 kas Exp $
- #
- # A simple answering machine. See the Modem::Vgetty man page for the
- # discussion of this source code.
- #
- # Copyright (c) 1998 Jan "Yenya" Kasprzak <kas@fi.muni.cz>. All rights
- # reserved. This package is free software; you can redistribute it and/or
- # modify it under the same terms as Perl itself.
- #
- # To run it: set the $voicemaster and $voicedir variables below to something
- # usable. Create the $voicedir directory. Edit the vgetty's configuration
- # file (voice.conf) so that it contains the following options:
- #
- # voice_shell /usr/bin/perl
- # call_program /some/path/answering_machine.pl
- #
- # (optional: create the welcome message using something like
- # autopvf <message.au |pvfspeed -s <speed>|pvftormd <modem_type> \
- # > $voicedir/welcome.rmd
- # where the speed and modem_type depends on your modem type - see the
- # pvftormd(1) documentation.)
- # Configure the vgetty on your modem line (in voice.conf), run it
- # (maybe from /etc/inittab) an call your modem. It should play a welcome
- # message (if you have created one), beep and record the message you
- # say to the phone.
- #
- use Modem::Vgetty;
- my $voicemaster = 'root@localhost';
- my $voicedir = '/home/zosky/voiceMail';
- my $tmout = 90;
- my $finish = 0;
- my $v = new Modem::Vgetty;
- $v->add_handler('BUSY_TONE', 'finish',
- sub { $v->stop; $finish=1; });
- $v->add_handler('SILENCE_DETECTED', 'finish',
- sub { $v->stop; $finish=1; });
- $v->add_handler('RECEIVED_DTMF', 'readnum',
- sub { my $self=shift; $self->stop; $dtmf = $_[2];
- if ($dtmf == 1) { my $usr = '/chris' }
- elsif ($dtmf == 2) { my $usr = '/marc' }
- elsif ($dtmf == 3) { my $usr = '/amira' }
- elsif ($dtmf == 4) { my $usr = '/roger' } });
- local $SIG{ALRM} = sub { $v->stop; };
- $v->enable_events;
- #### play welcome
- $v->play($voicedir.'/messages/welcome.rmd');
- $v->waitfor('READY');
- ###############
- $v->beep(100,10);
- $v->waitfor('READY');
- if ($finish == 0) {
- my $num = 0;
- $num++ while(-r "$voicedir/$usr/$num.rmd");
- $v->record("$voicedir/$usr/$num.rmd");
- alarm $tmout;
- $v->waitfor('READY');
- system "rmdtopvf $voicedir/$usr/$num.rmd" .
- "|pvfspeed -s 8000 | pvftowav" .
- "|lame -h - $voicedir/$usr/$num.mp3" ;
- # system "uuencode $voicedir/$num.mp3 $voicedir/$num.mp3" .
- # "|mail -s 'NEW.phoneMSG boolioncube\@gmail.com" ;
- system "rm $voicedir/$usr/$num.rmd" ;
- }
- exit 0;
Add Comment
Please, Sign In to add comment