+ # text counters.
+ if ($_ = &getChanConf("ircTextCounters")) {
+ s/([^\w\s])/\\$1/g;
+ my $z = join '|', split ' ';
+
+ if ($message =~ /^($z)stats(\s+(\S+))?$/i) {
+ my $type = $1;
+ my $arg = $3;
+
+ if (!defined $arg or $arg =~ /^\s*$/) {
+ my $x = (&dbRawReturn("SELECT SUM(counter) FROM stats WHERE type=".&dbQuote($type) ))[0];
+
+ if (defined $x) {
+ &pSReply("total count of '$type': $x");
+ } else {
+ &pSReply("zero counter for '$type'.");
+ }
+ } else {
+ my $x = (&dbRawReturn("SELECT SUM(counter) FROM stats WHERE type=".
+ &dbQuote($type)." AND nick=".&dbQuote($arg) ))[0];
+
+ if (defined $x) { # defined.
+ &pSReply("$arg has said $type $x times");
+ } else { # !defined.
+ &pSReply("$arg has not said $type yet.");
+ }
+ }
+
+ return;
+ }
+
+ if ($@) {
+ &DEBUG("regex failed: $@");
+ return;
+ }
+ }
+