Skip to content

Commit

Permalink
Add ilbot2 to repository. Thanks perl guys
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneid committed Jan 4, 2011
1 parent c25f4af commit ff0c481
Show file tree
Hide file tree
Showing 107 changed files with 5,182 additions and 0 deletions.
67 changes: 67 additions & 0 deletions bot/IrcLog.pm
@@ -0,0 +1,67 @@
package IrcLog;
use warnings;
use strict;
use DBI;

#use Smart::Comments;
use Config::File;
use Carp;
use utf8;

require Exporter;

use base 'Exporter';
our @EXPORT_OK = qw(
get_dbh
gmt_today
);

# get a database handle.
# you will have to modify that routine to fit your needs
sub get_dbh {
my $conf = Config::File::read_config_file("database.conf");
my $dbs = $conf->{DSN} || "mysql";
my $db_name = $conf->{DATABASE} || "irclog";
my $host = $conf->{HOST} || "localhost";
my $user = $conf->{USER} || "irclog";
my $passwd = $conf->{PASSWORD} || "";

my $db_dsn = "DBI:$dbs:database=$db_name;host=$host";
my $dbh = DBI->connect($db_dsn, $user, $passwd,
{RaiseError=>1, AutoCommit => 1});
return $dbh;
}

# returns current date in GMT in the form YYYY-MM-DD
sub gmt_today {
my @d = gmtime(time);
return sprintf("%04d-%02d-%02d", $d[5]+1900, $d[4] + 1, $d[3]);
}


=head1 NAME
IrcLog - common subroutines for ilbot and the corresponding CGI scripts
=head1 SYNOPSIS
there is no synopsis, since the module has no unified API, but is a loose
collection of subs that are usefull for the irc log bot and the
corresponding CGI scripts.
=head1 METHODS
* get_dbh
returns a DBI handle to a database. To achieve that, it reads the file
C<database.conf>.
* gmt_today
returns the current date in the format YYYY-MM-DD, and uses UTC (GMT) to
dermine the date.
=cut

# vim: ts=4 sw=4 expandtab
1;
5 changes: 5 additions & 0 deletions bot/README
@@ -0,0 +1,5 @@
The documentation can be found at
http://moritz.faui2k3.org/en/ilbot

However it is very incomplete, in case you really want to use it, ask moritz_
on #perl6
18 changes: 18 additions & 0 deletions bot/TODO
@@ -0,0 +1,18 @@
* links to colabti irclogs - but how to know for which channels?
* fix context in search results for adjacent hits
* fix spam.pl with rewritten URLs

Already done:
* import of colabti irclogs
* add context to search results?
* full text search
* move to own virtual host
* use rewrite magic for cleaner URLs
* some caching for indexes and old pages
* split listing of all channels and dates per channel

15:29 < [particle]> if you're in the mood for adding more, processing
S05:546-549 would be grand. as well as S05/"Nothing is
illegal"
15:30 < [particle]> oh, i should say, *highlighting* the text and processing
S05:546-549
1 change: 1 addition & 0 deletions bot/add_id.sql
@@ -0,0 +1 @@
ALTER TABLE irclog ADD id INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (id);
7 changes: 7 additions & 0 deletions bot/bot.conf
@@ -0,0 +1,7 @@
# Configuration for the bot
NICK = irclogger_com
SERVER = irc.freenode.net
# currently only one channel is supported; start multiple bots if you
# want to log more channels
CHANNEL = \#sinatra \#radiantcms \#datamapper \#sequel \#adhearsion \#integrity \#dm-hacking \#rack \#cucumber \#rspec \#webrat \#capistrano \#poolpartyrb \#monk \#merb \#vagrant \#riak \#ohm \#padrino \#redis \#redis-rb \#akin \#buildr \#ruboto \#cappuccino \#coffeescript \#rubysur \#motion \#couchdb \#extjs \#mplayer \#alsa \#veritas \#rvm

