Changeset 4bd9327 for lib/BarnOwl
- Timestamp:
- Aug 4, 2009, 2:38:06 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- 8462b38
- Parents:
- 513da71
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/BarnOwl/Module/Twitter.pm
r513da71 r4bd9327 187 187 } 188 188 189 sub twitter_direct { 190 my $account = shift; 191 192 my $sent = 0; 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 193 195 if (defined $account) { 194 196 my $handle = find_account($account); 195 $ handle->twitter_direct(@_);197 $lambda->($handle, @_); 196 198 } elsif (defined $default_handle) { 197 $ default_handle->twitter_direct(@_);199 $lambda->($default_handle, @_); 198 200 } 199 201 else { 200 $twitter_handles[0]->twitter_direct(@_); 201 } 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, @_); 202 209 } 203 210 204 211 sub twitter_atreply { 205 212 my $account = shift; 206 207 my $sent = 0; 208 if (defined $account) { 209 my $handle = find_account($account); 210 $handle->twitter_atreply(@_); 211 } 212 elsif (defined $default_handle) { 213 $default_handle->twitter_atreply(@_); 214 } 215 else { 216 $twitter_handles[0]->twitter_atreply(@_); 217 } 213 do_for_default_account( sub { my $handle = shift; $handle->twitter_atreply(@_); }, $account, @_); 218 214 } 219 215 220 216 sub twitter_follow { 221 217 my $account = shift; 222 223 if (defined $account) { 224 my $handle = find_account($account); 225 $handle->twitter_follow(@_); 226 } elsif (defined $default_handle) { 227 $default_handle->twitter_follow(@_); 228 } 229 else { 230 $twitter_handles[0]->twitter_follow(@_); 231 } 218 do_for_default_account( sub { my $handle = shift; $handle->twitter_follow(@_); }, $account, @_); 232 219 } 233 220 234 221 sub twitter_unfollow { 235 222 my $account = shift; 236 237 if (defined $account) { 238 my $handle = find_account($account); 239 $handle->twitter_unfollow(@_); 240 } elsif (defined $default_handle) { 241 $default_handle->twitter_unfollow(@_); 242 } 243 else { 244 $twitter_handles[0]->twitter_unfollow(@_); 245 } 223 do_for_default_account( sub { my $handle = shift; $handle->twitter_unfollow(@_); }, $account, @_); 246 224 } 247 225
Note: See TracChangeset
for help on using the changeset viewer.