blob: 572df872f84e5a07d6cb07f778ba4ba986febdb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# Nickmix - Perturbates given nick (or just a word) in certain way.
#
# $Id: nickmix.pl,v 1.2 2002/02/09 22:13:12 pasky Exp pasky $
use strict;
use vars qw ($VERSION %IRSSI $rcsid);
$rcsid = '$Id: nickmix.pl,v 1.2 2002/02/09 22:13:12 pasky Exp pasky $';
($VERSION) = '$Revision: 1.2 $' =~ / (\d+\.\d+) /;
%IRSSI = (
name => 'nickmix',
authors => 'Petr Baudis',
contact => 'pasky@ji.cz',
url => 'http://pasky.ji.cz/~pasky/dev/irssi/',
license => 'GPLv2, not later',
description => 'Perturbates given nick (or just a word) in certain way.'
);
use Irssi;
use Irssi::Irc;
sub cmd_nickmix {
my ($data) = @_;
my %letters; # letters hash - value is count of letters
my $vstr; # vowels string
my $str; # resulting string
# First load the whole thing into letters hash
map { $letters{$_}++; } split(//, $data);
# Now take the (most of/all) vowels away and compose string from them
foreach (qw(a e i o u y)) {
my $c = int rand($letters{$_} * 4 + 1);
$c = $letters{$_} if ($c > $letters{$_});
$letters{$_} -= $c;
for (; $c; $c--) {
# Either add or prepend
if (rand(2) < 1) {
$vstr .= $_;
} else {
$vstr = $_ . $vstr;
}
}
}
# Position of the $vstr..
my $vpos = int rand (3);
$str = $vstr if (not $vpos);
# Now take the rest and do the same ;)
foreach (keys %letters) { for (; $letters{$_}; $letters{$_}--) {
# Either add or prepend
if (rand(2) < 1) {
$str .= $_;
} else {
$str = $_ . $str;
}
} }
if ($vpos == 1) { $str .= $vstr; } elsif ($vpos == 2) { $str = $vstr . $str; }
Irssi::print "$data -> $str";
}
Irssi::command_bind("nickmix", "cmd_nickmix");
Irssi::print("Nickmix $VERSION loaded...");
|