Guest User

Untitled

a guest
Jul 20th, 2018
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. ## Change these to match your robot's google voice account information ##
  7. my $user = 'USERNAME@gmail.com';
  8. my $pass = 'PASSWORD';
  9.  
  10. use Data::Dumper;
  11. use Email::Stuff; #for simple sending!
  12. use Email::Send;
  13. use Email::Send::Gmail;
  14. use Email::Simple::Creator;
  15. use Email::Simple; #for simple receiving!
  16. use Weather::Google;
  17.  
  18. my %command;
  19. $command{w} = 'my $gw = new Weather::Google($input);
  20. $return = $gw->current_conditions("temp_f")." F (".$gw->current_conditions("temp_c")."C)";';
  21. $command{rot13} = '$return = $input; $return =~ tr/a-zA-Z/n-za-mN-ZA-M/;';
  22.  
  23. sub generatemessage
  24. {
  25. my $input = shift;
  26. $input =~ s/^(\S+)//;
  27. my $cmd = $1;
  28. $cmd =~ tr/A-Z/a-z/;
  29. my $return;
  30. eval $command{$cmd};
  31. return $return;
  32. }
  33.  
  34. my $text;
  35. {
  36. local $/=undef;
  37. $text = <STDIN>;
  38. }
  39.  
  40. my $incoming = Email::Simple->new($text);
  41. my $replyto = $incoming->header("From"); #get where it came from
  42. my $subject = $incoming->header("Subject"); #get the subject, we'll error out if we don't see what we want
  43. my $body = $incoming->body();
  44.  
  45. #strip the signature from google!
  46. $body =~ s/--.*$//sm;
  47.  
  48. if ($replyto =~ /\<(.*)\>/) #if we've got an email address in <> then use that instead, otherwise let Email::Stuff stuff it
  49. {
  50. $replyto = $1;
  51. }
  52.  
  53. if ($subject =~ /^SMS from/) #check that its really an SMS and not something else!
  54. {
  55.  
  56. my $email = Email::Simple->create(
  57. header => [
  58. From => $user,
  59. To => $replyto,
  60. Subject => "fdsa",
  61. ],
  62. body => generatemessage($body),
  63. );
  64.  
  65. my $sender = Email::Send->new(
  66. { mailer => 'Gmail',
  67. mailer_args => [
  68. username =>
  69. $user,
  70. password => $pass,
  71. ]
  72. }
  73. );
  74. eval { $sender->send($email) };
  75. }
Add Comment
Please, Sign In to add comment