); # 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)
+#####
# break if either lhs or rhs is NULL.
if ($lhs eq "" or $rhs eq "") {
- return;
+ return "NOT-A-STATEMENT";
}
# lets check if it failed.
$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);
$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 {
$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 {
$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 {
# 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;
}
&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] );
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];
}
}
next unless (!defined $limit);
- if ($limit == $newlimit) {
+ if (defined $limit and $limit == $newlimit) {
$cache{chanlimitChange}{$chan} = time();
next;
}
}
$chan = $chans[0];
- &::DEBUG("Guessed $::who being on chan $chan");
+ &::VERB("Guessed $::who being on chan $chan",2);
$::chan = $chan; # hack for IsChanConf().
}
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;
}
}
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.");
&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.
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);
}
# 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)) {
# hex.
if ($message =~ /^hex(\s+(.*))?$/i) {
- return unless (&IsParam("allowConv"));
+ return unless (&hasParam("allowConv"));
my $arg = $2;
if (!defined $arg) {
&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}/#;