Permalink
Browse files

Split really long messages on multiple lines

  • Loading branch information...
1 parent ee9e184 commit 19690a476a8d6584e59dbaa3ca92806016ee4db6 @abh committed Jun 9, 2010
Showing with 16 additions and 1 deletion.
  1. +16 −1 httpirc.pl
View
@@ -48,7 +48,22 @@
for my $channel (@channels) {
$con->send_srv("JOIN", $channel);
- $con->send_chan($channel, 'PRIVMSG', $channel, $msg);
+ my @msg;
+ while (length $msg > 300) {
+ $msg =~ s/^(.{300})//sm;
+ my $m = $1;
+ last unless $m;
+ $m =~ s/\n/ /smg;
+ push @msg, $m;
+ }
+ # whatever is remaining
+ push @msg, $msg;
+
+ #warn Data::Dumper->Dump([\@msg], [qw(msg)]);
+
+ for my $m (@msg) {
+ $con->send_chan($channel, 'PRIVMSG', $channel, $m);
+ }
}
my $response = {channels => \@channels, msg => $msg};

0 comments on commit 19690a4

Please sign in to comment.