Changeset 9bedca0


Ignore:
Timestamp:
Jul 4, 2008, 2:08:25 PM (9 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
df6d9af
Parents:
1c24c69
Message:
ttants: $@, $!, @!
Make error checking actually work
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter.pm

    rd1bb4f3 r9bedca0  
    2020use BarnOwl::Hooks;
    2121
    22 sub fail {
    23     my $msg = shift;
    24     BarnOwl::admin_message('Twitter Error', $msg);
    25     die("Twitter Error: $msg\n");
    26 }
    27 
     22my $twitter;
    2823my $user     = BarnOwl::zephyr_getsender();
    2924my ($class)  = ($user =~ /(^[^@]+)/);
    3025my $instance = "status";
    3126my $opcode   = "twitter";
     27
     28sub fail {
     29    my $msg = shift;
     30    undef $twitter;
     31    BarnOwl::admin_message('Twitter Error', $msg);
     32    die("Twitter Error: $msg\n");
     33}
    3234
    3335# Don't redefine variables if they already exist
     
    7072    $cfg = from_json($cfg);
    7173};
    72 if(@!) {
    73     fail("Unable to parse ~/.owl/twitter: @!");
     74if($@) {
     75    fail("Unable to parse ~/.owl/twitter: $@");
    7476}
    7577
    76 my $twitter  = Net::Twitter->new(username   => $cfg->{user} || $user,
    77                                  password   => $cfg->{password},
    78                                  clientname => 'BarnOwl');
     78$twitter  = Net::Twitter->new(username   => $cfg->{user} || $user,
     79                              password   => $cfg->{password},
     80                              clientname => 'BarnOwl');
    7981
    8082if(!defined($twitter->verify_credentials())) {
     
    102104sub twitter {
    103105    my $msg = shift;
    104     $twitter->update($msg);
     106    if(defined $twitter) {
     107        $twitter->update($msg);
     108    }
    105109}
    106110
Note: See TracChangeset for help on using the changeset viewer.