Changeset 29398

Show
Ignore:
Timestamp:
02/02/09 00:08:40 (4 years ago)
Author:
sugyan
Message:

lang/perl/Net-Twissr: version 0.1.2, modify example/terminal.pl

Location:
lang/perl/Net-Twissr/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Net-Twissr/trunk/Changes

    r28762 r29398  
    1111 
    12120.1.0  Wed Jan 20 00:18:52 2009 
     13 
     140.1.1  Wed Jan 21 22:06:26 2009 
     15       add method "update_twitter" and "update_wassr". 
     16 
     170.1.2   
     18       add reply properties. 
  • lang/perl/Net-Twissr/trunk/README

    r28808 r29398  
    1 Net-Twissr version 0.1.1 
     1Net-Twissr version 0.1.2 
    22 
    33[ REPLACE THIS... 
  • lang/perl/Net-Twissr/trunk/example/terminal.pl

    r29099 r29398  
    3232# l: list 
    3333# r: refresh 
     34# t: post to twitter only 
     35# w: post to wassr only 
     36# p: post to twitter and wassr 
     37# P: post as reply to current selected message 
    3438# q: quit 
    35 # p: post 
    3639 
    3740my $mode = 0; 
     
    6568        &refresh_friends_timeline(\@friends_timeline); 
    6669    } 
    67     if ($ch eq 'p') { 
    68         $screen->clrscr()->at(0, 0)->puts('Message:')->at(1, 0); 
     70    if ($ch eq 'p' or $ch eq 'P' or 
     71          $ch eq 't' or $ch eq 'w') { 
     72        my $message = 'Message'; 
     73        my $option = { 
     74            twitter => 1, 
     75            wassr => 1, 
     76        }; 
     77        # reply 
     78        if ($ch eq 'P') { 
     79            my $status = $friends_timeline[$index]; 
     80            $message .= " for $status->{user_id}"; 
     81            $message .= " in $status->{service}"; 
     82            if ($status->{service} eq 'twitter') { 
     83                $option->{wassr} = 0; 
     84            } 
     85            if ($status->{service} eq 'wassr') { 
     86                $option->{twitter} = 0; 
     87            } 
     88            $option->{reply} = $status->{id}; 
     89        } 
     90        # twitter only 
     91        if ($ch eq 't') { 
     92            $message .= ' in twitter'; 
     93            $option->{wassr} = 0; 
     94        } 
     95        # wassr only 
     96        if ($ch eq 'w') { 
     97            $message .= ' in wassr'; 
     98            $option->{twitter} = 0; 
     99        } 
     100        $message .= ':'; 
     101        $screen->clrscr()->at(0, 0)->puts($message)->at(1, 0); 
     102 
    69103        my $status = <>; 
    70104        if (defined $status) { 
    71105            chomp($status); 
    72             &update($status); 
     106            &update($status, $option); 
    73107        } 
    74108    } 
     
    96130            my $row = 0; 
    97131            my $status = $timeline->[$index]; 
     132            # Twissr / Wassr 
    98133            $screen->at($row++, 0)->puts($status->{service})->clreol(); 
    99             return if ($row > $rows - 1); 
     134            # date and time 
    100135            $screen->at($row++, 0)->puts(scalar(localtime($status->{time})))->clreol(); 
    101             return if ($row > $rows - 1); 
     136            # user name 
    102137            my $user = (Jcode->new($status->{user_id} . ' / ' . $status->{user_name})->jfold($cols))[0]; 
    103138            $screen->at($row++, 0)->puts($user)->clreol(); 
    104             return if ($row > $rows - 1); 
     139            # message 
    105140            my @text = Jcode->new($status->{text})->jfold($cols - 1); 
    106141            for (0..$#text) { 
    107142                $screen->at($row++, 0)->puts($text[$_])->clreol(); 
    108                 return if ($row > $rows - 1); 
     143            } 
     144            # reply 
     145            if ($status->{reply_id}) { 
     146                $row++; 
     147                # reply to 
     148                my $reply_to = $status->{reply_to}; 
     149                $screen->at($row++, 0)->puts('reply to : ' . $reply_to)->clreol(); 
     150                # reply message 
     151                if ($status->{reply_text}) { 
     152                    my @reply_text = Jcode->new($status->{reply_text})->jfold($cols - 1); 
     153                    for (0..$#reply_text) { 
     154                        $screen->at($row++, 0)->puts($reply_text[$_])->clreol(); 
     155                    } 
     156                } 
    109157            } 
    110158        }; 
     
    137185# statusの更新 
    138186sub update { 
    139     my $status = shift; 
    140     $twissr->update($status); 
    141 } 
     187    my ($status, $option) = @_; 
     188    # multi post 
     189    if ($option->{twitter} && $option->{wassr}) { 
     190        $twissr->update($status); 
     191    } 
     192    # single post 
     193    else { 
     194        # twitter 
     195        if ($option->{twitter}) { 
     196            $twissr->update_twitter({ 
     197                status => $status, 
     198                reply => $option->{reply}, 
     199            }); 
     200        } 
     201        # wassr 
     202        if ($option->{wassr}) { 
     203            $twissr->update_wassr({ 
     204                status => $status, 
     205                reply => $option->{reply}, 
     206            }); 
     207        } 
     208    } 
     209} 
  • lang/perl/Net-Twissr/trunk/lib/Net/Twissr.pm

    r28810 r29398  
    55use Carp; 
    66 
    7 use version; our $VERSION = qv('0.1.1'); 
     7use version; our $VERSION = qv('0.1.2'); 
    88 
    99use HTTP::Date; 
     
    202202        $time =~ s/\+0000/GMT/; 
    203203        $status{time} = str2time($time); 
     204        $status{reply_id} = $data->{in_reply_to_status_id}; 
     205        $status{reply_to} = $data->{in_reply_to_screen_name}; 
    204206        push @statuses, \%status; 
    205207    } 
     
    213215        $status{user_name} = $data->{user}->{screen_name}; 
    214216        $status{time} = $data->{epoch}; 
     217        $status{reply_id} = $1 if ($data->{reply_status_url} =~ m|^.*/(.*?)$|); 
     218        $status{reply_to} = $data->{reply_user_login_id}; 
     219        $status{reply_text} = $data->{reply_message}; 
    215220        push @statuses, \%status; 
    216221    } 
     
    229234=head1 VERSION 
    230235 
    231 This document describes Net::Twissr version 0.1.1 
     236This document describes Net::Twissr version 0.1.2 
    232237 
    233238