Amethyst

 view release on metacpan or  search on metacpan

Amethyst/Brain/Infobot/Module/Exchange.pm  view on Meta::CPAN

package Amethyst::Brain::Infobot::Module::Exchange;

use strict;
use vars qw(@ISA
		%CODE2CODE %TLD2CODE %CURR2CODE %COUNTRY2CODE
		%CODE2CURR
				$REFERER $CONVERTER);
use Data::Dumper;
use POE;
use POE::Component::Client::UserAgent;
use HTTP::Request::Common;
use HTTP::Response;
use LWP::UserAgent;	# For init
use Amethyst::Message;
use Amethyst::Brain::Infobot;
use Amethyst::Brain::Infobot::Module;

@ISA = qw(Amethyst::Brain::Infobot::Module);

sub new {
	my $class = shift;

Amethyst/Brain/Infobot/Module/Exchange.pm  view on Meta::CPAN

	eval { spawn POE::Component::Client::UserAgent; };
	if ($@) {
		die $@ unless $@ =~ /^alias is in use by another session/;
	}

	$REFERER = 'http://www.xe.net/ucc/full.shtml';
	$CONVERTER ='http://www.xe.net/ucc/convert.cgi';

	my $ua = new LWP::UserAgent;
	my $uri = new URI($REFERER);
	my $request = new HTTP::Request(GET => $uri);

	print STDERR "Requesting $uri\n";

	my $response = $ua->request($request);

	unless ($response->is_success) {
		print STDERR $response->error_as_HTML;
		die "Failed to contact currency converter";
	}

Amethyst/Brain/Infobot/Module/Exchange.pm  view on Meta::CPAN

	$heap->{Module} = $module;
	$heap->{Message} = $message;

	my $uri = new URI($CONVERTER);
	$uri->query_form(
			From		=> $fcode,
			To			=> $tcode,
			Amount		=> $number,
				);
	$uri = $uri->canonical;
	my $request = new HTTP::Request(GET => $uri);
	$request->referer($REFERER);

	my $postback = $session->postback('response');

	$kernel->post('useragent', 'request',
					request		=> $request,
					response	=> $postback,
						);
}

Amethyst/Brain/Infobot/Module/Google.pm  view on Meta::CPAN

package Amethyst::Brain::Infobot::Module::Google;

use strict;
use vars qw(@ISA);
use Data::Dumper;
use POE;
use POE::Component::Client::UserAgent;
use HTTP::Request::Common;
use HTTP::Response;
use WWW::Search;
use WWW::SearchResult;
use Amethyst::Message;
use Amethyst::Brain::Infobot;
use Amethyst::Brain::Infobot::Module;

@ISA = qw(Amethyst::Brain::Infobot::Module);

sub new {

Amethyst/Brain/Infobot/Module/Google.pm  view on Meta::CPAN

					@_[KERNEL, HEAP, SESSION, ARG0, ARG1, ARG2];

	$heap->{Module} = $module;
	$heap->{Message} = $message;
	$heap->{Query} = $query;

	my $uri = new URI('http://www.google.com:80/search');
	$uri->query_form(q => $query);
	$uri = $uri->canonical;
	print STDERR "Searching for " . $uri->as_string . "\n";
	my $request = new HTTP::Request(GET => $uri);
	my $postback = $session->postback('response');

	$kernel->post('useragent', 'request',
					request		=> $request,
					response	=> $postback,
						);
}

1;

Makefile  view on Meta::CPAN

#
#	ANY CHANGES MADE HERE WILL BE LOST!
#
#   MakeMaker ARGV: ()
#
#   MakeMaker Parameters:

#	ABSTRACT_FROM => q[Amethyst.pm]
#	AUTHOR => q[A. U. Thor <a.u.thor@a.galaxy.far.far.away>]
#	NAME => q[Amethyst]
#	PREREQ_PM => { HTTP::Response=>q[1.36], HTTP::Request=>q[1.3], URI=>q[1.22], Net::DNS=>q[0.31], POE::Component::Client::DNS=>q[0.94], Parse::Lex=>q[2.15], WWW::Search=>q[2.36], POE=>q[0.23], Math::BaseCalc=>q[1.011], Math::Trig=>q[1], Text::Soundex...
#	VERSION_FROM => q[Amethyst.pm]

# --- MakeMaker post_initialize section:


# --- MakeMaker const_config section:

# These definitions are from config.sh (via /usr/lib/perl5/5.6.1/i586-linux/Config.pm)

# They may have been overridden via Makefile.PL or on the command line

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    'NAME'		=> 'Amethyst',
    'VERSION_FROM'	=> 'Amethyst.pm', # finds $VERSION
    'PREREQ_PM'		=> {
			POE				=> 0.23,
			HTTP::Request	=> 1.30,
			HTTP::Response	=> 1.36,
			Math::BaseCalc	=> 1.011,
			Math::Trig		=> 1.0,
			Text::Soundex	=> 1.0,
			POE::Component::Client::DNS			=> 0.94,
			POE::Component::Client::UserAgent	=> 0.04,
			Net::DNS		=> 0.31,
			Parse::Lex		=> 2.15,
			URI				=> 1.22,
			WWW::Search		=> 2.36,



( run in 0.303 second using v1.01-cache-2.11-cpan-de7293f3b23 )