зеркало из https://github.com/mozilla/pjs.git
110 строки
5.0 KiB
Plaintext
110 строки
5.0 KiB
Plaintext
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
|
|
################################
|
|
# KookBot Module #
|
|
################################
|
|
#
|
|
# Based on kookbot.pl by Keunwoo Lee
|
|
# http://www.cs.washington.edu/homes/klee/misc/kookbot.html
|
|
#
|
|
# Whacked by Axel Hecht <axel@pike.org>
|
|
|
|
package BotModules::KookBot;
|
|
use vars qw(@ISA);
|
|
@ISA = qw(BotModules);
|
|
1;
|
|
|
|
sub Help {
|
|
my $self = shift;
|
|
my ($event) = @_;
|
|
return {
|
|
'' => 'This is the KookBot module. See http://www.cs.washington.edu/homes/klee/misc/kookbot.html for details',
|
|
'kook' => 'Requests that the bot kook around.',
|
|
};
|
|
}
|
|
|
|
# RegisterConfig - Called when initialised, should call registerVariables
|
|
sub RegisterConfig {
|
|
my $self = shift;
|
|
$self->SUPER::RegisterConfig(@_);
|
|
$self->registerVariables(
|
|
# [ name, save?, settable? ]
|
|
['sentences', 1, 1, 1], # how many sentences to say each time
|
|
['good-adjectives', 1, 1, ['intelligent', 'open-minded', 'honest', 'clear', 'practical', 'flexible yet critical', 'harmonious', 'truthful', 'well-constructed', ]],
|
|
['good-nouns', 1, 1, ['freedom', 'justice', 'straightforwardness', 'subtlety', 'strength', 'compassion', 'fairness', 'rational approach', 'democracy', 'realism', ]],
|
|
['bad-adjectives', 1, 1, ['orthodox', 'malignant', 'malevolent', 'dangerous', 'fascist', 'foolish', 'closed-minded', 'annoying', 'unjust', 'long-winded', 'lacking in support', 'shameful', ]],
|
|
['bad-nouns', 1, 1, ['oppression', 'tyranny', 'stupidity', 'ignorance', 'discrimination', 'indifference', 'propaganda', 'prejudice', ]],
|
|
['tactics-agree', 1, 1, ['apply principles of', 'embrace', 'think along the same lines as', 'commune with the spirit of', 'would prefer', 'argue strenuously for', 'try to posit', 'show the validity in', ]],
|
|
['tactics-object', 1, 1, ['object to', 'reject anything involved with', 'refuse to accept', 'do not agree with', 'argue strenuously against', 'completely disagree with', 'rebut', ]],
|
|
['productions', 1, 1, [
|
|
# OK, so here's the key:
|
|
# \0 = good_adjective
|
|
# \1 = good_noun
|
|
# \2 = bad_adjective
|
|
# \3 = bad_noun
|
|
# \4 = tactics_agree
|
|
# \5 = tactics_object
|
|
'You \4 the \2 \3 to \1.',
|
|
'True \0 \1 proceeds from examining \1, not \3.',
|
|
'One must consider \1 versus \3.',
|
|
'I can only imagine that you \4 \3.',
|
|
'You \4 \2 \3. I \5 that.',
|
|
'The argument you \4 would result in \3.',
|
|
'Think about the \3, \2 and \2, and how it compares with \0 \1.',
|
|
'I ask you to be \0, not \2. You \5 any appearance of \1.',
|
|
'Is this \0? I think it is obvious that your statement is \2 and \2.',
|
|
'But there is a \0 \1, and your argument would \5 it.',
|
|
'Can there be any doubt? I \4 \0, \0 \1, and you obviously do not.',
|
|
'You \5 the fact that your evidence is shallow, the result of \2 propaganda and \3.',
|
|
'Yet your argument tries to \5 everything that is \0.',
|
|
'It is only the \0 evidence that you \5, and it is because you \5 \1.',
|
|
'I \5 your arguments only. There is no personal attack here.',
|
|
]],
|
|
);
|
|
}
|
|
|
|
sub Told {
|
|
my $self = shift;
|
|
my ($event, $message) = @_;
|
|
my $dokook = undef;
|
|
if ((($event->{'level'} == 1) and ($self->isAdmin($event))) or
|
|
(($event->{'level'} == 3) and ($event->{'God_channel_rights'}) and
|
|
($event->{'KookBot_channel'} eq $event->{'God_channel'}))) {
|
|
if ($message =~ /^\s*kook\s+(\S+)\s*$/osi) {
|
|
$dokook = $1;
|
|
}
|
|
}
|
|
if (($message =~ /^\s*kook\s*$/osi) or defined($dokook)) {
|
|
my @output;
|
|
for (my $i = 0; $i < $self->{'sentences'}; $i++) {
|
|
my $line = $self->rand_idx('productions');
|
|
$line =~ s/\\0/$self->rand_idx('good-adjectives')/goe;
|
|
$line =~ s/\\1/$self->rand_idx('good-nouns')/goe;
|
|
$line =~ s/\\2/$self->rand_idx('bad-adjectives')/goe;
|
|
$line =~ s/\\3/$self->rand_idx('bad-nouns')/goe;
|
|
$line =~ s/\\4/$self->rand_idx('tactics-agree')/goe;
|
|
$line =~ s/\\5/$self->rand_idx('tactics-object')/goe;
|
|
push(@output, $line);
|
|
}
|
|
local $event->{'target'} = $event->{'target'};
|
|
if (defined($dokook)) {
|
|
$event->{'target'} = $dokook;
|
|
}
|
|
local $" = ' ';
|
|
$self->say($event, "@output");
|
|
} else {
|
|
if (($event->{'level'} == 1) and ($message =~ /^\s*kook\s+(\S+)\s*$/osi)) {
|
|
$event->{'God_channel'} = lc($1);
|
|
$event->{'KookBot_channel'} = lc($1);
|
|
}
|
|
my $result = $self->SUPER::Told(@_);
|
|
return $result < (3 * defined($event->{'KookBot_channel'})) ? 3 : $result;
|
|
}
|
|
return 0; # we've dealt with it, no need to do anything else.
|
|
}
|
|
|
|
sub rand_idx {
|
|
my $self = shift;
|
|
my($array) = @_;
|
|
return $self->{$array}->[int(rand(@{$self->{$array}}))];
|
|
}
|