#!/usr/bin/perl -w
# googlematic.pl
# Provides an AIM interface to Google, using the Google SOAP API
# and POE to manage all the activity.
#
# Usage
# ./googlematic.pl &
#
# Requirements
# - Googlematic::IM, Googlematic::Responder, Googlematic::Search,
# which are all distributed with this script
# - CGI
# - HTML::Entities
# - Net::AOLIM
# - POE
# - SOAP::Lite
# - XML::Parser
#
# Essential configuration (below)
# - AIM username and password (used in Googlematic::IM)
# - Google API Developer Key (used in Googlematic::Search)
#
# Optional configuration (below)
# - Search request throttling (used in Googlematic::Search)
# - Limit of number of user sessions open (used in Googlematic::IM)
# - Time limit on a user session (used in Googlematic::Responder)
#
# (c) 2002 Matt Webb <matt@interconnected.org> All rights reserved
use strict;
use POE;
$| = 1;
use Googlematic::IM;
use Googlematic::Search;
# Configuration variables
$Googlematic::CONFIG = {
aim_username => "xxxxxxx",
aim_password => "xxxxxxx",
google_key => "your key goes here",
searches_per_hour => "35", # the Google limit is 1000/day
max_user_sessions => "5",
user_session_timeout => "120" # in seconds
};
# There are two POE sessions:
# 1 - Googlematic::IM, known as 'im', takes care of the Instant Messager
# connection and looks after user sessions (which are created as new
# POE sessions, and known as Responders).
POE::Session->create(
package_states => [
Googlematic::IM => [
'_start', 'login_aim', 'loop', 'spawner',
'handler_aim', 'send', '_child', '_stop', 'proxy'
]
]
);
# 2 - Googlematic::Search, known as 'google', takes care the SOAP::Lite
# object making the searches on Google. Requests to it are sent from the
# individual Responders.
POE::Session->create(
package_states => [
Googlematic::Search => [
'_start', 'loop', 'search', 'reset'
]
]
);
# Run the POE machine.
$poe_kernel->run( );
exit;