
#!/usr/bin/perl -w
# Trillian to LICQ convertor
# By Peter Revill (arevill@bigpond.net.au)
# HUGE thanks to #Perl on irc.openprojects.net especially carbon :)

use warnings;
use strict;

my $string_data;
my $users = 0;

my $searchstring;
my $new_usersconf;

my ($file_buffer, $file_path, $i, $ans);
print "To run, copy Buddies.xml from your trillian profile (normally trillian/users/default/Buddies.xml and supply Buddies.xml as the file name)";

print "Please enter a file to read: ";

$ans = <STDIN>; chomp($ans);

$file_path = $ans;
if(open(FH, $file_path))
{

	while(<FH>) {

		if(/A(\d+)%/) {

			$users++;

		}
	}

}
close(FH);

open(FHD,$file_path);
$new_usersconf = "[users] \nNumOfUsers = " . $users . "\n";

my $count = 1;

while(<FHD>) {

	if(/A(\d+)%/) {

	$new_usersconf = $new_usersconf . "User" . $count . " = " . $1 . "\n";
		open(USE,"> .licq/users/" . $1 . ".uin");
		print USE "

		[user] \n
		History = default\n
		Groups.System =\n
		Groups.User =\n
		Ip =\n
		IntIp =\n
		Port =\n
		NewMessages =\n
		LastOnline =\n
		LastSent =\n
		LastRecv =\n
		LastCheckedAR =\n
		AutoAccept =\n
		StatusToUser =\n
		CustomAutoRsp =\n
		SendIntIp =\n
		UserEncoding =\n
		SID =\n
		GSID =\n
		Alias =\n
		FirstName =\n
		LastName =\n
		Email1 =\n
		Email2 =\n
		EmailO =\n
		City =\n
		State =\n
		PhoneNumber =\n
		FaxNumber =\n
		Address =\n
		CellularNumber =\n
		Zipcode =\n
		Country =\n
		Timezone =\n
		Authorization =\n
		HideEmail =\n
		Age =\n
		Gender =\n
		Homepage =\n
		BirthYear =\n
		BirthMonth =\n
		BirthDay =\n
		Language1 =\n
		Language2 =\n
		Language3 =\n
		CompanyCity =\n
		CompanyState =\n
		CompanyPhoneNumber =\n
		CompanyFaxNumber =\n
		CompanyAddress =\n
		CompanyZip =\n
		CompanyCountry =\n
		CompanyName =\n
		CompanyDepartment =\n
		CompanyPosition =\n
		CompanyHomepage =\n
	";
	close(USE);

	$count++;

	}
	}

	# now its time to write to users.conf

	open(USER, "> users.conf");

	print USER $new_usersconf;

	print $new_usersconf;

	print "Work complete, to finish off, all you need to do is copy users.conf (which should be in this dir, to .licq/users.conf (use cp users.conf .licq/users.conf if you want) (this assumes you have run this script in your home directory)";

	print "\n Then, go into licq, all the nicknames will come up as unknown, but click Licq: user functions - update all users and walla, problem solved :)";
	print "\n Enjoy! Cheers Peter Revill";