Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- ## Change these to match your robot's google voice account information ##
- my $user = 'USERNAME@gmail.com';
- my $pass = 'PASSWORD';
- use Data::Dumper;
- use Email::Stuff; #for simple sending!
- use Email::Send;
- use Email::Send::Gmail;
- use Email::Simple::Creator;
- use Email::Simple; #for simple receiving!
- use Weather::Google;
- my %command;
- $command{w} = 'my $gw = new Weather::Google($input);
- $return = $gw->current_conditions("temp_f")." F (".$gw->current_conditions("temp_c")."C)";';
- $command{rot13} = '$return = $input; $return =~ tr/a-zA-Z/n-za-mN-ZA-M/;';
- sub generatemessage
- {
- my $input = shift;
- $input =~ s/^(\S+)//;
- my $cmd = $1;
- $cmd =~ tr/A-Z/a-z/;
- my $return;
- eval $command{$cmd};
- return $return;
- }
- my $text;
- {
- local $/=undef;
- $text = <STDIN>;
- }
- my $incoming = Email::Simple->new($text);
- my $replyto = $incoming->header("From"); #get where it came from
- my $subject = $incoming->header("Subject"); #get the subject, we'll error out if we don't see what we want
- my $body = $incoming->body();
- #strip the signature from google!
- $body =~ s/--.*$//sm;
- if ($replyto =~ /\<(.*)\>/) #if we've got an email address in <> then use that instead, otherwise let Email::Stuff stuff it
- {
- $replyto = $1;
- }
- if ($subject =~ /^SMS from/) #check that its really an SMS and not something else!
- {
- my $email = Email::Simple->create(
- header => [
- From => $user,
- To => $replyto,
- Subject => "fdsa",
- ],
- body => generatemessage($body),
- );
- my $sender = Email::Send->new(
- { mailer => 'Gmail',
- mailer_args => [
- username =>
- $user,
- password => $pass,
- ]
- }
- );
- eval { $sender->send($email) };
- }
Add Comment
Please, Sign In to add comment