forked from dagbrown/flooterbuck
/
Update.pl
217 lines (200 loc) · 7.49 KB
/
Update.pl
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# infobot :: Kevin Lenzo (c) 1997
sub update {
my ( $lhs, $verb, $rhs ) = @_;
my ($reply) = $lhs;
$lhs =~ s/^\s*=?//; # handle dcc =oznoid and stuff
$lhs =~ s/^i (heard|think) //i;
$lhs =~ s/^some(one|1|body) said //i;
$lhs =~ s/ +/ /g;
# this really needs cleaning up
if ( $verb eq "is" ) {
$also = ( $rhs =~ s/^also //i );
my $also_or = ( $also and $rhs =~ s/\s*\|\s*// );
if ( $exists = &get( "is", $lhs ) ) {
chomp $exists;
if ( $exists eq $rhs and not $main::googling ) {
if ( $msgType =~ /public/ ) {
&performSay("i already had it that way, $who.");
} else {
&msg( $who, "it already was $rhs" );
}
return 'NOREPLY';
}
$skipReply = 0;
if ($also) {
if ($also_or) {
$rhs = $exists . '|' . $rhs;
} else {
if ( $exists ne $rhs ) {
$rhs = $exists . ' or ' . $rhs;
}
}
if ( length($rhs) > getparam('maxDataSize') ) {
if ( $msgType =~ /public/ ) {
if ($addressed) {
if ( rand() > 0.5 ) {
&performSay(
"that is too long, " . $who );
} else {
&performSay(
"i'm sorry, but that's too long, $who"
);
}
}
} else {
&msg( $who, "The text is too long" );
}
return 'NOREPLY';
}
if ( $msgType =~ /public/ ) {
&performSay("okay, $who.");
} else {
&msg( $who, "okay." );
}
$updateCount++;
&status(
"update: <$who> \'$lhs =is=> $rhs\'; was \'$exists\'"
);
&set( "is", $lhs, $rhs );
} else { # not "also"
if ( ( $correction_plausible == 0 )
&& ( $exists ne $rhs ) )
{
if ($addressed) {
if ( not $main::googling ) {
if ( $msgType =~ /public/ ) {
&performSay(
"...but $lhs is $exists...");
} else {
&msg( $who,
"...but $lhs is $exists.." );
}
&status(
"FAILED update: <$who> \'$lhs =$verb=> $rhs\'"
);
}
} else {
&status(
"FAILED update: <$who> \'$lhs =$verb=> $rhs\' (not addressed, no reply)"
);
# we were not addressed, so just
# ignore it.
return 'NOREPLY';
}
} else {
if ( IsFlag("m") ne "m" ) {
performReply(
"You have no access to change factoids");
return 'NOREPLY';
}
if ( $msgType =~ /public/ ) {
&performSay("okay, $who.");
} else {
&msg( $who, "okay." );
}
$updateCount++;
&status(
"update: <$who> '$lhs =is=> $rhs\'; was \'$exists\'"
);
&set( "is", $lhs, $rhs );
}
}
$reply = 'NOREPLY';
} else {
&status("enter: <$who> $lhs =$verb=> $rhs");
$updateCount++;
$factoidCount++;
if ( $factoidCount == 31337 ) { # particular count
$mySaveChannel = &channel();
&say(
"That would be factoid $factoidCount given on $mySaveChannel by $who."
);
&status(
"FACTOID NUMBER $factoidCount on channel $mySaveChannel by $who."
);
&say("woohoo!");
&channel($mySaveChannel);
}
&set( "is", $lhs, $rhs );
$is{"theCount"}++;
}
} else { # 'is' failed
if ( $verb eq "are" ) {
$also = ( $rhs =~ s/^also //i );
if ( $exists = &get( "are", $lhs ) ) {
if ($also) {
if ( $exists ne $rhs ) {
$rhs = $exists . ' or ' . $rhs;
}
if ( $msgType =~ /public/ ) {
&performSay("okay, $who.")
unless $rhs eq $exists;
} else {
&msg( $who, "okay." );
}
$updateCount++;
&status(
"update: <$who> \'$lhs =are=> $rhs\'; was \'$exists\'"
);
&set( "are", $lhs, $rhs );
} else { # not 'also'
if ( ( $correction_plausible == 0 )
&& ( $exists ne $rhs ) )
{
if ($addressed) {
&status(
"FAILED update: \'$lhs =$verb=> $rhs\'"
);
if ( $msgType =~ /public/ ) {
&performSay(
"...but $lhs is $exists...");
} else {
&msg( $who,
"...but $lhs is $exists.." );
}
} else {
&status(
"FAILED update: $lhs $verb $rhs (not addressed, no reply)"
);
# we were not addressed, so just
# ignore it.
return 'NOREPLY';
}
if ( $msgType =~ /public/ ) {
&performSay("...but $lhs are $exists...");
} else {
&msg( $who, "...but $lhs are $exists..." );
}
} else {
if ( $msgType =~ /public/ ) {
&performSay("okay, $who.")
unless $rhs eq $exists;
} else {
&msg( $who, "okay." )
unless grep $_ eq $who, split /\s+/,
$param{friendlyBots};
}
$updateCount++;
&status(
"update: <$who> \'$lhs =are=> $rhs\'; was \'$exists\'"
);
&set( "are", $lhs, $rhs );
}
$reply = 'NOREPLY';
}
} else {
&status("enter: <$who> $lhs =are=> $rhs");
$updateCount++;
&set( "are", $lhs, $rhs );
$are{"theCount"}++;
}
}
}
$lhs .= " $verb $rhs";
if ( $reply ne 'NOREPLY' ) {
$reply = $lhs;
}
return $reply;
}
# ---
1;