summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5bd61db)
requires +O in user file for this to be activated.
- converted most instances of &rawout() to $conn->function();
- typo for default userHandle. woops.
- uptimeWriteFile() should work now; use IsChanConf() instead.
- fixed channel key support. forgot about it when we changed over to
Net::IRC.
- added support for Q on quakenet.org - can be adapted for other servers
I guess.
- added el-cheapo throttling to $conn->notice() in News module.
TODO: implement this in our ¬ice() + &msg() functions.
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@593
c11ca15a-4712-0410-83d8-
924469b57eb5
14 files changed:
# which will make it less than linear => quicker!
# todo: cache this, update cache when altered. !!! !!! !!!
# my $t = &timeget();
# which will make it less than linear => quicker!
# todo: cache this, update cache when altered. !!! !!! !!!
# my $t = &timeget();
- my @list = &searchTable("factoids", "factoid_key", "factoid_key", "CMD: ");
+ my @list = &searchTable("factoids", "factoid_key", "factoid_key", "^CMD: ");
# my $delta_time = &timedelta($t);
# &DEBUG("factArgs: delta_time = $delta_time s");
# &DEBUG("factArgs: list => ".scalar(@list) );
# my $delta_time = &timedelta($t);
# &DEBUG("factArgs: delta_time = $delta_time s");
# &DEBUG("factArgs: list => ".scalar(@list) );
- my $rawout = "PRIVMSG $target :\001ACTION $txt\001";
- if (length $rawout > 510) {
+ if (length $txt > 480) {
&status("action: txt too long; truncating.");
&status("action: txt too long; truncating.");
-
- chop($rawout) while (length($rawout) > 510);
- $rawout .= "\001";
+ chop($txt) while (length $txt > 480);
}
&status("* $ident/$target $txt");
}
&status("* $ident/$target $txt");
+ $conn->me($target, $txt);
}
# Usage: ¬ice(nick || chan, txt);
}
# Usage: ¬ice(nick || chan, txt);
- my ($chankey) = @_;
- my $chan = lc $chankey;
+ my ($chan) = @_;
+ my $key = &getChanConf("chankey", $chan) || "";
- if ($chankey =~ s/^($mask{chan}),\S+/ /) {
- $chan = lc $1;
- }
+ # forgot for about 2 years to implement channel keys when moving
+ # over to Net::IRC...
# hopefully validChan is right.
if (&validChan($chan)) {
&status("join: already on $chan");
} else {
&status("joining $b_blue$chan$ob");
# hopefully validChan is right.
if (&validChan($chan)) {
&status("join: already on $chan");
} else {
&status("joining $b_blue$chan$ob");
- if (!$conn->join($chan)) {
- &DEBUG("joinchan: join failed. trying connect!");
- &clearIRCVars();
- $conn->connect();
- }
+
+ return if ($conn->join($chan, $key));
+
+ &DEBUG("joinchan: join failed. trying connect!");
+ &clearIRCVars();
+ $conn->connect();
# deletion of $channels{chan} is done in &entryEvt().
}
}
# deletion of $channels{chan} is done in &entryEvt().
}
}
&DEBUG("mode: MODE $chan $modes");
&DEBUG("mode: MODE $chan $modes");
+ # should move to use Net::IRC's $conn->mode()... but too lazy.
rawout("MODE $chan $modes");
}
rawout("MODE $chan $modes");
}
foreach $chan (@chans) {
if (!&IsNickInChan($nick,$chan)) {
foreach $chan (@chans) {
if (!&IsNickInChan($nick,$chan)) {
- &status("Kick: $nick is not on $chan.") if (scalar @chans == 1);
+ &status("kick: $nick is not on $chan.") if (scalar @chans == 1);
next;
}
if (!exists $channels{$chan}{o}{$ident}) {
next;
}
if (!exists $channels{$chan}{o}{$ident}) {
- &status("Kick: do not have ops on $chan :(");
+ &status("kick: do not have ops on $chan :(");
next;
}
&status("Kicking $nick from $chan.");
next;
}
&status("Kicking $nick from $chan.");
- if ($msg eq "") {
- &rawout("KICK $chan $nick");
- } else {
- &rawout("KICK $chan $nick :$msg");
- }
+ $conn->kick($chan, $nick, $msg);
foreach $chan (@chans) {
if (!exists $channels{$chan}{o}{$ident}) {
foreach $chan (@chans) {
if (!exists $channels{$chan}{o}{$ident}) {
- &status("Ban: do not have ops on $chan :(");
+ &status("ban: do not have ops on $chan :(");
sub invite {
my($who, $chan) = @_;
sub invite {
my($who, $chan) = @_;
- rawout("INVITE $who $chan");
-}
+ # todo: check if $who or $chan are invalid.
+ $conn->invite($who, $chan);
+}
##########
# Channel related functions...
##########
# Channel related functions...
return &makeHostMask($nuh{$n});
} else {
$cache{on_who_Hack} = 1;
return &makeHostMask($nuh{$n});
} else {
$cache{on_who_Hack} = 1;
&status("clc: big change in limit for $chan ($delta);".
"going for it. (was: $l; now: ".($count+$plus).")");
&status("clc: big change in limit for $chan ($delta);".
"going for it. (was: $l; now: ".($count+$plus).")");
- &rawout("MODE $chan +l ".($count+$plus) );
+ $conn->mode($chan, "+l", $count+$plus);
$cache{chanlimitChange}{$chan} = time();
}
$cache{chanlimitChange}{$chan} = time();
}
if ( &IsParam("nickServ_pass") and !$nickserv) {
&DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)");
if ( &IsParam("nickServ_pass") and !$nickserv) {
&DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)");
- &rawout("WHO NickServ");
+ $conn->who("NickServ");
return 0;
}
# check for first hash then for next hash.
return 0;
}
# check for first hash then for next hash.
# ok, we're free to do whatever we want now. go for it!
$running = 1;
# ok, we're free to do whatever we want now. go for it!
$running = 1;
- # unfortunately, Net::IRC does not implement this :(
- # invalid command... what is it?
-# &rawout("NOTIFY $ident");
-# &DEBUG("adding self to NOTIFY list.");
+ $conn->ison($ident);
+ &DEBUG("adding self to NOTIFY/ISON.");
+
+ # Q, as on quakenet.org.
+ if (&IsParam("Q_pass")) {
+ &status("Authing to Q...");
+ &rawout("PRIVMSG Q\@CServe.quakenet.org :AUTH $param{'Q_user'} $param{'Q_pass'}");
+ }
my $get = ($event->args)[2];
open(DCCGET,">$get");
my $get = ($event->args)[2];
open(DCCGET,">$get");
- $self->new_get($nick,
- ($event->args)[2],
- ($event->args)[3],
- ($event->args)[4],
- ($event->args)[5],
- \*DCCGET
- );
+ $self->new_get($event, \*DCCGET);
+
} elsif ($type eq 'GET') { # SEND for us?
&status("DCC: Initializing SEND for $nick.");
$self->new_send($event->args);
} elsif ($type eq 'GET') { # SEND for us?
&status("DCC: Initializing SEND for $nick.");
$self->new_send($event->args);
} elsif ($type eq 'CHAT') {
&status("DCC: Initializing CHAT for $nick.");
$self->new_chat($event);
} elsif ($type eq 'CHAT') {
&status("DCC: Initializing CHAT for $nick.");
$self->new_chat($event);
+# $self->new_chat(1, $nick, $event->host);
} else {
&WARN("${b_green}DCC $type$ob (1)");
} else {
&WARN("${b_green}DCC $type$ob (1)");
&status("$b_blue$chan$ob: sync in ${delta_time}s.");
}
&status("$b_blue$chan$ob: sync in ${delta_time}s.");
}
my $i = scalar(keys %{ $channels{$chan} });
my $j = $cache{maxpeeps}{$chan} || 0;
my $i = scalar(keys %{ $channels{$chan} });
my $j = $cache{maxpeeps}{$chan} || 0;
- if (time() > $sched{shmFlush}{TIME} + 3600) {
+ if (time() > ($sched{shmFlush}{TIME} || time()) + 3600) {
&DEBUG("looks like schedulers died somewhere... restarting...");
&setupSchedulers();
}
&DEBUG("looks like schedulers died somewhere... restarting...");
&setupSchedulers();
}
### TODO: move this to &joinchan()?
$cache{jointime}{$chan} = &timeget();
### TODO: move this to &joinchan()?
$cache{jointime}{$chan} = &timeget();
} elsif ($nick =~ /^ChanServ$/i) { # chanserv.
&status("ChanServ: <== '$args'.");
} elsif ($nick =~ /^ChanServ$/i) { # chanserv.
&status("ChanServ: <== '$args'.");
next unless ( exists $channels{$_}{'l'} );
&DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
next unless ( exists $channels{$_}{'l'} );
&DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
}
$netsplit{lc $nick} = time();
}
$netsplit{lc $nick} = time();
if (scalar keys %netsplitservers) {
if (defined $limit) {
&status("chanlimit: netsplit; removing it for $chan.");
if (scalar keys %netsplitservers) {
if (defined $limit) {
&status("chanlimit: netsplit; removing it for $chan.");
- &rawout("MODE $chan -l");
+ $conn->mode($chan, "-l");
$cache{chanlimitChange}{$chan} = time();
&status("chanlimit: netsplit; removed.");
}
$cache{chanlimitChange}{$chan} = time();
&status("chanlimit: netsplit; removed.");
}
}
if (!exists $channels{$chan}{'o'}{$ident}) {
}
if (!exists $channels{$chan}{'o'}{$ident}) {
- &status("ChanLimit: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
+ &status("chanlimit: dont have ops on $chan.") unless (exists $cache{warn}{chanlimit}{$chan});
$cache{warn}{chanlimit}{$chan} = 1;
&chanServCheck($chan);
next;
$cache{warn}{chanlimit}{$chan} = 1;
&chanServCheck($chan);
next;
delete $cache{warn}{chanlimit}{$chan};
if (!defined $limit) {
delete $cache{warn}{chanlimit}{$chan};
if (!defined $limit) {
- &status("chanLimit: setting for first time or from netsplit, for $chan");
+ &status("chanlimit: setting for first time or from netsplit, for $chan");
}
if (exists $cache{chanlimitChange}{$chan}) {
my $delta = time() - $cache{chanlimitChange}{$chan};
if ($delta < $interval*60) {
}
if (exists $cache{chanlimitChange}{$chan}) {
my $delta = time() - $cache{chanlimitChange}{$chan};
if ($delta < $interval*60) {
- &DEBUG("chanLimit: not going to change chanlimit! ($delta<$interval*60)");
+ &DEBUG("chanlimit: not going to change chanlimit! ($delta<$interval*60)");
- &rawout("MODE $chan +l $newlimit");
+ $conn->mode($chan, "+l", $newlimit);
$cache{chanlimitChange}{$chan} = time();
}
}
$cache{chanlimitChange}{$chan} = time();
}
}
&::notice($who, "|= Last time read $timestr ago");
}
&::notice($who, "|= Last time read $timestr ago");
}
my @sorted;
foreach (@new) {
my @sorted;
foreach (@new) {
-
- for (my $i=0; $i<=scalar(@sorted); $i++) {
+
+ for ($i=0; $i<=scalar(@sorted); $i++) {
my $news = $sorted[$i];
next unless (defined $news);
my $age = time() - $::news{$chan}{$news}{Time};
my $news = $sorted[$i];
next unless (defined $news);
my $age = time() - $::news{$chan}{$news}{Time};
- &::notice($who, sprintf("\002[\002%2d\002]\002 %s",
- $i, $news) );
-# $i, $_, &::Time2String($age) ) );
+ $::conn->schedule(int((2+$i)/2), sub {
+ &::notice($who, sprintf("\002[\002%2d\002]\002 %s",
+ $i, $news) );
+# $i, $_, &::Time2String($age) ) );
+ } );
- &::notice($who, "|= to read, do \002news $chan read <#>\002 or \002news $chan read <keyword>\002");
+ # todo: implement throttling via schedule into ¬ice() / &msg().
+ $::conn->schedule(int((2+$i)/2), sub {
+ &::notice($who, "|= to read, do \002news $chan read <#>\002 or \002news $chan read <keyword>\002");
+ } );
# lame hack to prevent dupes if we just ignore it.
my $x = $::newsuser{$chan}{$who};
# lame hack to prevent dupes if we just ignore it.
my $x = $::newsuser{$chan}{$who};
&status("rootwarn: Detected root user; notifying user");
} else {
&status("rootwarn: Detected root user; notifying nick and channel.");
&status("rootwarn: Detected root user; notifying user");
} else {
&status("rootwarn: Detected root user; notifying nick and channel.");
- rawout("PRIVMSG $chan :ROO".("O" x int(rand 68))."T has landed!");
+ &msg($chan, "ROO".("O" x int(rand 68))."T has landed!");
}
if ($_ = &getFactoid("root")) {
}
if ($_ = &getFactoid("root")) {
$topic{$chan}{'Last'} = $topic;
$topic{$chan}{'Who'} = $orig{who}."!".$uh;
$topic{$chan}{'Time'} = time();
$topic{$chan}{'Last'} = $topic;
$topic{$chan}{'Who'} = $orig{who}."!".$uh;
$topic{$chan}{'Time'} = time();
- rawout("TOPIC $chan :$topic");
+ $conn->topic($chan, $topic);
&topicAddHistory($chan,$topic);
return 1;
}
&topicAddHistory($chan,$topic);
return 1;
}
my @results;
my $file = $file{utm};
my @results;
my $file = $file{utm};
+ &::DEBUG("uGI: reading $file...");
+
if (!open(IN, $file)) {
&status("Writing uptime file for first time usage (nothing special).");
open(OUT,">$file");
if (!open(IN, $file)) {
&status("Writing uptime file for first time usage (nothing special).");
open(OUT,">$file");
}
&status("jumping servers... $server...");
}
&status("jumping servers... $server...");
- &rawout("QUIT :jumping to $server");
+ $conn->quit("jumping to $server");
if (&irc($server,$port) == 0) {
&ircloop();
if (&irc($server,$port) == 0) {
&ircloop();
+ # hack to support channel +o as "+o" in bot user file.
+ # requires +O in user file.
+ # is $who arg lowercase?
+ if (exists $channels{$chan}{o}{ $orig{who} } && &IsFlag("O") eq "O") {
+ &status("Gave $who/$chan +o (+O)\'ness");
+ $users{$userHandle}{FLAGS} =~ s/o//g;
+ $users{$userHandle}{FLAGS} .= "o";
+ }
+
# check if we have our head intact.
if ($lobotomized) {
if ($addressed and IsFlag("o") eq "o") {
# check if we have our head intact.
if ($lobotomized) {
if ($addressed and IsFlag("o") eq "o") {
$cache{countryStats}{chan} = $chan;
$cache{countryStats}{mtype} = $msgType;
$cache{countryStats}{who} = $who;
$cache{countryStats}{chan} = $chan;
$cache{countryStats}{mtype} = $msgType;
$cache{countryStats}{who} = $who;
$last{buflen} = 0;
$last{say} = "";
$last{msg} = "";
$last{buflen} = 0;
$last{say} = "";
$last{msg} = "";
-$userHandle = "default";
+$userHandle = "_default";
$wingaterun = time();
$firsttime = 1;
$utime_userfile = 0;
$wingaterun = time();
$firsttime = 1;
$utime_userfile = 0;
&status("--- Start of quit.");
$ident ||= "blootbot"; # lame hack.
&status("--- Start of quit.");
$ident ||= "blootbot"; # lame hack.
- &closeDCC() if (&whatInterface() =~ /IRC/);
&closePID();
&closeStats();
&closePID();
&closeStats();
- &seenFlush() if (&whatInterface() =~ /IRC/);
- &quit($param{'quitMsg'}) if (&whatInterface() =~ /IRC/);
+ # shutdown IRC and related components.
+ if (&whatInterface() =~ /IRC/) {
+ &closeDCC();
+ &seenFlush();
+ &quit($param{'quitMsg'});
+ }
&writeUserFile();
&writeChanFile();
&writeUserFile();
&writeChanFile();
- &uptimeWriteFile() if (&ChanConfList("uptime"));
+ if (&IsChanConf("uptime")) {
+ &DEBUG("going to write uptime file info.");
+ }
+ &uptimeWriteFile() if (&IsChanConf("uptime"));
&News::writeNews() if (&ChanConfList("news"));
&closeDB();
&closeSHM($shm);
&News::writeNews() if (&ChanConfList("news"));
&closeDB();
&closeSHM($shm);
my($param,$c) = @_;
if (!defined $param) {
my($param,$c) = @_;
if (!defined $param) {
- &WARN("param == NULL.");
+ &WARN("gCC: param == NULL.");
$param{'VERBOSITY'} = 1;
&loadConfig($bot_config_dir."/blootbot.config");
$param{'VERBOSITY'} = 1;
&loadConfig($bot_config_dir."/blootbot.config");
- foreach ("ircNick", "ircUser", "ircName", "DBType", "tempDir") {
+ foreach ( qw(ircNick ircUser ircName DBType tempDir) ) {
next if &IsParam($_);
&ERROR("Parameter $_ has not been defined.");
exit 1;
next if &IsParam($_);
&ERROR("Parameter $_ has not been defined.");
exit 1;
foreach ( &getPerlFiles("$bot_src_dir/$interface") ) {
my $mod = "$bot_src_dir/$interface/$_";
foreach ( &getPerlFiles("$bot_src_dir/$interface") ) {
my $mod = "$bot_src_dir/$interface/$_";
- &status("Loading Modules \"$mod\"");
+ # hrm... use another config option besides DEBUG to display
+ # change in memory usage.
+ &status("Loading Modules \"$mod\"") if (!&IsParam("DEBUG"));
eval "require \"$mod\"";
if ($@) {
&ERROR("require \"$mod\" => $@");
eval "require \"$mod\"";
if ($@) {
&ERROR("require \"$mod\" => $@");