Acme-Laugh

 view release on metacpan or  search on metacpan

eg/xchat-laugh.pl  view on Meta::CPAN

#!/usr/bin/perl
#
# For use with XChat supporting Perl extension. Just install Acme::Laugh
# and put this into your $HOME/.xchat2 directory.
#
# It will add a /laugh command that supports the following variants:
#
# /laugh                # just generate a random laugh
# /laugh 50             # use 50 chunks of laugh, real length varies
# /laugh somenick       # laugh at somenick
# /laugh somenick 50    # a combination of the two
#
use strict;
use Acme::Laugh qw(laugh);

Xchat::register("laugh", "1.1", "", "");
Xchat::print ("laugh 1.1 loaded.");
Xchat::print ("Usage /laugh [<nick>] [length]");
Xchat::hook_command ("laugh", sub {
	my ($command, $nick, $chunks) = @{$_[0]};
   if ($nick =~ /\A \d+ \z/xms) {
      $chunks = $nick;
      $nick = '';
   }
   elsif ($nick) {
      $nick .= ': ';
   }
   $chunks = 17 unless $chunks > 0;

lib/Acme/Laugh.pm  view on Meta::CPAN


Have you ever needed to generate a laugh? I had: in IRC, to laugh at
other people (for fun!). So, here we are!

=head1 INTERFACE 

This module lets you export the C<laugh> function:

=over

=item my $l = laugh( $length ); 

=item my $l = laugh();  # Random length

This function accepts an optional $length parameter, which lets you trim
the length of the generated laugh. This length has little to do with the
actual string length (which you can trim later, if you want), but higher
values generate longer laughs in average. Ok, peruse the code to see it!

=back


=head1 DEPENDENCIES

=for l'autore, da riempire:
   Una lista di tutti gli altri moduli su cui si basa questo modulo,
   incluse eventuali restrizioni sulle relative versioni, ed una

t/00.load.t  view on Meta::CPAN

use Test::More tests => 2;

BEGIN {
use_ok( 'Acme::Laugh' );
}

diag( "Testing Acme::Laugh $Acme::Laugh::VERSION" );

my $laugh = Acme::Laugh::laugh(10);
ok(length($laugh) > 10, "laugh length more or less correct");
diag( $laugh );

t/01.laugh.t  view on Meta::CPAN

use Test::More tests => 1;

use Acme::Laugh qw( laugh );

diag( "Testing Acme::Laugh $Acme::Laugh::VERSION" );

my $laugh = laugh(10);
ok(length($laugh) > 10, "laugh length more or less correct");
diag( $laugh );



( run in 0.581 second using v1.01-cache-2.11-cpan-65fba6d93b7 )