aboutsummaryrefslogtreecommitdiff
path: root/jumble.pl
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-26 17:08:34 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-26 17:08:34 -0500
commit9eed830f296dab257759f5276d0963467007aa6b (patch)
tree83d6225d248ec8d4026b514d8b9b248e6c0fce32 /jumble.pl
downloadstupid-irssi-tricks-9eed830f296dab257759f5276d0963467007aa6b.tar.gz
initial commit
Diffstat (limited to 'jumble.pl')
-rw-r--r--jumble.pl45
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);