- Timestamp:
- Jan 10, 2011 6:57:45 PM (14 years ago)
- Branches:
- master, trunk
- Children:
- 24fa584
- Parents:
- 702399e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/twitter/twitterbot.pl
r702399e r45a20c3 14 14 use YAML::Tiny; 15 15 use Date::Parse qw(str2time); 16 use Mail::Sendmail; 17 use Encode; 16 18 17 19 my $_execmode = $ARGV[0] || 0; … … 52 54 if ($tweets->{$id}{type} eq 'retweet') { 53 55 DEBUG and warn "skipping $id that was already retweeted\n"; 54 $skip = $id;56 $skip = 'retweet'; 55 57 } 56 58 if (defined $conf->{allow}) { 57 $skip = $id;59 $skip = 'allow'; 58 60 foreach my $screen_name ( @{ $conf->{allow}{screen_name} } ) { 59 61 if ($tweets->{$id}{screen_name} eq $screen_name) { … … 69 71 last; 70 72 } 73 } 74 } 75 76 if (defined $conf->{mail}) { 77 my $send; 78 foreach my $pickup ( @{ $conf->{mail}{pickup} } ) { 79 if ($tweets->{$id}{type} eq $pickup) { 80 $send = 1; 81 last; 82 } 83 } 84 if ($conf->{mail}{ignore_allowed}) { 85 if (defined $conf->{allow} and ! defined $skip) { 86 # this tweet was allowed to retweet, so that be ignored on mail 87 undef $send; 88 } 89 } 90 91 if ($send) { 92 if (! exists($conf->{mail}{body}) ) { 93 $conf->{mail}{body} = 94 "[localtime(date)] http://twitter.com/<screen_name>/status/<status_id> text\n" . 95 "----------------------------------------\n" 96 ; 97 } 98 $conf->{mail}{body} .= 99 "[" . localtime($tweets->{$id}{date}) . "] " . 100 "http://twitter.com/" . 101 $tweets->{$id}{screen_name} . "/status/" . 102 $tweets->{$id}{status_id} . " " . 103 $tweets->{$id}{text} . "\n" 104 ; 71 105 } 72 106 } … … 91 125 92 126 $stat->{$tweets->{$id}{type}} = $id; 127 } 128 129 if ($conf->{mail}{body}) { 130 my $body = encode("iso-2022-jp", $conf->{mail}{body}); 131 132 my %mail = ( 133 Smtp => $conf->{mail}{server}, 134 From => $conf->{mail}{from}, 135 To => join(", ", @{ $conf->{mail}{to} }), 136 Subject => $conf->{mail}{subject}, 137 "Content-Type" => $conf->{mail}{contenttype}, 138 Body => $body, 139 ); 140 DEBUG and warn "sending mail => ", Dumper(\%mail); 141 142 DEBUG or sendmail(%mail) or warn "Error sending mail: $Mail::Sendmail::error\n"; 93 143 } 94 144
Note: See TracChangeset
for help on using the changeset viewer.