1 # -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
2 ################################
4 ################################
6 # Based on kookbot.pl by Keunwoo Lee
7 # http://www.cs.washington.edu/homes/klee/misc/kookbot.html
9 # Whacked by Axel Hecht <axel@pike.org>
11 package BotModules::KookBot;
13 @ISA = qw(BotModules);
20 '' => 'This is the KookBot module. See http://www.cs.washington.edu/homes/klee/misc/kookbot.html for details',
21 'kook' => 'Requests that the bot kook around.',
25 # RegisterConfig - Called when initialised, should call registerVariables
28 $self->SUPER::RegisterConfig(@_);
29 $self->registerVariables(
30 # [ name, save?, settable? ]
31 ['sentences', 1, 1, 1], # how many sentences to say each time
32 ['good-adjectives', 1, 1, ['intelligent', 'open-minded', 'honest', 'clear', 'practical', 'flexible yet critical', 'harmonious', 'truthful', 'well-constructed', ]],
33 ['good-nouns', 1, 1, ['freedom', 'justice', 'straightforwardness', 'subtlety', 'strength', 'compassion', 'fairness', 'rational approach', 'democracy', 'realism', ]],
34 ['bad-adjectives', 1, 1, ['orthodox', 'malignant', 'malevolent', 'dangerous', 'fascist', 'foolish', 'closed-minded', 'annoying', 'unjust', 'long-winded', 'lacking in support', 'shameful', ]],
35 ['bad-nouns', 1, 1, ['oppression', 'tyranny', 'stupidity', 'ignorance', 'discrimination', 'indifference', 'propaganda', 'prejudice', ]],
36 ['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', ]],
37 ['tactics-object', 1, 1, ['object to', 'reject anything involved with', 'refuse to accept', 'argue strenuously against', 'completely disagree with', 'rebut', 'take issue with']],
38 ['productions', 1, 1, [
39 # OK, so here's the key:
46 'You \4 the \2 \3 to \1.',
47 'True \0 \1 proceeds from examining \1, not \3.',
48 'One must consider \1 versus \3.',
49 'I can only imagine that you \4 \3.',
50 'You \4 \2 \3. I \5 that.',
51 'The argument you \4 would result in \3.',
52 'Think about the \3, \2 and \2, and how it compares with \0 \1.',
53 'I ask you to be \0, not \2. You \5 any appearance of \1.',
54 'Is this \0? I think it is obvious that your statement is \2 and \2.',
55 'But there is a \0 \1, and your argument would \5 it.',
56 'Can there be any doubt? I \4 \0, \0 \1, and you obviously do not.',
57 'You \5 the fact that your evidence is shallow, the result of \2 propaganda and \3.',
58 'Yet your argument tries to \5 everything that is \0.',
59 'It is only the \0 evidence that you \5, and it is because you \5 \1.',
60 'I \5 your arguments only. There is no personal attack here.',
67 my ($event, $message) = @_;
69 if ((($event->{'level'} == 1) and ($self->isAdmin($event))) or
70 (($event->{'level'} == 3) and ($event->{'God_channel_rights'}) and
71 ($event->{'KookBot_channel'} eq $event->{'God_channel'}))) {
72 if ($message =~ /^\s*kook\s+(\S+)\s*$/osi) {
76 if (($message =~ /^\s*kook\s*$/osi) or defined($dokook)) {
78 for (my $i = 0; $i < $self->{'sentences'}; $i++) {
79 my $line = $self->rand_idx('productions');
80 $line =~ s/\\0/$self->rand_idx('good-adjectives')/goe;
81 $line =~ s/\\1/$self->rand_idx('good-nouns')/goe;
82 $line =~ s/\\2/$self->rand_idx('bad-adjectives')/goe;
83 $line =~ s/\\3/$self->rand_idx('bad-nouns')/goe;
84 $line =~ s/\\4/$self->rand_idx('tactics-agree')/goe;
85 $line =~ s/\\5/$self->rand_idx('tactics-object')/goe;
88 local $event->{'target'} = $event->{'target'};
89 if (defined($dokook)) {
90 $event->{'target'} = $dokook;
93 $self->say($event, "@output");
95 if (($event->{'level'} == 1) and ($message =~ /^\s*kook\s+(\S+)\s*$/osi)) {
96 $event->{'God_channel'} = lc($1);
97 $event->{'KookBot_channel'} = lc($1);
99 my $result = $self->SUPER::Told(@_);
100 return $result < (3 * defined($event->{'KookBot_channel'})) ? 3 : $result;
102 return 0; # we've dealt with it, no need to do anything else.
108 return $self->{$array}->[int(rand(@{$self->{$array}}))];