#!/usr/bin/env perl # $Id: qq,v 1.1 2007/01/02 21:11:32 tans Exp $ # Copyright (c) 2002 - 2006 Shufeng Tan. All rights reserved. # # This program is free software and is provided "as is" without express # or implied warranty. It may be used, redistributed and/or modified # under the terms of the Perl Artistic License (see # http://www.perl.com/perl/misc/Artistic.html) use strict; use Getopt::Long; use Net::OICQ::TextConsole; print "Crypt::OICQ version $Crypt::OICQ::VERSION, Net::OICQ version $Net::OICQ::VERSION\n"; my $usage = <] id If you use csh or tcsh, type: setenv OICQ_PW 'xxxxxxx' $0 [-hi] [-d#] [-p] id Options: -h print this help message -i invisible mode -u UDP protocol (TCP is default) -d debug mode -p specify plugin EOF my $invisible= 0; my $udp = 0; my $debug = 0; my $plugin = ""; my $help = 0; GetOptions("debug=i" => \$debug, "invisible" => \$invisible, "udp" => \$udp, "plugin=s" => \$plugin, "help" => \$help); die $usage if $help; my $mode = $invisible ? 'Invisible' : 'Normal'; my $proto = $udp ? 'udp' : 'tcp'; my $uid = shift; $| = 1; my $ui = new Net::OICQ::TextConsole; unless ($uid) { $uid = $ENV{OICQ_ID}; die "Login Id not given\n" unless $uid; $ui->info("QQ id: $uid\n"); } my $pw = $ENV{OICQ_PW}; if ($pw) { print "OICQ_PW found in env.\n"; } else { $pw = $ui->ask_passwd("Enter password for $uid: "); $pw or die "Password not entered.\n"; } our $oicq = $ui->{OICQ}; $oicq->{EventQueueSize} = 100; $oicq->{FontSize} = '10'; # This can be random $oicq->{FontColor} = 'random'; $oicq->{Debug} = $debug; $oicq->login($uid, $pw, $mode, $proto) or die "Failed to login.\n"; $ui->{LastKbInput} = time; $oicq->get_friends_list; $oicq->get_online_friends; $oicq->get_user_info($uid); if ($plugin) { if (-f $plugin) { $ui->load_plugin($plugin); } else { $ui->warn("Plugin $plugin does not exist.\n"); } } $ui->loop; END { defined $oicq && defined $oicq->{Socket} && $oicq->logout }