From: Andres S. <di...@us...> - 2005-02-11 20:04:39
|
Update of /cvsroot/tuxaator/tuxaator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3524 Modified Files: BotCore.pm Log Message: Wrap outgoing text instead of chopping off its head Index: BotCore.pm =================================================================== RCS file: /cvsroot/tuxaator/tuxaator/BotCore.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BotCore.pm 11 Feb 2005 20:00:07 -0000 1.10 --- BotCore.pm 11 Feb 2005 20:04:27 -0000 1.11 *************** *** 8,11 **** --- 8,12 ---- use DBI; use Data::Dumper; + use Text::Wrapper; use vars qw(@ISA); @ISA = qw(Net::IRC); *************** *** 145,160 **** sub queue { my $class = shift; ! my $event = shift; # copy of the event object for further processing ! my $msg = shift; # what to send ! my $type = shift; # what method to use to send data (right now "emote" triggers "me" ! # instead of privmsg ! my $rec = {}; ! my $to = @{$event->to}[0]; ! #my $target = (substr($to,0,1) eq "#") ? $class->{'config'}->{'channel'} : $event->{'nick'}; ! my $target = (substr($to,0,1) eq "#") ? $to : $event->{'nick'}; ! $rec->{'target'} = $target; ! $rec->{'msg'} = $msg; ! push @{$class->{'queue'}},$rec; ! $class->{'queued'}++; }; --- 146,165 ---- sub queue { my $class = shift; ! my $event = shift; # copy of the event object for further processing ! my $msg = shift; # what to send ! my $type = shift; # what method to use to send data (right now "emote" triggers "me" ! # instead of privmsg ! # Wrap the text into lines of no more than 400 characters each ! my $wrapper = new Text::Wrapper(columns => 400); ! for my $line (split /\n/, $wrapper->wrap($msg)) { ! my $rec = {}; ! my $to = @{$event->to}[0]; ! #my $target = (substr($to,0,1) eq "#") ? $class->{'config'}->{'channel'} : $event->{'nick'}; ! my $target = (substr($to,0,1) eq "#") ? $to : $event->{'nick'}; ! $rec->{'target'} = $target; ! $rec->{'msg'} = $line; ! push @{$class->{'queue'}},$rec; ! $class->{'queued'}++; ! } }; |