]> git.donarmstrong.com Git - infobot.git/commitdiff
"~forget blah" now works. thanks to ElectricElf
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 26 Apr 2001 14:37:28 +0000 (14:37 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 26 Apr 2001 14:37:28 +0000 (14:37 +0000)
documented user flags
public/private/notice send limit now configurable. thanks to EE
added "countrystats" command.
"blootbot: are you fixed now? :)" -- fixed. found by greycat
use hasParam instead of IsParam in UserExtra.pl/userCommands()
command "ord" handling fixed.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@465 c11ca15a-4712-0410-83d8-924469b57eb5

src/DynaConfig.pl
src/Factoids/Statement.pl
src/IRC/Irc.pl
src/IRC/IrcHelpers.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/News.pl
src/Process.pl
src/UserExtra.pl
src/core.pl

index e23edf0bec8d23df2ecacc7936b267aef5ee89ed..e1acb4d3e3e46e351a344bf77d3a43751c5b5312 100644 (file)
@@ -776,3 +776,12 @@ my @regFlagsUser = (
 );     # todo...
 
 1;
+
+#####
+# Userflags
+#      +r      - ability to remove factoids
+#      +t      - ability to teach factoids
+#      +m      - ability to modify factoids
+#      +n      - bot owner
+#      +o      - authorised user of bot (like +m on eggdrop)
+#####
index ed58a44800b193a5d1de32dcee50d2f5f4425674..ae0ffa4b6f78292d88c7d1909f08b75aab289212 100644 (file)
@@ -65,7 +65,7 @@ sub doStatement {
 
        # break if either lhs or rhs is NULL.
        if ($lhs eq "" or $rhs eq "") {
-           return;
+           return "NOT-A-STATEMENT";
        }
 
        # lets check if it failed.
index 36d57aae2ad52fe5a41f79e7c40c65d92577af65..9d23905c378b50467e57c55de0843d9602466658 100644 (file)
@@ -136,6 +136,7 @@ sub irc {
        $conn->add_global_handler('disconnect', \&on_disconnect);
        $conn->add_global_handler([251,252,253,254,255], \&on_init);
 ###    $conn->add_global_handler([251,252,253,254,255,302], \&on_init);
+       $conn->add_global_handler(315, \&on_endofwho);
        $conn->add_global_handler(324, \&on_modeis);
        $conn->add_global_handler(333, \&on_topicinfo);
        $conn->add_global_handler(352, \&on_who);
@@ -191,11 +192,14 @@ sub say {
            $pubcount++;
            $pubsize += length $msg;
 
-           if ( ($pubcount % 4) == 0 and $pubcount) {
+           my $i = &getChanConfDefault("sendPublicLimitLines", 3);
+           my $j = &getChanConfDefault("sendPublicLimitBytes", 1000);
+
+           if ( ($pubcount % $i) == 0 and $pubcount) {
                sleep 1;
-           } elsif ($pubsize > 1500) {
+           } elsif ($pubsize > $j) {
                sleep 1;
-               $pubsize -= 1500;
+               $pubsize -= $j;
            }
 
        } else {
@@ -230,11 +234,13 @@ sub msg {
            $msgcount++;
            $msgsize += length $msg;
 
-           if ( ($msgcount % 4) == 0 and $msgcount) {
+           my $i = &getChanConfDefault("sendPrivateLimitLines", 3);
+           my $j = &getChanConfDefault("sendPrivateLimitBytes", 1000);
+           if ( ($msgcount % $i) == 0 and $msgcount) {
                sleep 1;
-           } elsif ($msgsize > 1000) {
+           } elsif ($msgsize > $j) {
                sleep 1;
-               $msgsize -= 1000;
+               $msgsize -= $j;
            }
 
        } else {
@@ -283,11 +289,14 @@ sub notice {
        $notcount++;
        $notsize += length $txt;
 
-       if ( ($notcount % 3) == 0 and $notcount) {
+       my $i = &getChanConfDefault("sendNoticeLimitLines", 3);
+       my $j = &getChanConfDefault("sendNoticeLimitBytes", 1000);
+
+       if ( ($notcount % $i) == 0 and $notcount) {
            sleep 1;
-       } elsif ($notsize > 1000) {
+       } elsif ($notsize > $j) {
            sleep 1;
-           $notsize -= 1000;
+           $notsize -= $j;
        }
 
     } else {
index 52948dd569eb60e2b4172d56d44657b18abb3121..9d654f90e9c63d36274f186e0436354fe06451c8 100644 (file)
@@ -85,7 +85,7 @@ sub hookMsg {
        # addressing revamped by the xk.
        ### below needs to be fixed...
        if (&IsParam("addressCharacter")) {
-           if ($message =~ s/^$param{'addressCharacter'}//) {
+           if ($message =~ s/^\Q$param{'addressCharacter'}\E//) {
                $addrchar  = 1;
                $addressed = 1;
            }
index f04e08b1e2f5fac7c27e75e27ed84617434e7247..feac0db1e1c6479e4c20a0a7b59a75a43b59985b 100644 (file)
@@ -190,6 +190,17 @@ sub on_endofmotd {
     &joinNextChan();
 }
 
+sub on_endofwho {
+    my ($self, $event) = @_;
+#    &DEBUG("endofwho: chan => $chan");
+    $chan      ||= ($event->args)[1];
+#    &DEBUG("endofwho: chan => $chan");
+
+    if (exists $cache{countryStats}) {
+       &do_countrystats();
+    }
+}
+
 sub on_dcc {
     my ($self, $event) = @_;
     my $type = uc( ($event->args)[1] );
@@ -977,6 +988,14 @@ sub on_version {
 sub on_who {
     my ($self, $event) = @_;
     my @args   = $event->args;
+    my $str    = $args[5]."!".$args[2]."\@".$args[3];
+
+    if ($cache{on_who_Hack}) {
+       $cache{nuhInfo}{lc $args[5]}{Nick} = $args[5];
+       $cache{nuhInfo}{lc $args[5]}{User} = $args[2];
+       $cache{nuhInfo}{lc $args[5]}{Host} = $args[3];
+       return;
+    }
 
     $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
 }
index d14c12ced7d040d1cf389e24b09fa2d4f2b85c41..0412f853799c5dd222dcdbca8076ea6488c270d2 100644 (file)
@@ -365,7 +365,7 @@ sub chanlimitCheck {
        }
 
        next unless (!defined $limit);
-       if ($limit == $newlimit) {
+       if (defined $limit and $limit == $newlimit) {
            $cache{chanlimitChange}{$chan} = time();
            next;
        }
index 265da899bf4733f9d16b72658a0151f4334e8818..089ab07113270aff18ad9ca21db7df6ff305bf73 100644 (file)
@@ -58,7 +58,7 @@ sub Parse {
        }
 
        $chan   = $chans[0];
-       &::DEBUG("Guessed $::who being on chan $chan");
+       &::VERB("Guessed $::who being on chan $chan",2);
        $::chan = $chan;        # hack for IsChanConf().
     }
 
index 54ab15b906ad8511b0b953f6ad4e4cc6b0e18a40..1862e7a61040812f35ac91d38ec6705d3ad03735 100644 (file)
@@ -316,12 +316,9 @@ sub process {
            return 'SOMETHING 1';
        }
 
-       ### FIXME: should this only apply to public messages?
-       if ($addrchar) {
-           &DEBUG("floodwho => '$floodwho'.");
-           delete $flood{$floodwho}{$message};
-           &status("short return due to unknown command.");
-           return 'ADDR CHAR';
+       if (0 and $addrchar) {
+           &msg($who, "I don't trust people to use the core commands while addressing me in a short-cut way.");
+           return;
        }
     }
 
index f405a11d50b41d95504c87e7f1a4f43188c98950..8f6aff3fb6712a1acf178303e47c5aea4b935166 100644 (file)
@@ -34,7 +34,9 @@ use vars qw(%channels %chanstats %cmdstats);
        Cmdstats => 'Tell') );
 &addCmdHook("main", 'news', ('CODEREF' => 'News::Parse', 
        Module => 'news', ) );
-#      Module => 'news', Identifier => 'news') );
+&addCmdHook("main", 'countrystats', ('CODEREF' => 'countryStats', 
+#      Forker => "NULL",
+ ) );
 
 &status("CMD: loaded ".scalar(keys %hooks_main)." MAIN command hooks.");
 
@@ -410,6 +412,66 @@ sub DNS {
     &performReply($result);
 }
 
+sub countryStats {
+    if (exists $cache{countryStats}) {
+       &msg($who,"countrystats is already running!");
+       return;
+    }
+
+    if ($chan eq "") {
+       $chan = $_[0];
+    }
+
+    if ($chan eq "") {
+       &help("countrystats");
+       return;
+    }
+
+    &rawout("WHO $chan");
+    $cache{countryStats}{chan} = $chan;
+    $cache{countryStats}{mtype}        = $msgType;
+    $cache{countryStats}{who}  = $who;
+    $cache{on_who_Hack}                = 1;
+}
+
+sub do_countrystats {
+    $chan      = $cache{countryStats}{chan};
+    $msgType   = $cache{countryStats}{mtype};
+    $who       = $cache{countryStats}{who};
+
+    my $total  = 0;
+    my %cstats;
+    foreach (keys %{ $cache{nuhInfo} }) {
+       my $h = $cache{nuhInfo}{$_}{Host};
+
+       if ($h =~ /^.*\.(\D+)$/) {      # host
+           $cstats{$1}++;
+       } else {                        # ip
+           $cstats{unresolve}++;
+       }
+       $total++;
+    }
+    my %count;
+    foreach (keys %cstats) {
+       $count{ $cstats{$_} }{$_} = 1;
+    }
+
+    my @list;
+    foreach (sort {$b <=> $a} keys %count) {
+       my $str = join(", ", sort keys %{ $count{$_} });
+#      push(@list, "$str ($_)");
+       my $perc        = sprintf("%.01f", 100 * $_ / $total);
+       $perc           =~ s/\.0+$//;
+       push(@list, "$str ($_, $perc %)");
+    }
+
+    # todo: move this into a scheduler like nickometer
+    $msgType   = "private";
+    &pSReply( &formListReply(0, "Country Stats ", @list) );
+
+    delete $cache{countryStats};
+    delete $cache{on_who_Hack};
+}
 
 ###
 ### amalgamated commands.
@@ -418,7 +480,10 @@ sub DNS {
 sub userCommands {
     # conversion: ascii.
     if ($message =~ /^(asci*|chr) (\d+)$/) {
-       return unless (&IsParam("allowConv"));
+       &DEBUG("ascii/chr called ...");
+       return unless (&hasParam("allowConv"));
+
+       &DEBUG("ascii/chr called");
 
        $arg    = $2;
        $result = chr($arg);
@@ -430,10 +495,16 @@ sub userCommands {
     }
 
     # conversion: ord.
-    if ($message =~ /^ord (.)$/) {
-       return unless (&IsParam("allowConv"));
+    if ($message =~ /^ord(\s+(.*))$/) {
+       return unless (&hasParam("allowConv"));
+
+       $arg = $2;
+
+       if (!defined $arg or length $arg != 1) {
+           &help("ord");
+           return;
+       }
 
-       $arg = $1;
        if (ord($arg) < 32) {
            $arg = chr(ord($arg) + 64);
            if ($arg eq chr(64)) {
@@ -449,7 +520,7 @@ sub userCommands {
 
     # hex.
     if ($message =~ /^hex(\s+(.*))?$/i) {
-       return unless (&IsParam("allowConv"));
+       return unless (&hasParam("allowConv"));
        my $arg = $2;
 
        if (!defined $arg) {
index 4caf49330df9aa9d7903ec8bbe7b0f30df03fdbb..5d3a2b22a9aacd97b491a2b2004dfbcd4d4ee0e9 100644 (file)
@@ -354,6 +354,12 @@ sub setup {
 
     &status("Setup: ". &countKeys("factoids") ." factoids.");
     &News::readNews() if (&ChanConfList("news"));
+    &getChanConfDefault("sendPrivateLimitLines", 3);
+    &getChanConfDefault("sendPrivateLimitBytes", 1000);
+    &getChanConfDefault("sendPublicLimitLines", 3);
+    &getChanConfDefault("sendPublicLimitBytes", 1000);
+    &getChanConfDefault("sendNoticeLimitLines", 3);
+    &getChanConfDefault("sendNoticeLimitBytes", 1000);
 
     $param{tempDir} =~ s#\~/#$ENV{HOME}/#;