]> git.donarmstrong.com Git - infobot.git/blob - src/DynaConfig.pl
gmtime
[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/blootbot.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             &DEBUG("rUF: backup file bigger than current file. FIXME");
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/blootbot.users") {
133         &ERROR("Cannot write userfile ($bot_state_dir/blootbot.users): $!");
134         return;
135     }
136
137     my $time            = scalar(gmtime);
138
139     print OUT "#v1: blootbot -- $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             } else {
164                 print OUT "--$_\t\t$val\n";
165             }
166         }
167         print OUT "\n";
168     }
169
170     ### BAN LIST.
171     my $cbans   = 0;
172     foreach (keys %bans) {
173         my $chan = $_;
174         $cbans++;
175
176         my $count = scalar keys %{ $bans{$chan} };
177         if (!$count) {
178             &WARN("bans: chan $chan has no other attributes; skipping.");
179             next;
180         }
181
182         print OUT "::$chan bans\n";
183         foreach (keys %{ $bans{$chan} }) {
184 # format: bans: mask expire time-added count who-added reason
185             my @array = @{ $bans{$chan}{$_} };
186             if (scalar @array != 5) {
187                 &WARN("bans: $chan/$_ is corrupted.");
188                 next;
189             }
190
191             printf OUT "- %s:+%d:+%d:%d:%s:%s\n", $_, @array;
192         }
193     }
194     print OUT "\n" if ($cbans);
195
196     ### IGNORE LIST.
197     my $cignore = 0;
198     foreach (keys %ignore) {
199         my $chan = $_;
200         $cignore++;
201
202         my $count = scalar keys %{ $ignore{$chan} };
203         if (!$count) {
204             &WARN("ignore: chan $chan has no other attributes; skipping.");
205             next;
206         }
207
208         ### TODO: use hash instead of array for flexibility?
209         print OUT "::$chan ignore\n";
210         foreach (keys %{ $ignore{$chan} }) {
211 # format: ignore: mask expire time-added who-added reason
212             my @array = @{ $ignore{$chan}{$_} };
213             if (scalar @array != 4) {
214                 &WARN("ignore: $chan/$_ is corrupted.");
215                 next;
216             }
217
218             printf OUT "- %s:+%d:+%d:%s:%s\n", $_, @array;
219         }
220     }
221
222     close OUT;
223
224     $wtime_userfile = time();
225     &status("--- Saved USERFILE ($cusers users; $cbans bans; $cignore ignore) at $time");
226     if (defined $msgType and $msgType =~ /^chat$/) {
227         &pSReply("--- Writing user file...");
228     }
229 }
230
231 #####
232 ##### CHANNEL CONFIGURATION READER/WRITER
233 #####
234
235 sub readChanFile {
236     my $f = "$bot_state_dir/blootbot.chan";
237     if ( -f $f and -f "$f~") {
238         my $s1 = -s $f;
239         my $s2 = -s "$f~";
240
241         if ($s2 > $s1*3) {
242             &DEBUG("rCF: backup file bigger than current file. FIXME");
243         }
244     }
245
246     if (!open IN, $f) {
247         &ERROR("Cannot read chanfile ($f): $!");
248         return;
249     }
250
251     undef %chanconf;    # reset.
252
253     $_ = <IN>;          # version string.
254
255     my $chan;
256     while (<IN>) {
257         chop;
258
259         next if /^\s*$/;
260         next if /^\// or /^\;/; # / or ; are comment lines.
261
262         if (/^(\S+)\s*$/) {
263             $chan       = $1;
264             next;
265         }
266         next unless (defined $chan);
267
268         if (/^[\s\t]+\+(\S+)$/) {               # bool, true.
269             $chanconf{$chan}{$1} = 1;
270
271         } elsif (/^[\s\t]+\-(\S+)$/) {          # bool, false.
272             &DEBUG("deprecated support of negative options.") unless ($cache{negative});
273             # although this is supported in run-time configuration.
274             $cache{negative} = 1;
275 #           $chanconf{$chan}{$1} = 0;
276
277         } elsif (/^[\s\t]+(\S+)[\ss\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     delete $cache{negative};
299
300     &status("CHANFILE: Loaded: ".(scalar(keys %chanconf)-1)." chans");
301 }
302
303 sub writeChanFile {
304     if (!scalar keys %chanconf) {
305         &DEBUG("wCF: nothing to write.");
306         return;
307     }
308
309     if (!open OUT,">$bot_state_dir/blootbot.chan") {
310         &ERROR("Cannot write chanfile ($bot_state_dir/blootbot.chan): $!");
311         return;
312     }
313
314     my $time            = scalar(gmtime);
315     print OUT "#v1: blootbot -- $ident -- written $time\n\n";
316
317     if ($flag_quit) {
318
319         ### Process 1: if defined in _default, remove same definition
320         ###             from non-default channels.
321         foreach (keys %{ $chanconf{_default} }) {
322             my $opt     = $_;
323             my $val     = $chanconf{_default}{$opt};
324             my @chans;
325
326             foreach (keys %chanconf) {
327                 $chan = $_;
328
329                 next if ($chan eq "_default");
330                 next unless (exists $chanconf{$chan}{$opt});
331                 next unless ($val eq $chanconf{$chan}{$opt});
332
333                 push(@chans,$chan);
334                 delete $chanconf{$chan}{$opt};
335             }
336
337             if (scalar @chans) {
338                 &DEBUG("Removed config $opt to @chans since it's defiend in '_default'");
339             }
340         }
341
342         ### Process 2: if defined in all chans but _default, set in
343         ###             _default and remove all others.
344         my (%optsval, %opts);
345         foreach (keys %chanconf) {
346             $chan = $_;
347             next if ($chan eq "_default");
348             my $opt;
349
350             foreach (keys %{ $chanconf{$chan} }) {
351                 $opt = $_;
352                 if (exists $optsval{$opt} and $optsval{$opt} eq $chanconf{$chan}{$opt}) {
353                     $opts{$opt}++;
354                     next;
355                 }
356                 $optsval{$opt}  = $chanconf{$chan}{$opt};
357                 $opts{$opt}     = 1;
358             }
359         }
360
361         foreach (keys %opts) {
362             next unless ($opts{$_} > 2);
363             &DEBUG("  opts{$_} => $opts{$_}");
364         }
365
366         ### other optimizations are in UserDCC.pl
367     }
368
369     ### lets do it...
370     foreach (sort keys %chanconf) {
371         $chan   = $_;
372
373         print OUT "$chan\n";
374
375         foreach (sort keys %{ $chanconf{$chan} }) {
376             my $val = $chanconf{$chan}{$_};
377
378             if ($val =~ /^0$/) {                # bool, false.
379                 print OUT "    -$_\n";
380
381             } elsif ($val =~ /^1$/) {           # bool, true.
382                 print OUT "    +$_\n";
383
384             } else {                            # what = val.
385                 print OUT "    $_ $val\n";
386
387             }
388
389         }
390         print OUT "\n";
391     }
392
393     close OUT;
394
395     $wtime_chanfile = time();
396     &status("--- Saved CHANFILE (".scalar(keys %chanconf).
397                 " chans) at $time");
398
399     if (defined $msgType and $msgType =~ /^chat$/) {
400         &pSReply("--- Writing chan file...");
401     }
402 }
403
404 #####
405 ##### USER COMMANDS.
406 #####
407
408 # todo: support multiple flags.
409 sub IsFlag {
410     my $flags = shift;
411     my ($ret, $f, $o) = "";
412
413     &verifyUser($who, $nuh);
414
415     foreach $f (split //, $users{$userHandle}{FLAGS}) {
416         foreach $o ( split //, $flags ) {
417             next unless ($f eq $o);
418
419             $ret = $f;
420             last;
421         }
422     }
423
424     $ret;
425 }
426
427 sub verifyUser {
428     my ($nick, $lnuh) = @_;
429     my ($user, $m);
430
431     if ($userHandle = $dcc{'CHATvrfy'}{$who}) {
432         &VERB("vUser: cached auth for $who.",2);
433         return $userHandle;
434     }
435
436     $userHandle = "";
437
438     foreach $user (keys %users) {
439         next if ($user eq "_default");
440
441         foreach $m (keys %{ $users{$user}{HOSTS} }) {
442             $m =~ s/\?/./g;
443             $m =~ s/\*/.*?/g;
444             $m =~ s/([\@\(\)\[\]])/\\$1/g;
445
446             next unless ($lnuh =~ /^$m$/i);
447
448             if ($user !~ /^\Q$nick\E$/i and !exists $cache{VUSERWARN}{$user}) {
449                 &status("vU: host matched but diff nick ($nick != $user).");
450                 $cache{VUSERWARN}{$user} = 1;
451             }
452
453             $userHandle = $user;
454             last;
455         }
456
457         last if ($userHandle ne "");
458
459         if ($user =~ /^\Q$nick\E$/i and !exists $cache{VUSERWARN}{$user}) {
460             &status("vU: nick matched but host is not in list ($lnuh).");
461             $cache{VUSERWARN}{$user} = 1;
462         }
463     }
464
465     $userHandle ||= "_default";
466     # what's talkchannel for?
467     $talkWho{$talkchannel} = $who if (defined $talkchannel);
468     $talkWho = $who;
469
470     return $userHandle;
471 }
472
473 sub ckpasswd {
474     # returns true if arg1 encrypts to arg2
475     my ($plain, $encrypted) = @_;
476     if ($encrypted eq "") {
477         ($plain, $encrypted) = split(/\s+/, $plain, 2);
478     }
479     return 0 unless ($plain ne "" and $encrypted ne "");
480
481     # MD5 // DES. Bobby Billingsley++.
482     my $salt;
483     if ($encrypted =~ /^(\S{2})/ and length $encrypted == 13) {
484         $salt = $1;
485     } elsif ($encrypted =~ /^\$\d\$(\w\w)\$/) {
486         $salt = $1;
487     } else {
488         &DEBUG("unknown salt from $encrypted.");
489         return 0;
490     }
491
492     return ($encrypted eq crypt($plain, $salt));
493 }
494
495 # mainly for dcc chat... hrm.
496 sub hasFlag {
497     my ($flag) = @_;
498
499     if (&IsFlag($flag) eq $flag) {
500         return 1;
501     } else {
502         &status("DCC CHAT: <$who> $message -- not enough flags.");
503         &pSReply("error: you do not have enough flags for that. ($flag required)");
504         return 0;
505     }
506 }
507
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             &pSReply("chan $chan already exists.");
699             return;
700         }
701         $chanconf{$chan}{_time_added}   = time();
702         $chanconf{$chan}{autojoin}      = 1;
703
704         &pSReply("Joining $chan...");
705         &joinchan($chan);
706
707         return;
708     }
709
710     if (!exists $chanconf{$chan}) {
711         &pSReply("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 $state       = ($1 eq "+") ? 1 : 0;
722         my $was         = $chanconf{$chan}{$what};
723
724         if ($state) {                   # add/set.
725             if (defined $was and $was eq "1") {
726                 &pSReply("setting $what for $chan already 1.");
727                 return;
728             }
729
730             $val        = 1;
731
732         } else {                        # delete/unset.
733             if (!defined $was) {
734                 &pSReply("setting $what for $chan is not set.");
735                 return;
736             }
737
738             if ($was eq "0") {
739                 &pSReply("setting $what for $chan already 0.");
740                 return;
741             }
742
743             $val        = 0;
744         }
745
746         # alter for cosmetic (print out) reasons only.
747         $was    = ($was) ? "; was '$was'" : "";
748
749         if ($val eq "0") {
750             &pSReply("Unsetting $what for $chan$was.");
751             delete $chanconf{$chan}{$what};
752         } else {
753             &pSReply("Setting $what for $chan to '$val'$was.");
754             $chanconf{$chan}{$what}     = $val;
755         }
756
757         $update++;
758
759     } elsif (defined $val) {
760         ### ".chanset blah testing"
761
762         my $was = $chanconf{$chan}{$what};
763         if (defined $was and $was eq $val) {
764             &pSReply("setting $what for $chan already '$val'.");
765             return;
766         }
767         $was    = ($was) ? "; was '$was'" : "";
768         &pSReply("Setting $what for $chan to '$val'$was.");
769
770         $chanconf{$chan}{$what} = $val;
771
772         $update++;
773
774     } else {                            # read only.
775         ### ".chanset"
776         ### ".chanset blah"
777
778         if (!defined $what) {
779             &WARN("chanset/DC: what == undefine.");
780             return;
781         }
782
783         if (exists $chanconf{$chan}{$what}) {
784             &pSReply("$what for $chan is '$chanconf{$chan}{$what}'");
785         } else {
786             &pSReply("$what for $chan is not set.");
787         }
788     }
789
790     if ($update) {
791         $utime_chanfile = time();
792         $ucount_chanfile++;
793     }
794
795     return;
796 }
797
798 sub rehashConfVars {
799     # this is an attempt to fix where an option is enabled but the module
800     # has been not loaded. it also can be used for other things.
801
802     foreach (keys %{ $cache{confvars} }) {
803         my $i = $cache{confvars}{$_};
804         &DEBUG("rehashConfVars: _ => $_");
805
806         if (/^news$/ and $i) {
807             &loadMyModule("news");
808             delete $cache{confvars}{$_};
809         }
810
811         if (/^uptime$/ and $i) {
812             &loadMyModule("uptime");
813             delete $cache{confvars}{$_};
814         }
815
816         if (/^rootwarn$/i and $i) {
817             &loadMyModule($_);
818             delete $cache{confvars}{$_};
819         }
820     }
821
822     &DEBUG("end of rehashConfVars");
823
824     delete $cache{confvars};
825 }
826
827 # following arrays are not used... forgot what I intended to use them for.
828 my @regFlagsChan = (
829         "autojoin",
830         "freshmeat",
831         "limitcheckInterval",
832         "limitcheckPlus",
833         "allowConv",
834         "allowDNS",
835 ### TODO: finish off this list.
836 );
837
838 my @regFlagsUser = (
839         "m",            # modify factoid.
840         "r",            # remove factoid.
841         "s",            # search (deprecated)
842         "t",            # teach/add factoid.
843         "a",            # ask/request factoid.
844         "n",            # bot owner
845         "o",            # master of bot (automatic +amrt)
846         "O",            # dynamic ops (as on channel). (automatic +o)
847 );      # todo...
848
849 1;
850
851 #####
852 # Userflags
853 #       +r      - ability to remove factoids
854 #       +t      - ability to teach factoids
855 #       +m      - ability to modify factoids
856 #       +n      - bot owner
857 #       +o      - authorised user of bot (like +m on eggdrop)
858 #####