]> git.donarmstrong.com Git - infobot.git/commitdiff
- patch from Morten Brix Pedersen <morten@wtf.dk>. Thanks!
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 16 Feb 2002 12:16:49 +0000 (12:16 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 16 Feb 2002 12:16:49 +0000 (12:16 +0000)
  - 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

14 files changed:
INSTALL
INSTALL.mysql
INSTALL.patches
README
files/blootbot.chan
files/blootbot.help
files/blootbot.lang
files/blootbot.users
setup/stats.sql
src/CommandStubs.pl
src/Files.pl
src/IRC/IrcHooks.pl
src/Modules/Debian.pl
src/core.pl

diff --git a/INSTALL b/INSTALL
index 13d7866ec3db346995f40e94a6f8f4134899e172..ebcee18b299e100fba879d6a48cfbb7d91719680 100644 (file)
--- 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)
index 9e816db446e23054ea3b3fd58beceac6e09a2fb4..a1c6ebaa21a1ea33d505d94ec35ab2386996e610 100644 (file)
@@ -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 <DB NAME>'
 - 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
index 35cd3eaabbda590bc0377a31418aa4228290ae9d..3ff49d0b03b0a978b04f0d100d6509623b888e28 100644 (file)
@@ -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 9d64299b359ca4383d470cd11f1c6d45a677ff86..5beabf96af16011cbd4687d237eb057504753df0 100644 (file)
--- 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
index bf52c9ab2e315ce6f9b2add7f1ecacf6a02e95ae..e6e18b5a81807e5a14f48b43483a53e01ce18a4a 100644 (file)
@@ -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
 
index 5f48ac2fea999694ba301fd2bc6773c2e706806c..b6d4fc661bc0fd3e22ff483af03271ba9d3ba26f 100644 (file)
@@ -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: ## <nick>
@@ -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] <add,del,mod,set,latest,read,help>
 
 news add: D: Add news items
 news add: U: news [chan] add <title>
@@ -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
index dedbf20fd68f98a2078c2b2da03c045733b52db4..d475fff5daf7cf9783b7fa52a5a05fb8443e30c6 100644 (file)
@@ -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
index 871f63d871bb4581ab37fc905d44f11473864074..73a5727a4c0a762349c1eba5de293a0debfcee4b 100644 (file)
@@ -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
 
index d1b7b2f88101033e747ec3a040eb1317d83ccf63..4a585b1501200a67479efb6e1581e7097ef2c798 100644 (file)
@@ -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)
 );
index e1cd9504c3d2505124b9cffab39b05cf4dc6d152..1a55669aef5b19ad323f1480aa82a45997506e3f 100644 (file)
@@ -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;
index b302604d09a46c2b4e6f1bf4c4cae764a3ca86f9..add4a4df235229321baa8afd40eaf0ff6f296bb6 100644 (file)
@@ -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 = ();
 
index 957ca20a50dee4c90241649bf47812434eb7324b..74087d0b474acd2628a64b30e9b078d5e056dc5d 100644 (file)
@@ -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();
 }
 
index ffda84f909e04b45780b4044b93c183f7d83754d..48ce83026ca888b939970afa819ef3c9b5c275db 100644 (file)
@@ -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++;
     }
index 28c24bdf5951a1758038f661b70b78d79752c3cf..e8975c136a799f11219e10e071d3de9d85c8fbd0 100644 (file)
@@ -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;
     }