Changeset 1943

Show
Ignore:
Timestamp:
04/15/07 22:25:34
Author:
otsune
Message:

Use the plaintext method.
cut off string more than 160 characters.
string was encoded so that the multi byte was reflected.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Twitter.pm

    r1942 r1943  
    33use base qw( Plagger::Plugin ); 
    44 
     5use Encode; 
    56use Net::Twitter; 
    67 
     
    2930    my($self, $context, $args) = @_; 
    3031 
    31     my $body = ( $args->{entry}->summary || $args->{entry}->title ) . " " . $args->{entry}->permalink; 
     32    my $body = ( $args->{entry}->summary->plaintext || $args->{entry}->title ) . " " . $args->{entry}->permalink; 
     33    # TODO: FIX when Summary configurable. 
     34    if ( length($body) > 159 ) { 
     35        $body = substr($body, 0, 159); 
     36    } 
    3237    $context->log(info => "Updating Twitter status to '$body'"); 
    33     $self->{twitter}->update($body) or $context->error("Can't update twitter status"); 
     38    $self->{twitter}->update( encode_utf8($body) ) or $context->error("Can't update twitter status"); 
    3439} 
    3540