]> git.donarmstrong.com Git - infobot.git/blob - src/DynaConfig.pl
* Rebranding from blootbot to infobot
[infobot.git] / src / DynaConfig.pl
1 #
2 # DynaConfig.pl: Read/Write configuration files dynamically.
3 #        Author: dms
4 #       Version: v0.1 (20010120)
5 #       Created: 20010119
6 #          NOTE: Merged from User.pl
7 #
8
9 use strict;
10
11 use vars qw(%chanconf %cache %bans %channels %nuh %users %ignore
12         %talkWho %dcc %mask);
13 use vars qw($utime_userfile $ucount_userfile $utime_chanfile $who
14         $ucount_chanfile $userHandle $chan $msgType $talkchannel
15         $ident $bot_state_dir $talkWho $flag_quit $wtime_userfile
16         $wcount_userfile $wtime_chanfile $nuh $message);
17
18 #####
19 ##### USERFILE CONFIGURATION READER/WRITER
20 #####
21
22 sub readUserFile {
23     my $f = "$bot_state_dir/infobot.users";
24
25     if (! -f $f) {
26         &DEBUG("userfile not found; new fresh run detected.");
27         return;
28     }
29
30     if ( -f $f and -f "$f~") {
31         my $s1 = -s $f;
32         my $s2 = -s "$f~";
33
34         if ($s2 > $s1*3) {
35             &FIXME("rUF: backup file bigger than current file.");
36         }
37     }
38
39     if (!open IN, $f) {
40         &ERROR("Cannot read userfile ($f): $!");
41         &closeLog();
42         exit 1;
43     }
44
45     undef %users;       # clear on reload.
46     undef %bans;        # reset.
47     undef %ignore;      # reset.
48
49     my $ver = <IN>;
50     if ($ver !~ /^#v1/) {
51         &ERROR("old or invalid user file found.");
52         &closeLog();
53         exit 1; # correct?
54     }
55
56     my $nick;
57     my $type;
58     while (<IN>) {
59         chop;
60
61         next if /^$/;
62         next if /^#/;
63
64         if (/^--(\S+)[\s\t]+(.*)$/) {           # user: middle entry.
65             my ($what,$val) = ($1,$2);
66
67             if (!defined $val or $val eq '') {
68                 &WARN("$what: val == NULL.");
69                 next;
70             }
71
72             if (!defined $nick) {
73                 &WARN("DynaConfig: invalid line: $_");
74                 next;
75             }
76
77             # nice little hack.
78             if ($what eq 'HOSTS') {
79                 $users{$nick}{$what}{$val} = 1;
80             } else {
81                 $users{$nick}{$what} = $val;
82             }
83
84         } elsif (/^(\S+)$/) {                   # user: start entry.
85             $nick       = $1;
86
87         } elsif (/^::(\S+) ignore$/) {          # ignore: start entry.
88             $chan       = $1;
89             $type       = 'ignore';
90
91         } elsif (/^- (\S+):\+(\d+):\+(\d+):(\S+):(.*)$/ and $type eq 'ignore') {
92             ### ignore: middle entry.
93             my $mask = $1;
94             my(@array) = ($2,$3,$4,$5);
95             ### DEBUG purposes only!
96             if ($mask !~ /^$mask{nuh}$/) {
97                 &WARN("ignore: mask $mask is invalid.");
98                 next;
99             }
100             $ignore{$chan}{$mask} = \@array;
101
102         } elsif (/^::(\S+) bans$/) {            # bans: start entry.
103             $chan       = $1;
104             $type       = 'bans';
105
106         } elsif (/^- (\S+):\+(\d+):\+(\d+):(\d+):(\S+):(.*)$/ and $type eq 'bans') {
107             ### bans: middle entry.
108             # $btime, $atime, $count, $whoby, $reason.
109             my(@array) = ($2,$3,$4,$5,$6);
110             $bans{$chan}{$1} = \@array;
111
112         } else {                                # unknown.
113             &WARN("unknown line: $_");
114         }
115     }
116     close IN;
117
118     &status( sprintf("USERFILE: Loaded: %d users, %d bans, %d ignore",
119                 scalar(keys %users)-1,
120                 scalar(keys %bans),             # ??
121                 scalar(keys %ignore),           # ??
122         )
123     );
124 }
125
126 sub writeUserFile {
127     if (!scalar keys %users) {
128         &DEBUG("wUF: nothing to write.");
129         return;
130     }
131
132     if (!open OUT,">$bot_state_dir/infobot.users") {
133         &ERROR("Cannot write userfile ($bot_state_dir/infobot.users): $!");
134         return;
135     }
136
137     my $time            = scalar(gmtime);
138
139     print OUT "#v1: infobot -- $ident -- written $time\n\n";
140
141     ### USER LIST.
142     my $cusers  = 0;
143     foreach (sort keys %users) {
144         my $user = $_;
145         $cusers++;
146         my $count = scalar keys %{ $users{$user} };
147         if (!$count) {
148             &WARN("user $user has no other attributes; skipping.");
149             next;
150         }
151
152         print OUT "$user\n";
153
154         foreach (sort keys %{ $users{$user} }) {
155             my $what    = $_;
156             my $val     = $users{$user}{$_};
157
158             if (ref($val) eq 'HASH') {
159                 foreach (sort keys %{ $users{$user}{$_} }) {
160                     print OUT "--$what\t\t$_\n";
161                 }
162
163             } elsif ($_ eq 'FLAGS') {
164                 print OUT "--$_\t\t" . join('', sort split('', $val)) . "\n";
165             } else {
166                 print OUT "--$_\t\t$val\n";
167             }
168         }
169         print OUT "\n";
170     }
171
172     ### BAN LIST.
173     my $cbans   = 0;
174     foreach (keys %bans) {
175         my $chan = $_;
176         $cbans++;
177
178         my $count = scalar keys %{ $bans{$chan} };
179         if (!$count) {
180             &WARN("bans: chan $chan has no other attributes; skipping.");
181             next;
182         }
183
184         print OUT "::$chan bans\n";
185         foreach (keys %{ $bans{$chan} }) {
186 # format: bans: mask expire time-added count who-added reason
187             my @array = @{ $bans{$chan}{$_} };
188             if (scalar @array != 5) {
189                 &WARN("bans: $chan/$_ is corrupted.");
190                 next;
191             }
192
193             printf OUT "- %s:+%d:+%d:%d:%s:%s\n", $_, @array;
194         }
195     }
196     print OUT "\n" if ($cbans);
197
198     ### IGNORE LIST.
199     my $cignore = 0;
200     foreach (keys %ignore) {
201         my $chan = $_;
202         $cignore++;
203
204         my $count = scalar keys %{ $ignore{$chan} };
205         if (!$count) {
206             &WARN("ignore: chan $chan has no other attributes; skipping.");
207             next;
208         }
209
210         ### TODO: use hash instead of array for flexibility?
211         print OUT "::$chan ignore\n";
212         foreach (keys %{ $ignore{$chan} }) {
213 # format: ignore: mask expire time-added who-added reason
214             my @array = @{ $ignore{$chan}{$_} };
215             if (scalar @array != 4) {
216                 &WARN("ignore: $chan/$_ is corrupted.");
217                 next;
218             }
219
220             printf OUT "- %s:+%d:+%d:%s:%s\n", $_, @array;
221         }
222     }
223
224     close OUT;
225
226     $wtime_userfile = time();
227     &status("--- Saved USERFILE ($cusers users; $cbans bans; $cignore ignore) at $time");
228     if (defined $msgType and $msgType =~ /^chat$/) {
229         &performStrictReply("--- Writing user file...");
230     }
231 }
232
233 #####
234 ##### CHANNEL CONFIGURATION READER/WRITER
235 #####
236
237 sub readChanFile {
238     my $f = "$bot_state_dir/infobot.chan";
239     if ( -f $f and -f "$f~") {
240         my $s1 = -s $f;
241         my $s2 = -s "$f~";
242
243         if ($s2 > $s1*3) {
244             &FIXME("rCF: backup file bigger than current file.");
245         }
246     }
247
248     if (!open IN, $f) {
249         &ERROR("Cannot read chanfile ($f): $!");
250         return;
251     }
252
253     undef %chanconf;    # reset.
254
255     $_ = <IN>;          # version string.
256
257     my $chan;
258     while (<IN>) {
259         chop;
260
261         next if /^\s*$/;
262         next if /^\// or /^\;/; # / or ; are comment lines.
263
264         if (/^(\S+)\s*$/) {
265             $chan       = $1;
266             next;
267         }
268         next unless (defined $chan);
269
270         if (/^[\s\t]+\+(\S+)$/) {               # bool, true.
271             $chanconf{$chan}{$1} = 1;
272
273         } elsif (/^[\s\t]+\-(\S+)$/) {          # bool, false.
274             # although this is supported in run-time configuration.
275             $chanconf{$chan}{$1} = 0;
276
277         } elsif (/^[\s\t]+(\S+)[\s\t]+(.*)$/) {# what = val.
278             $chanconf{$chan}{$1} = $2;
279
280         } else {
281             &WARN("unknown line: $_") unless (/^#/);
282         }
283     }
284     close IN;
285
286     # verify configuration
287     ### TODO: check against valid params.
288     foreach $chan (keys %chanconf) {
289         foreach (keys %{ $chanconf{$chan} }) {
290             next unless /^[+-]/;
291
292             &WARN("invalid param: chanconf{$chan}{$_}; removing.");
293             delete $chanconf{$chan}{$_};
294             undef $chanconf{$chan}{$_};
295         }
296     }
297
298     &status("CHANFILE: Loaded: ".(scalar(keys %chanconf)-1)." chans");
299 }
300
301 sub writeChanFile {
302     if (!scalar keys %chanconf) {
303         &DEBUG("wCF: nothing to write.");
304         return;
305     }
306
307     if (!open OUT,">$bot_state_dir/infobot.chan") {
308         &ERROR("Cannot write chanfile ($bot_state_dir/infobot.chan): $!");
309         return;
310     }
311
312     my $time            = scalar(gmtime);
313     print OUT "#v1: infobot -- $ident -- written $time\n\n";
314
315     if ($flag_quit) {
316
317         ### Process 1: if defined in _default, remove same definition
318         ###             from non-default channels.
319         foreach (keys %{ $chanconf{_default} }) {
320             my $opt     = $_;
321             my $val     = $chanconf{_default}{$opt};
322             my @chans;
323
324             foreach (keys %chanconf) {
325                 $chan = $_;
326
327                 next if ($chan eq "_default");
328                 next unless (exists $chanconf{$chan}{$opt});
329                 next unless ($val eq $chanconf{$chan}{$opt});
330
331                 push(@chans,$chan);
332                 delete $chanconf{$chan}{$opt};
333             }
334
335             if (scalar @chans) {
336                 &DEBUG("Removed config $opt to @chans since it's defiend in '_default'");
337             }
338         }
339
340         ### Process 2: if defined in all chans but _default, set in
341         ###             _default and remove all others.
342         my (%optsval, %opts);
343         foreach (keys %chanconf) {
344             $chan = $_;
345             next if ($chan eq "_default");
346             my $opt;
347
348             foreach (keys %{ $chanconf{$chan} }) {
349                 $opt = $_;
350                 if (exists $optsval{$opt} and $optsval{$opt} eq $chanconf{$chan}{$opt}) {
351                     $opts{$opt}++;
352                     next;
353                 }
354                 $optsval{$opt}  = $chanconf{$chan}{$opt};
355                 $opts{$opt}     = 1;
356             }
357         }
358
359         foreach (keys %opts) {
360             next unless ($opts{$_} > 2);
361             &DEBUG("  opts{$_} => $opts{$_}");
362         }
363
364         ### other optimizations are in UserDCC.pl
365     }
366
367     ### lets do it...
368     foreach (sort keys %chanconf) {
369         $chan   = $_;
370
371         print OUT "$chan\n";
372
373         foreach (sort keys %{ $chanconf{$chan} }) {
374             my $val = $chanconf{$chan}{$_};
375
376             if ($val =~ /^0$/) {                # bool, false.
377                 print OUT "    -$_\n";
378
379             } elsif ($val =~ /^1$/) {           # bool, true.
380                 print OUT "    +$_\n";
381
382             } else {                            # what = val.
383                 print OUT "    $_ $val\n";
384
385             }
386
387         }
388         print OUT "\n";
389     }
390
391     close OUT;
392
393     $wtime_chanfile = time();
394     &status("--- Saved CHANFILE (".scalar(keys %chanconf).
395                 " chans) at $time");
396
397     if (defined $msgType and $msgType =~ /^chat$/) {
398         &performStrictReply("--- Writing chan file...");
399     }
400 }
401
402 #####
403 ##### USER COMMANDS.
404 #####
405
406 # TODO: support multiple flags.
407 # TODO: return all flags for opers
408 sub IsFlag {
409     my $flags = shift;
410     my ($ret, $f, $o) = '';
411
412     &verifyUser($who, $nuh);
413
414     foreach $f (split //, $users{$userHandle}{FLAGS}) {
415         foreach $o ( split //, $flags ) {
416             next unless ($f eq $o);
417
418             $ret = $f;
419             last;
420         }
421     }
422
423     $ret;
424 }
425
426 sub verifyUser {
427     my ($nick, $lnuh) = @_;
428     my ($user, $m);
429
430     if ($userHandle = $dcc{'CHATvrfy'}{$who}) {
431         &VERB("vUser: cached auth for $who.",2);
432         return $userHandle;
433     }
434
435     $userHandle = '';
436
437     foreach $user (keys %users) {
438         next if ($user eq "_default");
439
440         foreach $m (keys %{ $users{$user}{HOSTS} }) {
441             $m =~ s/\?/./g;
442             $m =~ s/\*/.*?/g;
443             $m =~ s/([\@\(\)\[\]])/\\$1/g;
444
445             next unless ($lnuh =~ /^$m$/i);
446
447             if ($user !~ /^\Q$nick\E$/i and !exists $cache{VUSERWARN}{$user}) {
448                 &status("vU: host matched but diff nick ($nick != $user).");
449                 $cache{VUSERWARN}{$user} = 1;
450             }
451
452             $userHandle = $user;
453             last;
454         }
455
456         last if ($userHandle ne '');
457
458         if ($user =~ /^\Q$nick\E$/i and !exists $cache{VUSERWARN}{$user}) {
459             &status("vU: nick matched but host is not in list ($lnuh).");
460             $cache{VUSERWARN}{$user} = 1;
461         }
462     }
463
464     $userHandle ||= "_default";
465     # what's talkchannel for?
466     $talkWho{$talkchannel} = $who if (defined $talkchannel);
467     $talkWho = $who;
468
469     return $userHandle;
470 }
471
472 sub ckpasswd {
473     # returns true if arg1 encrypts to arg2
474     my ($plain, $encrypted) = @_;
475     if ($encrypted eq '') {
476         ($plain, $encrypted) = split(/\s+/, $plain, 2);
477     }
478     return 0 unless ($plain ne '' and $encrypted ne '');
479
480     # MD5 // DES. Bobby Billingsley++.
481     my $salt;
482     if ($encrypted =~ /^(\S{2})/ and length $encrypted == 13) {
483         $salt = $1;
484     } elsif ($encrypted =~ /^\$\d\$(\w\w)\$/) {
485         $salt = $1;
486     } else {
487         &DEBUG("unknown salt from $encrypted.");
488         return 0;
489     }
490
491     return ($encrypted eq crypt($plain, $salt));
492 }
493
494 # mainly for dcc chat... hrm.
495 sub hasFlag {
496     my ($flag) = @_;
497
498     if (&IsFlag($flag) eq $flag) {
499         return 1;
500     } else {
501         &status("DCC CHAT: <$who> $message -- not enough flags.");
502         &performStrictReply("error: you do not have enough flags for that. ($flag required)");
503         return 0;
504     }
505 }
506
507 # expire is time in minutes
508 sub ignoreAdd {
509     my($mask,$chan,$expire,$comment) = @_;
510
511     $chan       ||= '*';        # global if undefined.
512     $comment    ||= '';         # optional.
513     $expire     ||= 0;          # permament.
514     my $count   ||= 0;
515
516     if ($expire > 0) {
517         $expire         = ($expire*60) + time();
518     } else {
519         $expire         = 0;
520     }
521
522     my $exist   = 0;
523     $exist++ if (exists $ignore{$chan}{$mask});
524
525     $ignore{$chan}{$mask} = [$expire, time(), $who, $comment];
526
527     # TODO: improve this.
528     if ($expire == 0) {
529         &status("ignore: Added $mask for $chan to NEVER expire, by $who, for $comment");
530     } else {
531         &status("ignore: Added $mask for $chan to expire $expire mins, by $who, for $comment");
532     }
533
534     if ($exist) {
535         $utime_userfile = time();
536         $ucount_userfile++;
537
538         return 2;
539     } else {
540         return 1;
541     }
542 }
543
544 sub ignoreDel {
545     my($mask)   = @_;
546     my @match;
547
548     ### TODO: support wildcards.
549     foreach (keys %ignore) {
550         my $chan = $_;
551
552         foreach (grep /^\Q$mask\E$/i, keys %{ $ignore{$chan} }) {
553             delete $ignore{$chan}{$mask};
554             push(@match,$chan);
555         }
556
557         &DEBUG("iD: scalar => ".scalar(keys %{ $ignore{$chan} }) );
558     }
559
560     if (scalar @match) {
561         $utime_userfile = time();
562         $ucount_userfile++;
563     }
564
565     return @match;
566 }
567
568 sub userAdd {
569     my($nick,$mask)     = @_;
570
571     if (exists $users{$nick}) {
572         return 0;
573     }
574
575     $utime_userfile = time();
576     $ucount_userfile++;
577
578     if (defined $mask and $mask !~ /^\s*$/) {
579         &DEBUG("userAdd: mask => $mask");
580         $users{$nick}{HOSTS}{$mask} = 1;
581     }
582
583     $users{$nick}{FLAGS}        ||= $users{_default}{FLAGS};
584
585     return 1;
586 }
587
588 sub userDel {
589     my($nick)   = @_;
590
591     if (!exists $users{$nick}) {
592         return 0;
593     }
594
595     $utime_userfile = time();
596     $ucount_userfile++;
597
598     delete $users{$nick};
599
600     return 1;
601 }
602
603 sub banAdd {
604     my($mask,$chan,$expire,$reason) = @_;
605
606     $chan       ||= '*';
607     $expire     ||= 0;
608
609     if ($expire > 0) {
610         $expire         = $expire*60 + time();
611     }
612
613     my $exist   = 1;
614     $exist++ if (exists $bans{$chan}{$mask} or
615                 exists $bans{'*'}{$mask});
616     $bans{$chan}{$mask} = [$expire, time(), 0, $who, $reason];
617
618     my @chans   = ($chan eq '*') ? keys %channels : $chan;
619     my $m       = $mask;
620     $m          =~ s/\?/\\./g;
621     $m          =~ s/\*/\\S*/g;
622     foreach (@chans) {
623         my $chan = $_;
624         foreach (keys %{ $channels{$chan}{''} }) {
625             next unless (exists $nuh{lc $_});
626             next unless ($nuh{lc $_} =~ /^$m$/i);
627             &FIXME("nuh{$_} =~ /$m/");
628         }
629     }
630
631     if ($exist == 1) {
632         $utime_userfile = time();
633         $ucount_userfile++;
634     }
635
636     return $exist;
637 }
638
639 sub banDel {
640     my($mask)   = @_;
641     my @match;
642
643     foreach (keys %bans) {
644         my $chan        = $_;
645
646         foreach (grep /^\Q$mask\E$/i, keys %{ $bans{$chan} }) {
647             delete $bans{$chan}{$_};
648             push(@match, $chan);
649         }
650
651         &DEBUG("bans: scalar => ".scalar(keys %{ $bans{$chan} }) );
652     }
653
654     if (scalar @match) {
655         $utime_userfile = time();
656         $ucount_userfile++;
657     }
658
659     return @match;
660 }
661
662 sub IsUser {
663     my($user) = @_;
664
665     if ( &getUser($user) ) {
666         return 1;
667     } else {
668         return 0;
669     }
670 }
671
672 sub getUser {
673     my($user) = @_;
674
675     if (!defined $user) {
676         &WARN("getUser: user == NULL.");
677         return;
678     }
679
680     if (my @retval = grep /^\Q$user\E$/i, keys %users) {
681         if ($retval[0] ne $user) {
682             &WARN("getUser: retval[0] ne user ($retval[0] ne $user)");
683         }
684         my $count = scalar keys %{ $users{$retval[0]} };
685         &DEBUG("count => $count.");
686
687         return $retval[0];
688     } else {
689         return;
690     }
691 }
692
693 sub chanSet {
694     my($cmd, $chan, $what, $val) = @_;
695
696     if ($cmd eq "+chan") {
697         if (exists $chanconf{$chan}) {
698             &performStrictReply("chan $chan already exists.");
699             return;
700         }
701         $chanconf{$chan}{_time_added}   = time();
702         $chanconf{$chan}{autojoin}      = $conn->nick();
703
704         &performStrictReply("Joining $chan...");
705         &joinchan($chan);
706
707         return;
708     }
709
710     if (!exists $chanconf{$chan}) {
711         &performStrictReply("no such channel $chan");
712         return;
713     }
714
715     my $update  = 0;
716
717     if (defined $what and $what =~ s/^([+-])(\S+)/$2/) {
718         ### ".chanset +blah"
719         ### ".chanset +blah 10"         -- error.
720
721         my $set = ($1 eq "+") ? 1 : 0;
722         my $was         = $chanconf{$chan}{$what};
723
724         if ($set) {                     # add/set.
725             if (defined $was and $was eq '1') {
726                 &performStrictReply("setting $what for $chan already 1.");
727                 return;
728             }
729
730             $val        = 1;
731
732         } else {                        # delete/unset.
733             if (!defined $was) {
734                 &performStrictReply("setting $what for $chan is not set.");
735                 return;
736             }
737
738             $val        = 0;
739         }
740
741         # alter for cosmetic (print out) reasons only.
742         $was    = (defined $was) ? "; was '$was'" : '';
743
744         if ($val eq '0') {
745             &performStrictReply("Unsetting $what for $chan$was.");
746             delete $chanconf{$chan}{$what};
747         } else {
748             &performStrictReply("Setting $what for $chan to '$val'$was.");
749             $chanconf{$chan}{$what}     = $val;
750         }
751
752         $update++;
753
754     } elsif (defined $val) {
755         ### ".chanset blah testing"
756
757         my $was = $chanconf{$chan}{$what};
758         if (defined $was and $was eq $val) {
759             &performStrictReply("setting $what for $chan already '$val'.");
760             return;
761         }
762         $was    = ($was) ? "; was '$was'" : '';
763         &performStrictReply("Setting $what for $chan to '$val'$was.");
764
765         $chanconf{$chan}{$what} = $val;
766
767         $update++;
768
769     } else {                            # read only.
770         ### ".chanset"
771         ### ".chanset blah"
772
773         if (!defined $what) {
774             &WARN("chanset/DC: what == undefine.");
775             return;
776         }
777
778         if (exists $chanconf{$chan}{$what}) {
779             &performStrictReply("$what for $chan is '$chanconf{$chan}{$what}'");
780         } else {
781             &performStrictReply("$what for $chan is not set.");
782         }
783     }
784
785     if ($update) {
786         $utime_chanfile = time();
787         $ucount_chanfile++;
788     }
789
790     return;
791 }
792
793 sub rehashConfVars {
794     # this is an attempt to fix where an option is enabled but the module
795     # has been not loaded. it also can be used for other things.
796
797     foreach (keys %{ $cache{confvars} }) {
798         my $i = $cache{confvars}{$_};
799         &DEBUG("rehashConfVars: _ => $_");
800
801         if (/^news$/ and $i) {
802             &loadMyModule('News');
803             delete $cache{confvars}{$_};
804         }
805
806         if (/^uptime$/ and $i) {
807             &loadMyModule('Uptime');
808             delete $cache{confvars}{$_};
809         }
810
811         if (/^rootwarn$/i and $i) {
812             &loadMyModule('RootWarn');
813             delete $cache{confvars}{$_};
814         }
815
816         if (/^onjoin$/i and $i) {
817             &loadMyModule('OnJoin');
818             delete $cache{confvars}{$_};
819         }
820     }
821
822     &DEBUG("end of rehashConfVars");
823
824     delete $cache{confvars};
825 }
826
827 my @regFlagsUser = (
828         # possible chars to include in FLAG
829         'A',    # bot administration over /msg
830                         # default is only via DCC CHAT
831         'O',    # dynamic ops (as on channel). (automatic +o)
832         'T',    # add topics.
833         'a',    # ask/request factoid.
834         'm',    # modify factoid. (includes renaming)
835         'n',    # bot owner, can 'reload'
836         'o',    # master of bot (automatic +amrt)
837                         # can search on factoid strings shorter than 2 chars
838                         # can tell bot to join new channels
839                         # can [un]lock factoids
840         'r',    # remove factoid.
841         't',    # teach/add factoid.
842 );
843
844 1;