Guest User

Untitled

a guest
Feb 19th, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.49 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. # BASED ON...
  3. # $Id: answering_machine.pl,v 1.2 1998/09/08 12:22:45 kas Exp $
  4. #
  5. # A simple answering machine. See the Modem::Vgetty man page for the
  6. # discussion of this source code.
  7. #
  8. # Copyright (c) 1998 Jan "Yenya" Kasprzak <kas@fi.muni.cz>. All rights
  9. # reserved. This package is free software; you can redistribute it and/or
  10. # modify it under the same terms as Perl itself.
  11. #
  12. # To run it: set the $voicemaster and $voicedir variables below to something
  13. # usable. Create the $voicedir directory. Edit the vgetty's configuration
  14. # file (voice.conf) so that it contains the following options:
  15. #
  16. #      voice_shell /usr/bin/perl
  17. #      call_program /some/path/answering_machine.pl
  18. #
  19. # (optional: create the welcome message using something like
  20. #      autopvf <message.au |pvfspeed -s <speed>|pvftormd <modem_type> \
  21. #             > $voicedir/welcome.rmd
  22. # where the speed and modem_type depends on your modem type - see the
  23. # pvftormd(1) documentation.)
  24. # Configure the vgetty on your modem line (in voice.conf), run it
  25. # (maybe from /etc/inittab) an call your modem. It should play a welcome
  26. # message (if you have created one), beep and record the message you
  27. # say to the phone.
  28. #
  29. use Modem::Vgetty;
  30.  
  31. my $voicemaster = 'root@localhost';
  32. my $voicedir = '/home/zosky/voiceMail';
  33. my $tmout = 90;
  34. my $finish = 0;
  35. my $v = new Modem::Vgetty;
  36. $v->add_handler('BUSY_TONE', 'finish',
  37.     sub { $v->stop; $finish=1; });
  38. $v->add_handler('SILENCE_DETECTED', 'finish',
  39.     sub { $v->stop; $finish=1; });
  40. $v->add_handler('RECEIVED_DTMF', 'readnum',
  41.         sub { my $self=shift; $self->stop; $dtmf = $_[2];
  42.           if ($dtmf == 1) { my $usr = '/chris' }
  43.            elsif ($dtmf == 2) { my $usr = '/marc'  }
  44.            elsif ($dtmf == 3) { my $usr = '/amira' }
  45.            elsif ($dtmf == 4) { my $usr = '/roger' }    });
  46. local $SIG{ALRM} = sub { $v->stop; };
  47.  
  48. $v->enable_events;
  49.  
  50. #### play welcome
  51. $v->play($voicedir.'/messages/welcome.rmd');
  52. $v->waitfor('READY');
  53.  
  54. ###############
  55. $v->beep(100,10);
  56. $v->waitfor('READY');
  57. if ($finish == 0) {
  58.     my $num = 0;
  59.     $num++ while(-r "$voicedir/$usr/$num.rmd");
  60.     $v->record("$voicedir/$usr/$num.rmd");
  61.     alarm $tmout;
  62.     $v->waitfor('READY');
  63.     system "rmdtopvf $voicedir/$usr/$num.rmd"  .
  64.            "|pvfspeed -s 8000 | pvftowav" .
  65.            "|lame -h - $voicedir/$usr/$num.mp3" ;
  66. #   system "uuencode $voicedir/$num.mp3 $voicedir/$num.mp3" .
  67. #          "|mail -s 'NEW.phoneMSG boolioncube\@gmail.com" ;
  68.     system "rm $voicedir/$usr/$num.rmd" ;
  69. }
  70.  
  71. exit 0;
Add Comment
Please, Sign In to add comment