From: dms Date: Sat, 16 Feb 2002 12:16:49 +0000 (+0000) Subject: - patch from Morten Brix Pedersen . Thanks! X-Git-Url: https://git.donarmstrong.com/?p=infobot.git;a=commitdiff_plain;h=c68ac9b2d4b88535c1a2cfa695f6c4f683f0373c - patch from Morten Brix Pedersen . Thanks! - documentation and code update for setting up of bot. - minor update to help file. - stats.sql to support channel (code supports with or without channel column, from memory) - ircII.servers changed to blootbot.servers 'ln -fs ircII.servers blootbot.servers' for the lazy. - setup/setup.pl now runs! but does it work? - debian: cosmetic code update. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@549 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/INSTALL b/INSTALL index 13d7866..ebcee18 100644 --- a/INSTALL +++ b/INSTALL @@ -1,11 +1,12 @@ Method of installation. ----------------------- -- Move blootbot.config to blootbot.config.used -- Copy sample.config to blootbot.config +- Move files/sample/sample.config to files/blootbot.config - Edit files/blootbot.config, modify to taste. +- Edit files/blootbot.chan to set which channels to join. - Edit files/ircII.server to modify list of IRC servers to connect. -- Depends on: + +- Install the following Perl modules: - Net::IRC perl module - Debian: (apt-get install libnet-irc-perl) - WWW::Search @@ -15,7 +16,7 @@ Method of installation. - HTML::Parser - Debian: (apt-get install libhtml-parser-perl) -- Choice of database +- Choose your database: - MySQL (see INSTALL.mysql) - PgSQL (see INSTALL.pgsql, DOES NOT WORK YET) - Berkeley DBM (see INSTALL.dbm) diff --git a/INSTALL.mysql b/INSTALL.mysql index 9e816db..a1c6eba 100644 --- a/INSTALL.mysql +++ b/INSTALL.mysql @@ -1,8 +1,8 @@ INSTALL.mysql ---------------- -- Debian: (apt-get install mysql-server) -- Debian: (apt-get install libdbd-mysql-perl) +- Install a MySQL server and the DBI Perl modules. + - Debian: (apt-get install mysql-server libdbd-mysql-perl) - run 'mysqladmin -u root -p create ' - run 'setup/setup.pl' @@ -17,11 +17,15 @@ INSTALL.mysql to mysql. ADDITIONAL NOTES: - HOW TO ADD NEW USER MANUALLY - CREATE DATABASE @DBNAME@ - INSERT INTO user VALUES ('localhost','@USER@',password('@PASS@'), - 'Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N'); - INSERT INTO db VALUES ('localhost','@DBNAME@','@USER@', - 'Y','Y','Y','Y','Y','N','N','N','N','N'); - GRANT SELECT,INSERT,UPDATE,DELETE ON @DBNAME@ TO @USER@ - FLUSH PRIVILEGES +----------------- + You can add a new user manually by connecting to MySQL and performing these + commands: + + $ mysql -u root -p + + mysql> CREATE DATABASE blootbot; + mysql> GRANT USAGE ON *.* TO 'user'@'localhost' IDENTIFIED BY 'yourpassword'; + mysql> GRANT ALL PRIVILEGES ON blootbot.* TO 'user'@'localhost'; + +for the mysql that are on apt the bot (#debian@OPN), they are available +at http://emu.res.cmu.edu/~apt/blootbot/apt.sql.bz2 diff --git a/INSTALL.patches b/INSTALL.patches index 35cd3ea..3ff49d0 100644 --- a/INSTALL.patches +++ b/INSTALL.patches @@ -9,4 +9,11 @@ INSTALL.patches - alternatively, move the files from patches/ - mv patches/Google.pm /usr/lib/perl5/WWW/Search/ - - mv patches/Connections.pm /usr/lib/perl5/Net/IRC/ + +UPDATE +---------------------- +you now not need to patch Net::IRC for the forking patch, it's done +inside the bot code. Unfortunately, Net::IRC 0.70 has buggy code that +does not detect DCC CHAT properly. To fix the problems identified, +download the debs (convert to tarball if on non-debian system) from: +http://nyip.net/~apt/ diff --git a/README b/README index 9d64299..5beabf9 100644 --- a/README +++ b/README @@ -50,11 +50,7 @@ cases. preliminary pgsql support has been added but someone with pgperl knowledge needs to fix it up or at least unify the module with mysql. INSTALLATION - - Read INSTALL and INSTALL.patches - - Copy files/sample.config to files/blootbot.config - - Edit files/blootbot.config - - ./blootbot - + - Read the included INSTALL file NOTICE Be warned that this bot consumes quite a lot of memory upon start diff --git a/files/blootbot.chan b/files/blootbot.chan index bf52c9a..e6e18b5 100644 --- a/files/blootbot.chan +++ b/files/blootbot.chan @@ -1,29 +1,42 @@ -#v1: blootbot -- blootbot -- written Sun Jan 28 20:36:31 2001 +#v1: blootbot -- blootbot -- written Sat Feb 9 17:51:31 2002 #debian-bots - ++freshmeat + +allowTelling +autojoin - -freshmeat + +babelfish + factoidDeleteDelay 7 + ircTextCounters heh hah :) ? hi lol +joinfloodCheck limitcheckInterval 10 limitcheckPlus 10 + +news + newsDefaultExpire 7 + +newsKeepRead + +newsNotifyAll + +rootWarn + rootWarnMode aggressive + +#nophear + +autojoin _default +allowConv +allowDNS - -babelfish + +chanlimitcheck + chanlimitcheckInterval 10 + chanlimitcheckPlus 10 +cookie +countdown +debian +debianExtra debianRefreshInterval 7 +dict + +factoidArguments floodMessages 10:30 floodRepeat 2:10 +freshmeat - -freshmeatForFactoid freshmeatRefreshInterval 24 - -insult + +insult +karma +kernel +lart @@ -32,10 +45,6 @@ _default +nickometer +perlMath +quote - -randomFactoid - -randomQuote - +rootWarn - rootWarnMode passive +search +seen seenFlushInterval 60 @@ -46,7 +55,6 @@ _default +tell +topic +units - +uptime +userinfo +wwwsearch diff --git a/files/blootbot.help b/files/blootbot.help index 5f48ac2..b6d4fc6 100644 --- a/files/blootbot.help +++ b/files/blootbot.help @@ -181,6 +181,7 @@ topic: End of help. part: D: Leave a channel (DCC only) part: U: ## <#channel> part: E: ## #debian +part: NOTE: /kick is an alternative seen: D: Report last seen time for somebody seen: U: ## @@ -221,10 +222,10 @@ unlock: E: ## abuse dollar variables: D: To be used in factoids dollar variables: $date - ... dollar variables: $time - ... -dollar variables: $who - nick that caused the factoid to be retrieved -dollar variables: $username - the username, not the nick -dollar variables: $host - ... -dollar variables: $channel - ... +dollar variables: $who - nick of factoid requester +dollar variables: $username - username of factoid requester +dollar variables: $host - hostname of factoid requester +dollar variables: $channel - channel from which the factoid was requested dollar variables: $lastspeaker - ... dollar variables: $factoid - ... @@ -306,10 +307,7 @@ nickometer: E: ## unknown_lamer nickometer: E: ## #debian-bots news: D: News functin -news: U: ## [chan] add -news: U: ## [chan] del -news: U: ## [chan] mod -news: U: ## [chan] set +news: U: ## [chan] news add: D: Add news items news add: U: news [chan] add @@ -341,3 +339,8 @@ news mod: D: Modify a news item (todo: modify Text aswell) news mod: E: news [chan] mod <item> s/<from>/<to>/[g] news mod: E: news mod 1 s/test/Test/ news mod: E: news mod test s/test/Test/g + +tell: D: Tell someone about a factoid or command +tell: U: tell <who> -?about <what> +tell: E: tell me about blootbot +tell: E: tell someone -about testing diff --git a/files/blootbot.lang b/files/blootbot.lang index dedbf20..d475fff 100644 --- a/files/blootbot.lang +++ b/files/blootbot.lang @@ -23,6 +23,8 @@ dunno I give up, what is it? I don't know, could you explain it? I'm not sure, is it larger than a breadbox? + parse error: dunno what the heck you're talking about + are you smoking crack? # moron reply. moron diff --git a/files/blootbot.users b/files/blootbot.users index 871f63d..73a5727 100644 --- a/files/blootbot.users +++ b/files/blootbot.users @@ -1,19 +1,11 @@ -#v1: blootbot -- blootbot -- written Sun Jan 28 20:36:30 2001 +#v1: blootbot -- blootbot -- written Sat Feb 9 17:51:31 2002 _default ---FLAGS +mrt +--FLAGS mrt --HOSTS *!*@* -stuph ---FLAGS +mrt ---HOSTS - xk ---FLAGS +mrsteon ---HOSTS *!root@*.home.org ---HOSTS *!xk@*.home.org ---PASS AAH2sny6Y3Y7Y - -::* bans -- *!*@*.il:+0:+0:0:980679318:you jews suck +--FLAGS mrsteon +--HOSTS *!xk@superbox.home.org +--PASS 5K/rmJPzwxJhU diff --git a/setup/stats.sql b/setup/stats.sql index d1b7b2f..4a585b1 100644 --- a/setup/stats.sql +++ b/setup/stats.sql @@ -1,8 +1,10 @@ CREATE TABLE stats ( nick VARCHAR(20) NOT NULL, type VARCHAR(8) NOT NULL, + channel VARCHAR(16) NOT NULL DEFAULT "PRIVATE", + time INT UNSIGNED DEFAULT 'UNIX_TIMESTAMP()', counter SMALLINT UNSIGNED DEFAULT '0', - PRIMARY KEY (nick,type) + PRIMARY KEY (nick,type,channel) ); diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index e1cd950..1a55669 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -280,6 +280,11 @@ sub Modules { $itc =~ s/([^\w\s])/\\$1/g; my $z = join '|', split ' ', $itc; + if ($msgType eq "privmsg" and $message =~ / ($mask{chan})$/) { + &DEBUG("ircTC: privmsg detected; chan = $1"); + $chan = $1; + } + if ($message =~ /^_stats(\s+(\S+))$/i) { &textstats_main($2); return; diff --git a/src/Files.pl b/src/Files.pl index b302604..add4a4d 100644 --- a/src/Files.pl +++ b/src/Files.pl @@ -49,7 +49,7 @@ sub loadLang { # File: Irc Servers list. sub loadIRCServers { - my ($file) = $bot_config_dir."/ircII.servers"; + my ($file) = $bot_config_dir."/blootbot.servers"; @ircServers = (); %ircPort = (); diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 957ca20..74087d0 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -1169,7 +1169,8 @@ sub on_chanfull { my ($self, $event) = @_; my @args = $event->args; - &DEBUG("on_chanfull: args => @args"); + &status(">>> chanfull/$b_blue$args[1]$ob"); + &joinNextChan(); } @@ -1177,15 +1178,18 @@ sub on_inviteonly { my ($self, $event) = @_; my @args = $event->args; - &DEBUG("on_inviteonly: args => @args"); + &status(">>> inviteonly/$b_cyan$args[1]$ob"); + &joinNextChan(); } sub on_banned { my ($self, $event) = @_; my @args = $event->args; + my $chan = $args[1]; + + &status(">>> banned/$b_blue$chan$ob $b_cyan$args[0]$ob"); - &DEBUG("on_banned: args => @args"); &joinNextChan(); } diff --git a/src/Modules/Debian.pl b/src/Modules/Debian.pl index ffda84f..48ce830 100644 --- a/src/Modules/Debian.pl +++ b/src/Modules/Debian.pl @@ -89,7 +89,7 @@ sub DebianDownload { $file =~ s/##DIST/$dist/g; my $update = 0; - if ( -f $file) { + if ( -f $file ) { my $last_refresh = (stat $file)[9]; $update++ if (time() - $last_refresh > $refresh); } else { @@ -222,7 +222,7 @@ sub searchContents { s/##DIST/$dist/g; next unless ( -f "$debian_dir/$_" ); - push(@files, "$debian_dir/$_" ); + push(@files, "$debian_dir/$_"); } if (!scalar @files) { @@ -239,26 +239,27 @@ sub searchContents { $regex =~ s/\?/./g; open(IN,"zegrep -h '$grepRE' $files |"); + # wonderful abuse of last and next and unless ;) while (<IN>) { - if (/^\.?\/?(.*?)[\t\s]+(\S+)\n$/) { - my ($file,$package) = ("/".$1,$2); - if ($query =~ /[\/\*\\]/) { - next unless (eval { $file =~ /$regex/ }); - return unless &checkEval($@); - } else { - my ($basename) = $file =~ /^.*\/(.*)$/; - next unless (eval { $basename =~ /$regex/ }); - return unless &checkEval($@); - } - next if ($query !~ /\.\d\.gz/ and $file =~ /\/man\//); - next if ($front and eval { $file !~ /^\/$query/ }); - return unless &checkEval($@); + last if ($found > 100); + + next unless if (/^\.?\/?(.*?)[\t\s]+(\S+)\n$/); - $contents{$package}{$file} = 1; - $found++; + my ($file,$package) = ("/".$1,$2); + if ($query =~ /[\/\*\\]/) { + next unless (eval { $file =~ /$regex/ }); + return unless &checkEval($@); + } else { + my ($basename) = $file =~ /^.*\/(.*)$/; + next unless (eval { $basename =~ /$regex/ }); + return unless &checkEval($@); } + next if ($query !~ /\.\d\.gz/ and $file =~ /\/man\//); + next if ($front and eval { $file !~ /^\/$query/ }); + return unless &checkEval($@); - last if ($found > 100); + $contents{$package}{$file} = 1; + $found++; } close IN; @@ -277,7 +278,7 @@ sub searchContents { } my $file = "$::param{tempDir}/$::who.txt"; - if (!open(OUT,">$file")) { + if (!open OUT, ">$file") { &::ERROR("Debian: cannot write file for dcc send."); return; } @@ -497,8 +498,10 @@ sub searchDesc { &::WARN("sD: package == NULL?"); next; } + $desc{$package} = $desc; $package = ""; + } else { &::WARN("debian: invalid line: '$_'. (2)"); } @@ -526,11 +529,11 @@ sub generateIncoming { ### STATIC URL. my %ftp = &::ftpList("llug.sep.bnl.gov", "/pub/debian/Incoming/"); - if (!open(PKG,">$pkgfile")) { + if (!open PKG, ">$pkgfile") { &::ERROR("cannot write to pkg $pkgfile."); return 0; } - if (!open(IDX,">$idxfile")) { + if (!open IDX, ">$idxfile") { &::ERROR("cannot write to idx $idxfile."); return 0; } @@ -788,7 +791,7 @@ sub infoStats { next; } - open(IN,"zcat $file 2>&1 |"); + open(IN, "zcat $file 2>&1 |"); if (! -e $file) { &::DEBUG("deb: iS: $file does not exist."); @@ -877,7 +880,7 @@ sub generateIndex { &DebianDownload($dist, &fixDist($dist, %urlpackages) ); &::status("Debian: generating index for '$dist'."); - if (!open(OUT,">$idx")) { + if (!open OUT, ">$idx") { &::ERROR("cannot write to $idx."); return 0; } @@ -921,7 +924,7 @@ sub validPackage { &::DEBUG("deb: validPackage($package, $dist) called.") if ($debug); my $error = 0; - while (!open(IN, $debian_dir. "/Packages-$dist.idx")) { + while (!open IN, $debian_dir."/Packages-$dist.idx") { if ($error) { &::ERROR("Packages-$dist.idx does not exist (#1)."); return; @@ -956,16 +959,12 @@ sub searchPackage { my $file = $debian_dir."/Packages-$dist.idx"; my @files; my $error = 0; - my $warn = 0; - - if ($query =~ tr/A-Z/a-z/) { - $warn++; - } + my $warn = ($query =~ tr/A-Z/a-z/) ? 1 : 0; &::status("Debian: Search package matching '$query' in '$dist'."); - unlink $file if ( -z $file); + unlink $file if ( -z $file ); - while (!open(IN, $file)) { + while (!open IN, $file) { if ($dist eq "incoming") { &::DEBUG("deb: sP: dist == incoming; calling gI()."); &generateIncoming(); @@ -1065,11 +1064,12 @@ sub fixDist { ### TODO: what should we do if the sar wasn't done. $new{$debian_dir."/".$key} = $val; } + return %new; } sub DebianFind { - ### H-H-H-HACK HACK HACK :) + # HACK! HACK! HACK! my ($str) = @_; my ($dist, $query) = &getDistroFromStr($str); my @results = sort &searchPackage($str); @@ -1093,10 +1093,12 @@ sub debianCheck { ### TODO: remove the following loop (check if dir exists before) while (1) { last if (opendir(DEBIAN, $debian_dir)); + if ($error) { &::ERROR("dC: cannot opendir debian."); return; } + mkdir $debian_dir, 0755; $error++; } diff --git a/src/core.pl b/src/core.pl index 28c24bd..e8975c1 100644 --- a/src/core.pl +++ b/src/core.pl @@ -11,6 +11,7 @@ use strict; ### TODO: reorder. use vars qw( $bot_misc_dir $bot_pid $bot_base_dir $bot_src_dir + $bot_data_dir $bot_config_dir $bot_state_dir $bot_run_dir $answer $correction_plausible $talkchannel $bot_release $statcount $memusage $user $memusageOld $bot_version $dbh $shm $host $msg $noreply $conn $irc $learnok $nick $ident @@ -510,8 +511,7 @@ sub loadConfig { if (!open(FILE, $file)) { &ERROR("FAILED loadConfig ($file): $!"); - &status("Please copy files/sample.config to files/blootbot.config"); - &status(" and edit files/blootbot.config, modify to tastes."); + &status("Please read the INSTALL file on how to install and setup this file."); exit 0; }