'Identifier' => 'freshmeat', 'Cmdstats' => 'Freshmeat',
'Forker' => 1, 'Help' => 'freshmeat') );
&addCmdHook("extra", 'verstats', ('CODEREF' => 'do_verstats' ) );
+&addCmdHook("extra", 'weather', ('CODEREF' => 'Weather::Weather',
+ 'Identifier' => 'weather', 'Help' => 'weather',
+ 'Cmdstats' => 'Weather') );
###
### END OF ADDING HOOKS.
$reply .= ". Started the scan ".&Time2String(time() - $wingaterun)." ago";
}
- &performStrictReply("$reply.");
+ &pSReply("$reply.");
return;
}
}
close IDX1;
- &::performStrictReply( &::formListReply(0, "New debian packages:", @new) );
+ &::pSReply( &::formListReply(0, "New debian packages:", @new) );
}
sub do_verstats {
$wtime_userfile = time();
&status("--- Saved USERFILE ($cusers users; $cbans bans; $cignore ignore) at $time");
if (defined $msgType and $msgType =~ /^chat$/) {
- &performStrictReply("--- Writing user file...");
+ &pSReply("--- Writing user file...");
}
}
while (<IN>) {
chop;
- next if /^$/;
+ next if /^\s*$/;
+ next if /^\// or /^\;/; # / or ; are comment lines.
if (/^(\S+)\s*$/) {
$chan = $1;
### TODO: check against valid params.
foreach $chan (keys %chanconf) {
foreach (keys %{ $chanconf{$chan} }) {
- next unless (/^[+-]/);
+ next unless /^[+-]/;
+
&WARN("invalid param: chanconf{$chan}{$_}; removing.");
delete $chanconf{$chan}{$_};
undef $chanconf{$chan}{$_};
next if ($chan eq "_default");
next unless (exists $chanconf{$chan}{$opt});
next unless ($val eq $chanconf{$chan}{$opt});
+
push(@chans,$chan);
delete $chanconf{$chan}{$opt};
}
" chans) at $time");
if (defined $msgType and $msgType =~ /^chat$/) {
- &performStrictReply("--- Writing chan file...");
+ &pSReply("--- Writing chan file...");
}
}
return 1;
} else {
&status("DCC CHAT: <$who> $message -- not enough flags.");
- &performStrictReply("error: you do not have enough flags for that. ($flag required)");
+ &pSReply("error: you do not have enough flags for that. ($flag required)");
return 0;
}
}
if (exists $help{$topic}) {
foreach (split /\n/, $help{$topic}) {
- &performStrictReply($_);
+ &pSReply($_);
}
} else {
&pSReply("no help on $topic. Use 'help' without arguments.");
# generate a hash list.
foreach (@files) {
- if (/^(.*\/)(.*?)$/) {
- $files{$1}{$2} = 1;
- }
+ next unless /^(.*\/)(.*?)$/;
+
+ $files{$1}{$2} = 1;
}
@files = (); # reuse the array.
--- /dev/null
+#
+# DumpVars2.pl: Perl variables dumper ][.
+# Maintained: dms
+# Version: v0.1 (20020329)
+# Created: 20020329
+#
+
+#use strict;
+use Devel::Symdump;
+
+sub symdumplog {
+ my ($line) = @_;
+
+ if (fileno SYMDUMP) {
+ print SYMDUMP $line."\n";
+ } else {
+ &status("SD: ".$line);
+ }
+}
+
+sub symdumpAll {
+ my $o = Devel::Symdump->rnew();
+
+ # scalars.
+ foreach ($o->scalars) {
+# &symdumpRecur($_);
+ symdumplog(" scalar($_)");
+ }
+}
+
+sub symdumpRecur {
+ my $x = shift;
+
+ if (ref $x eq "HASH") {
+ foreach (keys %$x) {
+ &symdumpRecur($_);
+ }
+ } else {
+ symdumplog("unknown: $x");
+ }
+}
+
+sub symdumpAllFile {
+ &DEBUG("before open");
+ if (&IsParam("symdumpLogFile")) {
+ my $file = $param{'symdumpLogFile'};
+ &status("opening fh to symdump ($file)");
+ if (!open(SYMDUMP,">$file")) {
+ &ERROR("cannot open dumpvars.");
+ return;
+ }
+ }
+ &DEBUG("after open");
+
+ symdumpAll();
+
+ if (fileno SYMDUMP) {
+ &status("closing fh to symdump");
+ close SYMDUMP;
+ }
+
+ &status("SD: count == $countlines");
+}
+
+1;
#
# News.pl: Advanced news management
# Author: dms
-# Version: v0.3 (20014012)
+# Version: v0.3 (20010412)
# Created: 20010326
# Notes: Testing done by greycat, kudos!
#
} elsif ($what =~ /^(expire|text|desc)(\s+(.*))?$/i) {
# shortcut/link.
# nice hack.
+ my $cmd = $1;
my($arg1,$arg2) = split(/\s+/, $3, 2);
- &set("$arg1 $1 $arg2");
+ &set("$arg1 $cmd $arg2");
} elsif ($what =~ /^help(\s+(.*))?$/i) {
&::help("news $2");
close NEWS;
my $cn = scalar(keys %::news);
+ return unless ($ci or $cn or $cu);
+
&::status("News: read ".
$ci. &::fixPlural(" item", $ci). " for ".
$cn. &::fixPlural(" chan", $cn). ", ".
$cu. &::fixPlural(" user", $cu), " cache"
- ) if ($ci or $cn or $cu);
+ );
}
sub writeNews {
return;
}
+ # should define this at the top of file.
my $file = "$::bot_base_dir/blootbot-news.txt";
if (fileno NEWS) {
- &::ERROR("fileno NEWS exists, should never happen.");
+ &::ERROR("News: write: fileno NEWS exists, should never happen.");
return;
}
my $item = &getNewsItem($str);
if (!defined $item or !scalar keys %{ $::news{$chan}{$item} }) {
# todo: numerical check.
- if ($str =~ /^(\d+) (\d+)$/ or
- $str =~ /^(\d+)-(\d+)$/ or
- $str =~ /^-(\d+)$/ or $str =~ /^(\d+)-$/ or 0
+ if ($str =~ /^(\d+)[-, ](\d+)$/ or
+ $str =~ /^-(\d+)$/ or
+ $str =~ /^(\d+)-$/ or 0
) {
- &::notice($who, "We don't support multiple requests of news items, sorry.");
+ &::notice($who, "We don't support multiple requests of news items yet. Sorry.");
return;
}
my($tchan, $flag) = @_;
# hack hack hack.
- $chan ||= $tchan;
- $who = $::who;
+ $chan ||= $tchan;
+ $who = $::who;
# todo: if chan = undefined, guess.
# if (!exists $::news{$chan}) {
if (defined $t and ($t == 0 or $t == -1)) {
if ($flag) {
- &::notice($who, "if you want to read news, try /msg $::ident news or /msg $::ident news notify");
+ &::notice($who, "if you want to read news, try \002/msg $::ident news $chan\002 or \002/msg $::ident news $chan notify\002");
} else {
&::DEBUG("news: not displaying any new news for $who");
return;
# $i, $_, &::Time2String($age) ) );
}
- &::notice($who, "|= to read, do 'news read <#>' or 'news read <keyword>'");
+ &::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};
return;
}
+ # dump variables ][.
+ if ($message =~ /^symdump$/i) {
+ return unless (&hasFlag("o"));
+ return unless (&IsParam("symdump"));
+
+ &status("Dumping all variables...");
+ &symdumpAllFile();
+
+ return;
+ }
+
# kick.
if ($message =~ /^kick(\s+(\S+)(\s+(\S+))?)?/) {
return unless (&hasFlag("o"));
--- /dev/null
+#
+# Weather.pl: Frontend to GEO::Weather (weather.com).
+# Author: logeist
+# Version: v0.1 (20020512).
+# Created: 20020512.
+#
+
+package Weather;
+
+use IO::Socket;
+use strict;
+
+###local $SIG{ALRM} = sub { die "alarm\n" };
+
+sub Weather {
+ my ($query) = @_;
+ my (@weatherloc, $whash);
+ my $retval;
+
+ return unless &::loadPerlModule("Geo::Weather");
+ my $weather = new Geo::Weather;
+
+ for ($query) {
+ s/^[\s\t]+//;
+ s/[\s\t]+$//;
+ s/[\s\t]+/ /;
+ }
+
+ @weatherloc = split /,\s*/, $query;
+
+ if (@weatherloc == 1) {
+ $whash = $weather->get_weather ("$weatherloc[0]");
+ } else {
+ $whash = $weather->get_weather ("$weatherloc[0]", "$weatherloc[1]");
+ }
+
+ if (!ref $whash) {
+ $retval = "I'm sorry, not able to return weather conditions for $query";
+ &::performStrictReply($retval);
+ undef $weather;
+ return;
+ }
+
+ $retval = "Current conditions in $whash->{city}, $whash->{state}: $whash->{cond}, $whash->{temp}° F. Winds $whash->{wind} MPH. Dewpoint: $whash->{dewp}° F, Relative Humidity: $whash->{humi}%,";
+
+ if ($whash->{visb} eq 'Unlimited') {
+ $retval .= " Visibility: $whash->{visb}, ";
+ } else {
+ $retval .= " Visibility: $whash->{visb} mi., ";
+ }
+
+ $retval .= " Barometric Pressure: $whash->{baro} in.";
+ if($whash->{heat} ne 'N/A') {
+ $retval .= " Heat Index: $whash->{heat}° F.";
+ }
+
+ &::performStrictReply($retval);
+ undef $weather;
+}
+
+1;
# customized random message.
my $tmp = (rand() < 0.5) ? ", $who" : "";
- &performStrictReply(&getRandom(keys %{ $lang{'hello'} }) . $tmp);
+ &pSReply( &getRandom(keys %{ $lang{'hello'} }) . $tmp );
return;
}
&status("random praise detected");
my $tmp = (rand() < 0.5) ? "thanks $who " : "";
- &performStrictReply($tmp.":)");
+ &pSReply($tmp.":)");
return;
}
my $IPC_PRIVATE = 0;
my $size = 2000;
+ if (&IsParam("noSHM")) {
+ &status("Created shared memory: disabled. [bot may become unreliable]");
+ return 0;
+ }
+
if (defined( $_ = shmget($IPC_PRIVATE, $size, 0777) )) {
&status("Created shared memory (shm) key: [$_]");
return $_;
my $size = 3*80;
my $retval = '';
+ return '' if (&IsParam("noSHM"));
+
if (shmread($key,$retval,$position,$size)) {
return $retval;
} else {
my $position = 0;
my $size = 80*3;
+ return if (&IsParam("noSHM"));
+
# NULL hack.
### TODO: create shmClear to deal with this.
if ($str !~ /^$/) {
&closeDB();
&closeSHM($shm);
&dumpallvars() if (&IsParam("dumpvarsAtExit"));
+ &symdumpAll() if (&IsParam("symdumpAtExit"));
&closeLog();
&closeSQLDebug() if (&IsParam("SQLDebug"));
"debianExtra" => "DebianExtra.pl",
"dict" => "Dict.pl",
"dumpvars" => "DumpVars.pl",
+ "symdump" => "DumpVars2.pl",
"factoids" => "Factoids.pl",
"freshmeat" => "Freshmeat.pl",
"kernel" => "Kernel.pl",
my @myModulesLoadNow;
my @myModulesReloadNot;
BEGIN {
- @myModulesLoadNow = ('topic', 'uptime', 'news', 'rootWarn');
+ @myModulesLoadNow = ('topic', 'uptime', 'news', 'rootWarn', 'symdump');
@myModulesReloadNot = ('IRC/Irc.pl','IRC/Schedulers.pl');
}