Chapter 8 — Checking for Mail 147
while (1)
{
last unless defined($foo->ui_dataget(undef));
}
When Net::AOLIM receives a message, it hands the script off to the subroutine
called reply.replymust check if the incoming message is a direct Instant
Message, not an internal error message. Once it has done that, it retrieves the
buddy name of the person who sent it.
sub reply
{
my $params = $_[ARG1];
my $aim_event_type = $params->[0];
if($aim_event_type eq ‘IM_IN’) {
my $aimdestuser = $params->[1];
And all that remains to be done is to check Gmail for new mail and reply to the
message sender with a nice answer. Once that is done, the script returns to its
loop. Listing 8-7 shows all.
Listing 8-7:A New Mail Count AIM Bot
#!/usr/bin/perl -w
use warnings;
use strict;
use Mail::Webmail::Gmail;
use Net::AOLIM;
my $gmail_user =””;
my $gmail_password = “”;
my $aim_user = “”;
my $aim_password = “”;
my $aim_destuser = “”;
$aim = Net::AOLIM->new(“username” => $aim_user,
“password” => $aim_password,
“callback” => \&reply,
“allow_srv_settings” => 0,
“login_timeout” => 2 );