Fixed merge conflicts
This commit is contained in:
parent
5b3598ef16
commit
4912c49c49
33
Butts.pm
33
Butts.pm
|
@ -335,6 +335,31 @@ C<$self-E<gt>meme>.
|
|||
return @words;
|
||||
}
|
||||
|
||||
sub _find_repeating_vowel {
|
||||
my ($self, $word) = @_;
|
||||
my $vowels = "aeiouAEIOU";
|
||||
|
||||
my $j = 0;
|
||||
my $j_record = 0;
|
||||
my $k_record = 0;
|
||||
while ($j < length($word)) {
|
||||
if (index($vowels, substr($word,$j,1)) > -1) {
|
||||
# $word[$j] is a vowel; how many times does it repeat?
|
||||
my $k = 0;
|
||||
do {
|
||||
++$k;
|
||||
} while (($j + $k < length($word)) && (substr($word,$j+$k,1) eq substr($word,$j,1)));
|
||||
# save the vowel that repeats most
|
||||
if ($k > $k_record) {
|
||||
$j_record = $j;
|
||||
$k_record = $k;
|
||||
}
|
||||
}
|
||||
++$j;
|
||||
}
|
||||
return ($j_record, $k_record);
|
||||
}
|
||||
|
||||
sub _buttsub {
|
||||
my ($self, $word) = @_;
|
||||
|
||||
|
@ -370,6 +395,14 @@ C<$self-E<gt>meme>.
|
|||
$butt = ucfirst($meme);
|
||||
}
|
||||
|
||||
my ($j, $k) = $self->_find_repeating_vowel($sub);
|
||||
|
||||
if ($k > 2) {
|
||||
my $k2;
|
||||
($j, $k2) = $self->_find_repeating_vowel($butt);
|
||||
substr($butt, $j, 1) = substr($butt, $j, 1) x $k;
|
||||
}
|
||||
|
||||
substr($actual_word, $l, $r) = $butt;
|
||||
return $lp . $actual_word . $rp;
|
||||
}
|
||||
|
|
15
buttbot.pl
15
buttbot.pl
|
@ -424,13 +424,18 @@ sub buttify_message {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($reply_as_emote) {
|
||||
$self->emote(channel => $where, who => $who,
|
||||
body => $butt_msg, address => 0);
|
||||
unless ($butt_msg eq $meme) {
|
||||
if ($reply_as_emote) {
|
||||
$self->emote(channel => $where, who => $who,
|
||||
body => $butt_msg, address => 0);
|
||||
} else {
|
||||
$self->say(channel => $where, who => $who,
|
||||
body => $butt_msg, address => $prefix_addressee);
|
||||
}
|
||||
} else {
|
||||
$self->say(channel => $where, who => $who,
|
||||
body => $butt_msg, address => $prefix_addressee);
|
||||
$self->log("BUTT: butting resulted in \"butt\" and discarded.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue