#!/usr/bin/perl # Put in a directory with the following files: # auth.txt: Contains two lines: # username # password # config.txt: Starts off with five lines, all numeric (each run will update): # starting year # starting month # starting day # starting hour # starting minute # starting second # terms.txt: One line for each keyword use strict; use warnings; use Date::Calc qw(Add_Delta_Days); use Tk; use Tk::Pane; my $ALWAYS_LOG_IN = 0; my $ALWAYS_DISPLAY = 0; my $PREFIX = $ENV{"HOME"} . "/Documents/kibo"; my @matches = (); my @terms = (); sub kibo { my ($year, $month, $day, $hour, $minute, $second) = @_; my $time = "$hour$minute$second"; open(WGET, "wget --quiet --load-cookies $PREFIX/cookies.txt https://calref.net/xmpp/log/lounge\@conference.calref.net/$year/$month/$day.html -O - |") or die $!; if (eof(WGET)) { return; } my $new_hour = "00"; my $new_minute = "00"; my $new_second = "00"; while (my $line = ) { if ($line =~ /\[(\d\d):(\d\d):(\d\d)\]<\/a> <(.*)><\/font>(.*)$/) { $new_hour = $1; $new_minute = $2; $new_second = $3; my $member = $4; my $message = $5; my $new_time = "$new_hour$new_minute$new_second"; if ($new_time > $time) { my $match = 0; for (@terms) { if ($message =~ /$_/i) { $match = 1; } } if ($match) { push(@matches, "$year-$month-$day [$new_hour:$new_minute:$new_second] <$member> $message"); } } } } close(WGET) or die $!; return "$new_hour:$new_minute:$new_second"; } if ($ALWAYS_LOG_IN || ! -e "$PREFIX/cookies.txt") { open(AUTH, "<$PREFIX/auth.txt") or die $!; chomp(my $username = ); chomp(my $password = ); close(AUTH) or die $!; `wget --quiet --delete-after --save-cookies $PREFIX/cookies.txt --post-data 'user=$username&passwrd=$password&cookieneverexp=on' https://calref.net/index.php?action=login2`; } open(TERMS, "<$PREFIX/terms.txt") or die $!; while () { chomp; push(@terms, $_); } close(TERMS) or die $!; open(CONFIG, "<$PREFIX/config.txt") or die $!; chomp(my $year = ); chomp(my $month = ); chomp(my $day = ); chomp(my $hour = ); chomp(my $minute = ); chomp(my $second = ); close(CONFIG) or die $!; my $last_date = "$year-$month-$day"; my $last_time = "$hour:$minute:$second"; for (;;) { my $new_time = kibo($year, $month, $day, $hour, $minute, $second); if (! $new_time) { last; } $last_date = "$year-$month-$day"; $last_time = $new_time; ($year, $month, $day) = Add_Delta_Days($year, $month, $day, 1); $year = sprintf("%02d", $year); $month = sprintf("%02d", $month); $day = sprintf("%02d", $day); $hour = "00"; $minute = "00"; $second = "00"; } ($year, $month, $day) = split(/-/, $last_date); ($hour, $minute, $second) = split(/:/, $last_time); chomp(my $sysdate = `date`); open(CONFIG, ">$PREFIX/config.txt") or die $!; print CONFIG <geometry("735x461"); my $frame = $window->Scrolled("Pane", -scrollbars=>"osoe")->pack( -expand=>1, -fill=>"both" ); $frame->Label(-justify=>"left", -text=>join("\n", @matches))->pack(); MainLoop(); }