diff options
Diffstat (limited to 'jumble.pl')
-rw-r--r-- | jumble.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/jumble.pl b/jumble.pl new file mode 100644 index 0000000..79ac4fa --- /dev/null +++ b/jumble.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# script was written ages ago (probably 2008 or earlier). + +use warnings; +use strict; + +use Irssi qw/command command_bind/; + +our $VERSION = "0.1"; +our %IRSSI = ( + authors => 'Urchlay', + contact => 'Urchlay on NewNet', + name => 'jumble', + description => 'Smiultae bad tpying', + license => 'Same as Perl', + url => 'none', +); + +sub jumble { + my ($text, $srv, $chan) = @_; + my @words = split /\s+/, $text; + + for(@words) { + if(length($_) > 2) { + /(\W*\w)(\w+)(\w\W*)/; + if($2) { + my $start = $1; + my $middle = $2; + my $end = $3; + + my @letters = split "", $middle; + for(0..$#letters-1) { + ($letters[$_], $letters[$_+1]) = ($letters[$_+1], $letters[$_]) + if rand > 0.5; + } + $_ = $start . join("", @letters) . $end; + } + } + } + + $chan->command('MSG ' . $chan->{name} . ' ' . join(" ", @words)); +} + +command_bind("jumble", \&jumble); |