Changeset 118d800
- Timestamp:
- Oct 29, 2009, 10:19:55 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- c78d06f
- Parents:
- 7ec65f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/BarnOwl/Module/Twitter/Handle.pm
r7ec65f5 r118d800 93 93 94 94 return $self; 95 } 96 97 =head2 twitter_command COMMAND ARGS... 98 99 Call the specified method on $self->{twitter} with an extended 100 timeout. This is intended for interactive commands, with the theory 101 that if the user explicitly requested an action, it is slightly more 102 acceptable to hang the UI for a second or two than to fail just 103 because Twitter is being slightly slow. Polling commands should be 104 called normally, with the default (short) timeout, to prevent 105 background Twitter suckage from hosing the UI normally. 106 107 =cut 108 109 sub twitter_command { 110 my $self = shift; 111 my $cmd = shift; 112 113 eval { $self->{twitter}->{ua}->timeout(5); }; 114 my $result = eval { 115 $self->{twitter}->$cmd(@_); 116 }; 117 my $error = $@; 118 eval { $self->{twitter}->{ua}->timeout(1); }; 119 if ($error) { 120 die($error); 121 } 122 return $result; 95 123 } 96 124 … … 218 246 die("Twitter: Message over 140 characters long.\n"); 219 247 } 220 if(defined($reply_to)) { 221 $self->{twitter}->update({ 222 status => $msg, 223 in_reply_to_status_id => $reply_to 224 }); 225 } else { 226 $self->{twitter}->update($msg); 227 } 248 $self->twitter_command('update', { 249 status => $msg, 250 defined($reply_to) ? (in_reply_to_status_id => $reply_to) : () 251 }); 228 252 } 229 253 } … … 235 259 my $msg = shift; 236 260 if(defined $self->{twitter}) { 237 $self-> {twitter}->new_direct_message({261 $self->twitter_command('new_direct_message', { 238 262 user => $who, 239 263 text => $msg … … 272 296 my $who = shift; 273 297 274 my $user = $self-> {twitter}->create_friend($who);298 my $user = $self->twitter_command('create_friend', $who); 275 299 # returns a string on error 276 300 if (defined $user && !ref $user) { … … 286 310 my $who = shift; 287 311 288 my $user = $self-> {twitter}->destroy_friend($who);312 my $user = $self->twitter_command('destroy_friend', $who); 289 313 # returns a string on error 290 314 if (defined $user && !ref $user) {
Note: See TracChangeset
for help on using the changeset viewer.