X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fcicqhist;fp=usr_bin%2Fcicqhist;h=0000000000000000000000000000000000000000;hb=c08b156abb0b2b1b1335cb1ada0c08758553238b;hp=73bf02f3d7cfec2bd0a4a0213fa17b4fde1d27bb;hpb=b0c3e5ff760f99d6ff7721852bc1a0d73c5ea201;p=grml-scripts.git diff --git a/usr_bin/cicqhist b/usr_bin/cicqhist deleted file mode 100755 index 73bf02f..0000000 --- a/usr_bin/cicqhist +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/perl -w - -# Julius Plenz -# http://www.plenz.com/ -# -# $Id: cicqhist,v 0.4 2004/07/20 18:33:36 plenz Exp $ -# -# This script has just been written because of a simple purpose: -# To learn Perl. Or at least to make first few steps with perl. -# It just aims to be like http://centericq.de/misc/cicq-history.sh - -# and maybe it's even a bit more powerful... ;-) -# -# Released under the GNU GPL. - -use strict; -use Getopt::Std; - -my %options = (); -getopts ('d:hisv', \%options); - -$\ = "\n"; -$0 =~ s/^.*\///; - -my ($VER, $DATE); -$VER = '$Revision: 0.4 $'; -$VER =~ s/^.*: ([0-9\.,]+)\s*\$$/$1/; -$DATE = '$Date: 2004/07/20 18:33:36 $'; -$DATE =~ s/^.*: ([0-9\/]{10})[0-9: ]*\$$/$1/; -$DATE =~ s/\//-/g; - -if ($options{"v"}) { - print $0, ' ', $VER, ' ', $DATE; - exit; -} - -if (!$ARGV[0] || - $options{"h"} || - $ARGV[0] eq "") { - - # print help - print $0, ' ', $VER, ' ', $DATE; - print 'by Julius Plenz '; - print 'http://www.plenz.com/'; - print '(just to learn Perl :-)'; - print ''; - print 'Usage: ' . $0 . ' [-d ] [-h] [-i] [-s] '; - print '-d ... Use ... as cicq-directory (default: ~/.centericq)'; - print '-h Display this message'; - print '-i Display initials rather than full nicknames'; - print '-s Display shortened date (yymmdd hh:mm)'; - print '-v Display program version'; - exit; -} - - -# Change this, if you want! -my $mynick = $ENV{"USER"}; -# my $mynick = "Goofy"; - - -# The main directory -my $cicqdir; -if ($options{"d"}) { - $cicqdir = $options{"d"}; -} else { - $cicqdir = $ENV{"HOME"} . '/.centericq'; -} - -# Three basic settings -my $number = $ARGV[0]; -my $infofile = "$cicqdir/$number/info"; -my $histfile = "$cicqdir/$number/history"; - -# Getting the nickname -open (INFO, $infofile) || die ("Couldn't open file $infofile"); -my @lines = ; - -my $i = $#lines; -$i++; - -my $nickname; -foreach (@lines) { - $i--; - if ($i == 6) { - chomp; - $nickname = $_; - } -} - -close (INFO); - - -# Opening History -print "--- Displaying conversation with $nickname ---\n"; - -open (HIST, $histfile) || die ("Couldn't open file $histfile"); - -my $linenumber = 0; -my $nick = ''; -my $displaytime; - -while () { - chomp; - my $line = $_; - - if ($line eq " ") { - $linenumber = 0; - next; - } - - if ($linenumber < 4) { - if ($line =~ /^IN$/) { - $nick = sprintf ('%-13s', $nickname); - } - - if ($line =~ /^OUT$/) { - $nick = sprintf ('%-13s', $mynick); - } - - if (/^[0-9]+$/) { - my $tstamp = $_; - chomp ($tstamp); - - if ($tstamp < 3) { - next; - } - - my ($sec, $min, $hour, $mday, $mon, $year) = - localtime ($tstamp); - - if ($options{"s"}) { - $year += 1900; - $displaytime = sprintf ('%02d%02d%02d %02d:%02d ', - substr ($year, 2, 2), $mon, $mday, $hour, $min); - } else { - $displaytime = - sprintf ('[%02d.%02d.%02d, %02d:%02d:%02d] ', - $mday, $mon, (1900+$year), $hour, $min, $sec); - } - } - - $linenumber++; - if ($linenumber == 4) { - - $\ = ""; - - if ($options{"i"}) { - print $displaytime . substr ($nick, 0, 1) . ': '; - } else { - print $displaytime . $nick . ': '; - } - - $\ = "\n"; - } - - } else { - print $line; - } - -} - -close (HIST); - -if ($options{"i"}) { - print ''; - print ''; - print ' 'x8 . $number .' = '. substr ($nickname, 0, 1) . - ' = ' . $nickname; - print ' 'x8 . substr ($mynick, 0, 1) . ' = ' . $mynick; -} - -print "\n--- End of conversation with $nickname ---"; - -# EOF vim: set et sm nu ft=perl