Bot-targa

 view release on metacpan or  search on metacpan

bin/bottarga  view on Meta::CPAN

				$self->type(channel => $message->{channel}, body => "per un totale di ".@pranzonauti." pranzonauti");
			} else {
				$self->type(channel => $message->{channel}, body => 'niente manciare, niente pere, per i prossimi 20 ciorni');
			}
		} elsif ($message->{body} =~ /^(.*)\?$/) {
			if($sborropippo) {
				$self->type(channel => $message->{channel}, who => $message->{who}, address => $message->{who}, body => 'le seghe');
			} else {
				my $ua = LWP::UserAgent->new;
				$ua->agent('Bottarga');
				my $req = HTTP::Request->new(GET => "https://www.googleapis.com/customsearch/v1?key=$key&cx=$cx&hl=it&num=1&q=$1");
				my $res = $ua->request($req);
				if ($res->is_success) {
					my $json = decode_json($res->content);
					if (defined $json->{items}[0]->{link}) {
						$self->type(channel => $message->{channel}, who => $message->{who}, address => $message->{who}, body => $json->{items}[0]->{link});
					} else {
						$self->type(channel => $message->{channel}, who => $message->{who}, address => $message->{who}, body => 'boh');
					}
				}
			}



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