Re: remove old messages from history

"Miso Liptak" <[email protected]> Tue, 6 Feb 2007 11:03:32 +0100
Newsgroups gmane.network.centericq
Message-ID <[email protected]>
> Good idea, but changing the way CenterICQ works would be better. It seems
> that CICQ (re)loads a whole history file when opening a chat window. It
> would be better if it only loads the latest 40 messages and skips the others
> (for speed and memory). Loading all the chat history would only be useful
> when starting the history view (e.g. with the h key). This change would
> require a bit of C++ programming though (another patch...).

This is a good idea.. Unfortunately I don't have time to go thru sources..

>
> Miso, you could change my Perl mergeHistory script a little bit to get it
> working the way you suggest. It already reads the timestamps.

I already came up with this:
#!/usr/bin/perl -w

# format of the file to parse
# ^L (0x0c)
# OUT or IN
# MSG
# date in seconds
# date in seconds
# text (can span multiple lines until new ^L)

use strict;

if (int(@ARGV) < 1) {
    die "Missing parameter - how old messages to remove (in seconds since now)"
}

my ($l1,$l2,$l3);
my $threshold = time - $ARGV[0];

<STDIN>;
while (1) {
    $l1 = <STDIN>; # IN or OUT
    last unless defined $l1;
    die unless ($l1 =~ /^OUT$/ || $l1 =~ /^IN$/);
    $l2 = <STDIN>; # MSG
    die unless $l2 =~ /^MSG$/;
    $l3 = <STDIN>; # date1
    if ($l3 > $threshold) {
        # copy rest to stdout
        print "^L\n";
        print $l1;
        print $l2;
        print $l3;
        while(<STDIN>) {
            print;
        }
        exit 0;
    }
    <STDIN>; # date2
    while(<STDIN>) {
        last if (/^^L$/);
    }
}
_______________________________________________
Cicq mailing list
Cicq-xGejAJT2w6wWP6gT/[email protected]
http://mailman.linuxpl.org/mailman/listinfo/cicq
Questions? Check the FAQ first: http://centericq.de/faq/