Changeset 538a5f7 for lib/BarnOwl/Module


Ignore:
Timestamp:
Mar 25, 2010, 12:48:01 PM (14 years ago)
Author:
Nelson Elhage <nelhage@ksplice.com>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
4225627
Parents:
6249a76d
git-author:
Kevin Riggle <kevinr@free-dissociation.com> (03/07/10 01:52:58)
git-committer:
Nelson Elhage <nelhage@ksplice.com> (03/25/10 12:48:01)
Message:
convert a single newline into a single space in outgoing tweets

Signed-off-by: Kevin Riggle <kevinr@free-dissociation.com>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter/Handle.pm

    rbdb7c26 r538a5f7  
    281281}
    282282
     283sub _stripnl {
     284    my $msg = shift;
     285
     286    # strip non-newline whitespace around newlines
     287    $msg =~ s/[^\n\S]*(\n+)[^\n\S]*/$1/sg;
     288    # change single newlines to a single space; leave multiple newlines
     289    $msg =~ s/([^\n])\n([^\n])/$1 $2/sg;
     290    # strip leading and trailing whitespace
     291    $msg =~ s/\s+$//s;
     292    $msg =~ s/^\s+//s;
     293
     294    return $msg;
     295}
     296
    283297sub twitter {
    284298    my $self = shift;
    285299
    286     my $msg = shift;
     300    my $msg = _stripnl(shift);
    287301    my $reply_to = shift;
    288302
     
    305319
    306320    my $who = shift;
    307     my $msg = shift;
     321    my $msg = _stripnl(shift);
     322
    308323    if(defined $self->{twitter}) {
    309324        $self->twitter_command('new_direct_message', {
Note: See TracChangeset for help on using the changeset viewer.