25 changes: 25 additions & 0 deletions bot/cgi/.htaccess
@@ -0,0 +1,25 @@
Options +ExecCGI
AddHandler cgi-script .pl

DirectoryIndex index.pl
RewriteEngine on

RewriteCond %{HTTP_REQUEST} !^search
RewriteRule ^([\w-]+)/?$ channel-index.pl?channel=$1 [L]

RewriteCond %{HTTP_REQUEST} !^search
RewriteRule ^([\w-]+)/today$ out.pl?channel=$1

RewriteCond %{QUERY_STRING} ^channel=([^;]+);date=(\d\d\d\d-\d\d-\d\d)
RewriteCond %{HTTP_REQUEST} ^out\.pl
RewriteRule ^out.pl /%1/%2? [R=301,L]

RewriteCond %{HTTP_REQUEST} !^search
RewriteRule ^([\w-]+)/(\d\d\d\d-\d\d-\d\d) out.pl?channel=$1;date=$2 [L]

RewriteRule ^search/?$ /search.pl
RewriteRule ^search/(\d+)/(.*)$ /search.pl?offset=$1;q=$2
RewriteRule ^search/(.*)$ /search.pl?offset=0;q=$2

RewriteRule ^\. - [F]
RewriteRule \.conf$ - [F]
89 changes: 89 additions & 0 deletions bot/cgi/.svn/all-wcprops
@@ -0,0 +1,89 @@
K 25
svn:wc:ra_dav:version-url
V 36
/pugs/!svn/ver/21328/misc/irclog/cgi
END
search.pl
K 25
svn:wc:ra_dav:version-url
V 46
/pugs/!svn/ver/21301/misc/irclog/cgi/search.pl
END
out.pl
K 25
svn:wc:ra_dav:version-url
V 43
/pugs/!svn/ver/21328/misc/irclog/cgi/out.pl
END
index.pl
K 25
svn:wc:ra_dav:version-url
V 45
/pugs/!svn/ver/21301/misc/irclog/cgi/index.pl
END
cgi.conf
K 25
svn:wc:ra_dav:version-url
V 45
/pugs/!svn/ver/18608/misc/irclog/cgi/cgi.conf
END
style.css
K 25
svn:wc:ra_dav:version-url
V 46
/pugs/!svn/ver/18645/misc/irclog/cgi/style.css
END
links.dat
K 25
svn:wc:ra_dav:version-url
V 46
/pugs/!svn/ver/19610/misc/irclog/cgi/links.dat
END
channel-index.pl
K 25
svn:wc:ra_dav:version-url
V 53
/pugs/!svn/ver/21301/misc/irclog/cgi/channel-index.pl
END
at.png
K 25
svn:wc:ra_dav:version-url
V 43
/pugs/!svn/ver/16134/misc/irclog/cgi/at.png
END
moosecamel.png
K 25
svn:wc:ra_dav:version-url
V 51
/pugs/!svn/ver/16064/misc/irclog/cgi/moosecamel.png
END
spam.pl
K 25
svn:wc:ra_dav:version-url
V 44
/pugs/!svn/ver/21301/misc/irclog/cgi/spam.pl
END
.htaccess
K 25
svn:wc:ra_dav:version-url
V 46
/pugs/!svn/ver/20508/misc/irclog/cgi/.htaccess
END
moose1.ico
K 25
svn:wc:ra_dav:version-url
V 47
/pugs/!svn/ver/16064/misc/irclog/cgi/moose1.ico
END
abbr.dat
K 25
svn:wc:ra_dav:version-url
V 45
/pugs/!svn/ver/20507/misc/irclog/cgi/abbr.dat
END
text.pl
K 25
svn:wc:ra_dav:version-url
V 44
/pugs/!svn/ver/18537/misc/irclog/cgi/text.pl
END

0 comments on commit ff0c481

Please sign in to comment.