For the valuable use of any noders who use X-Chat, I present a small Perl Script that'll take an X-Chat log file and make it suitable for noding (I hope)...

------------------------------------------------------------

#!/usr/bin/perl -w

# This boneheadedly simple script will prepare an X-Chat log for
# posting on E2.  Made by Nicholas Killewald.
# Freely redistributable in accordance with the GPL.

# Needs two arguments: One to read from, one to write to.

# ah, I'd like to have two arguments, please
die "E2.pl needs TWO arguments...\n\nE2.pl [SOURCE] [DESTINATION]\n" unless(@ARGV==2);

($in, $out)=@ARGV;	# name 'em

open(IN, $in) || die "Can't open $in... $!";

# this version, there's no overwriting/appending avaliable.  Maybe next version.
if(-e $out){
	die "$out already exists... I won't let you overwrite it.\n(At least not in this version)";
}else{
	open(OUT, ">$out") || die "Can't open $out for writing... $!";
}

# right, they're open now.  let's get to work.

while(<IN>){
	next if(/^---/);	# ignore system messages, pings, CTCPs, etc
	chomp;			# yum!

	s/&/&amp;/g;		# all & to proper code

	s/>/&gt;/ if(/^-->/);	# put in proper code for user entering
	s/</&lt;/ if(/^<--/);	# same deal, user leaving

	if(/^</){		# if it starts with < (normal user text)
		s/^</[/;		# hardlink users
		s/>/]:/;
	}

	if(/^\*/){		# if it starts with * (action text)
		@bean=split(/\ /);		# divide and conquer
		$bean[1]="[".$bean[1]."]";	# hardlink user
		$_=join(" ", @bean);		# combine and conquer
	}	
	
	s/</&lt;/g;		# all < to proper code
	s/>/&gt;/g;		# all > to proper code

	print OUT $_."<br>\n";	# kick it out, rinse, repeat
}

close(IN);
close(OUT);

print "Right... with any luck, this should work.\n";
print "Your E2ified chatlog is now in $out.  Enjoy!\n";

I'll work on other clients' logs later... And yes, this code is freely redistributable and modifiable under the GPL.

STUFF TO DO: Add support for users who leave timestamps on.

Log in or register to write something here or to contact authors.