#!/usr/bin/perl # by Alberto Simoes (albie@alfarrabio.di.uminho.pt) package Google; use Data::Dumper; use cybot; use Net::Google; my $key = '4LVH/SH8KT7eZtht3QHRob8BdTh0lpdH'; my $google = Net::Google->new(key=>$key); print STDERR "initializing google with key ($key)\n"; if (!$google) { print STDERR "Can't init google stuff ($@)\n" } my $googleSearch = $google->search(); if (!$googleSearch) { print STDERR "Don't have a google Search object ($@)\n" } register_command("google",sub { my ($bot,$chan,$nick,$mask, @commands) = @_; my $query = join(" ",@commands); $googleSearch->query($query); my $results = $googleSearch->results(); my $i = 0; for (@$results) { $bot->message ($chan, "$i: ".$_->URL()); $i++; } },"Googles something..."); 1;