Configurable meme.
This commit is contained in:
parent
7241de6ab8
commit
522a1cb8d3
13
Butts.pm
13
Butts.pm
|
@ -27,6 +27,7 @@ if (-f STOPWORDS && -r STOPWORDS) {
|
|||
}
|
||||
|
||||
sub buttify {
|
||||
my $meme = shift;
|
||||
my @words = @_;
|
||||
my $repetitions = int(@words / 11) + 1;
|
||||
my $c = 0;
|
||||
|
@ -46,8 +47,9 @@ sub buttify {
|
|||
|
||||
my $is_word = $word !~ /^[\d\W+]+$/;
|
||||
my $is_stop = grep /\Q$word\E/i, @stopwords;
|
||||
my $is_meme = $word =~ /\Q$meme\E/i;
|
||||
|
||||
$is_word and not $is_stop;
|
||||
$is_word and not $is_stop and not $is_meme;
|
||||
} @longest;
|
||||
|
||||
print 'Words in order: ' . join(', ', map { $words[$_] } @longest) . "\n" if DEBUG;
|
||||
|
@ -62,7 +64,7 @@ sub buttify {
|
|||
for my $c (0 .. $repetitions - 1) {
|
||||
my $index = $indices[$c];
|
||||
|
||||
$words[$index] = _buttsub($words[$index]);
|
||||
$words[$index] = _buttsub($meme, $words[$index]);
|
||||
@indices = grep { $_ != $index } @indices;
|
||||
}
|
||||
|
||||
|
@ -70,6 +72,7 @@ sub buttify {
|
|||
}
|
||||
|
||||
sub _buttsub {
|
||||
my $meme = shift;
|
||||
my $word = shift;
|
||||
|
||||
# split off leading and trailing punctuation
|
||||
|
@ -90,12 +93,12 @@ sub _buttsub {
|
|||
while (substr($actual_word, $l + $r, 1) eq 't') { $r++ }
|
||||
while ($l > 0 && substr($actual_word, $l - 1, 1) eq 'b') { $l-- }
|
||||
my $sub = substr($actual_word, $l, $r);
|
||||
my $butt = 'butt';
|
||||
my $butt = lc($meme);
|
||||
|
||||
if ($sub eq uc $sub) {
|
||||
$butt = 'BUTT';
|
||||
$butt = uc($meme);
|
||||
} elsif ($sub =~/^[A-Z]/) {
|
||||
$butt = 'Butt';
|
||||
$butt = ucfirst($meme);
|
||||
}
|
||||
|
||||
substr($actual_word, $l, $r) = $butt;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#server = irc.synirc.org
|
||||
server = irc.freenode.org
|
||||
#server = irc.undernet.org
|
||||
meme = face
|
||||
setmeme = yes
|
||||
changenick = yes
|
||||
port = 6667
|
||||
nick = buttbottest
|
||||
ident = null
|
||||
|
|
32
buttbot.pl
32
buttbot.pl
|
@ -36,10 +36,14 @@ my ($previouschannel);
|
|||
my (%linestotal);
|
||||
my (%timeoflastbutting);
|
||||
|
||||
|
||||
#pre-setting frequencies
|
||||
$friendfrequency = $CONF{friendfreq} || 37;
|
||||
$normalfrequency = $CONF{normfreq} || 51;
|
||||
|
||||
#The meme.
|
||||
my $meme = $CONF{meme} || "butt";
|
||||
|
||||
#remove whitespace!
|
||||
$CONF{channel} =~ s/\s+//;
|
||||
|
||||
|
@ -151,10 +155,11 @@ sub pm_bot {
|
|||
#If the command is !butt, buttify message.
|
||||
|
||||
##if the first word in the string is equal to the password, set the user to be the admin
|
||||
if ($sub eq "!auth ".$CONF{pass}) {
|
||||
if ($sub eq "!auth" && $data[0] eq $CONF{pass}) {
|
||||
$auth=$from;
|
||||
} elsif ($sub eq "!butt" and @data >0 ) {
|
||||
my @bread_and = &buttify(@data);
|
||||
_send("PRIVMSG $to :Authed.");
|
||||
} elsif ($sub eq "!$meme" and @data >0 ) {
|
||||
my @bread_and = &buttify($meme, @data);
|
||||
# comparing lists is piss easy in python :(
|
||||
my $jam = join(" ", @data);
|
||||
my $cock = join(" ", @bread_and);
|
||||
|
@ -170,6 +175,13 @@ sub pm_bot {
|
|||
} elsif ($sub eq "!leave" and @data > 0) {
|
||||
$CONF{channel} =~ s/$data[0]//;
|
||||
_send("PART $data[0]");
|
||||
} elsif ( $sub eq "!meme" and ($CONF{setmeme} ne "no") and @data >0 ) {
|
||||
$meme = $data[0];
|
||||
_send("PRIVMSG $to :Meme changed to $meme.");
|
||||
if ($CONF{changenick} ne 'no') {
|
||||
$CONF{nick} = $meme."bot";
|
||||
_send("NICK :$CONF{nick}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +218,7 @@ sub pm_channel {
|
|||
# only butt if the command is not the only word
|
||||
if (@data > 1 && $data[1] ne "\1") {
|
||||
my $first = shift(@data);
|
||||
my @butted = &buttify(@data);
|
||||
my @butted = &buttify($meme, @data);
|
||||
unshift(@butted, $first);
|
||||
|
||||
my $jam = join(" ", @data);
|
||||
|
@ -214,20 +226,24 @@ sub pm_channel {
|
|||
_send("PRIVMSG $to :$cock") if ($jam ne $cock);
|
||||
}
|
||||
} else {
|
||||
my @bread_and = &buttify(@data);
|
||||
my @bread_and = &buttify($meme, @data);
|
||||
# comparing lists is piss easy in python :(
|
||||
my $jam = join(" ", @data);
|
||||
my $cock = join(" ", @bread_and);
|
||||
_send("PRIVMSG $to :$cock") if ($jam ne $cock);
|
||||
}
|
||||
}
|
||||
} elsif ($sub eq "!butt" and ($CONF{buttcommand} ne "no") and @data >0 ) {
|
||||
} elsif ($sub eq "!$meme" && @data >0 ) {
|
||||
if (($data[0] !~ /^!/) && ($data[0] !~ /^cout/)) {
|
||||
my @bread_and = &buttify(@data);
|
||||
my @bread_and = &buttify($meme, @data);
|
||||
# comparing lists is piss easy in python :(
|
||||
my $jam = join(" ", @data);
|
||||
my $cock = join(" ", @bread_and);
|
||||
_send("PRIVMSG $to :$cock") if ($jam ne $cock);
|
||||
if ($CONF{buttcommand} ne 'no') {
|
||||
_send("PRIVMSG $to :$cock") if ($jam ne $cock);
|
||||
} else {
|
||||
_send("PRIVMSG $sender :$cock") if ($jam ne $cock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue