3 # Julius Plenz <jp@cvmx.de>
4 # http://www.plenz.com/
6 # $Id: cicqhist,v 0.4 2004/07/20 18:33:36 plenz Exp $
8 # This script has just been written because of a simple purpose:
9 # To learn Perl. Or at least to make first few steps with perl.
10 # It just aims to be like http://centericq.de/misc/cicq-history.sh -
11 # and maybe it's even a bit more powerful... ;-)
13 # Released under the GNU GPL.
19 getopts ('d:hisv', \%options);
25 $VER = '$Revision: 0.4 $';
26 $VER =~ s/^.*: ([0-9\.,]+)\s*\$$/$1/;
27 $DATE = '$Date: 2004/07/20 18:33:36 $';
28 $DATE =~ s/^.*: ([0-9\/]{10})[0-9: ]*\$$/$1/;
32 print $0, ' ', $VER, ' ', $DATE;
41 print $0, ' ', $VER, ' ', $DATE;
42 print 'by Julius Plenz <jp@cvmx.de>';
43 print 'http://www.plenz.com/';
44 print '(just to learn Perl :-)';
46 print 'Usage: ' . $0 . ' [-d <dir>] [-h] [-i] [-s] <number>';
47 print '-d ... Use ... as cicq-directory (default: ~/.centericq)';
48 print '-h Display this message';
49 print '-i Display initials rather than full nicknames';
50 print '-s Display shortened date (yymmdd hh:mm)';
51 print '-v Display program version';
56 # Change this, if you want!
57 my $mynick = $ENV{"USER"};
58 # my $mynick = "Goofy";
64 $cicqdir = $options{"d"};
66 $cicqdir = $ENV{"HOME"} . '/.centericq';
69 # Three basic settings
70 my $number = $ARGV[0];
71 my $infofile = "$cicqdir/$number/info";
72 my $histfile = "$cicqdir/$number/history";
74 # Getting the nickname
75 open (INFO, $infofile) || die ("Couldn't open file $infofile");
94 print "--- Displaying conversation with $nickname ---\n";
96 open (HIST, $histfile) || die ("Couldn't open file $histfile");
111 if ($linenumber < 4) {
112 if ($line =~ /^IN$/) {
113 $nick = sprintf ('%-13s', $nickname);
116 if ($line =~ /^OUT$/) {
117 $nick = sprintf ('%-13s', $mynick);
128 my ($sec, $min, $hour, $mday, $mon, $year) =
133 $displaytime = sprintf ('%02d%02d%02d %02d:%02d ',
134 substr ($year, 2, 2), $mon, $mday, $hour, $min);
137 sprintf ('[%02d.%02d.%02d, %02d:%02d:%02d] ',
138 $mday, $mon, (1900+$year), $hour, $min, $sec);
143 if ($linenumber == 4) {
148 print $displaytime . substr ($nick, 0, 1) . ': ';
150 print $displaytime . $nick . ': ';
167 print ' 'x8 . $number .' = '. substr ($nickname, 0, 1) .
169 print ' 'x8 . substr ($mynick, 0, 1) . ' = ' . $mynick;
172 print "\n--- End of conversation with $nickname ---";
174 # EOF vim: set et sm nu ft=perl