Changeset 8462b38
- Timestamp:
- Aug 15, 2009, 2:32:16 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- 385dd69
- Parents:
- 4bd9327
- Location:
- lib/BarnOwl/Module
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/BarnOwl/Module/Twitter.pm
r4bd9327 r8462b38 171 171 } 172 172 173 sub find_account_default { 174 my $name = shift; 175 if(defined($name)) { 176 return find_account($name); 177 } else { 178 return $default_handle; 179 } 180 } 181 173 182 sub twitter { 174 183 my $account = shift; … … 187 196 } 188 197 189 # do_for_default_account( SUB( HANDLE, ARGS...), ACCOUNT, ARGS... )190 sub do_for_default_account {191 my $lambda = shift;192 die ("do_for_default_account has nothing to do") unless defined $lambda && ref($lambda) eq 'CODE';193 my $account = shift;194 195 if (defined $account) {196 my $handle = find_account($account);197 $lambda->($handle, @_);198 } elsif (defined $default_handle) {199 $lambda->($default_handle, @_);200 }201 else {202 $lambda->($twitter_handles[0], @_);203 }204 }205 206 sub twitter_direct {207 my $account = shift;208 do_for_default_account( sub { my $handle = shift; $handle->twitter_direct(@_); }, $account, @_);209 }210 211 sub twitter_atreply {212 my $account = shift;213 do_for_default_account( sub { my $handle = shift; $handle->twitter_atreply(@_); }, $account, @_);214 }215 216 sub twitter_follow {217 my $account = shift;218 do_for_default_account( sub { my $handle = shift; $handle->twitter_follow(@_); }, $account, @_);219 }220 221 sub twitter_unfollow {222 my $account = shift;223 do_for_default_account( sub { my $handle = shift; $handle->twitter_unfollow(@_); }, $account, @_);224 }225 226 198 BarnOwl::new_command(twitter => \&cmd_twitter, { 227 199 summary => 'Update Twitter from BarnOwl', … … 283 255 my $user = shift; 284 256 die("Usage: $cmd USER\n") unless $user; 285 my $account = shift; 286 BarnOwl::start_edit_win("$cmd $user" . (defined $account ? " $account" : ""), sub{twitter_direct($account, $user, shift)}); 257 my $account = find_account_default(shift); 258 BarnOwl::start_edit_win("$cmd $user " . ($account->nickname||""), 259 sub { $account->twitter_direct($user, shift) }); 287 260 } 288 261 … … 291 264 my $user = shift || die("Usage: $cmd USER [In-Reply-To ID]\n"); 292 265 my $id = shift; 293 my $account = shift; 294 BarnOwl::start_edit_win("Reply to \@" . $user . (defined $account ? " on $account" : ""), sub { twitter_atreply($account, $user, $id, shift) }); 266 my $account = find_account_default(shift); 267 268 BarnOwl::start_edit_win("Reply to \@" . $user . ($account->nickname ? (" on " . $account->nickname) : ""), 269 sub { $account->twitter_atreply($user, $id, shift) }); 295 270 } 296 271 … … 300 275 die("Usage: $cmd USER\n") unless $user; 301 276 my $account = shift; 302 twitter_follow($account,$user);277 find_account_default($account)->twitter_follow($user); 303 278 } 304 279 … … 308 283 die("Usage: $cmd USER\n") unless $user; 309 284 my $account = shift; 310 twitter_unfollow($account,$user);285 find_account_default($account)->twitter_unfollow($user); 311 286 } 312 287 -
lib/BarnOwl/Module/Twitter/Handle.pm
r513da71 r8462b38 280 280 } 281 281 282 sub nickname { 283 my $self = shift; 284 return $self->{cfg}->{account_nickname}; 285 } 286 282 287 1;
Note: See TracChangeset
for help on using the changeset viewer.