Google from IRC

Performing Google searches from IRC is not only convenient, but also efficient. See how fast you can Google for something on IRC and click on the URL highlighted by your IRC client.

When someone pops into your IRC channel with a question, you can bet your life that 9 times out of 10, he could have easily found the answer on Google. If you think this is the case, you could tell him that, or you could do it slightly more subtly by suggesting a Google search term to an IRC bot, which will then go and look for a result.

Most IRC clients are capable of highlighting URLs in channels. Clicking on a highlighted URL will open your default web browser and load the page. For some people, this is a lot quicker than finding the icon to start your web browser and then typing or pasting the URL. More obviously, a single Google search will present its result to everybody in the channel.

The goal is to have an IRC bot called GoogleBot that responds to the !google command. It will respond by showing the title and URL of the first Google search result. If the size of the page is known, that will also be displayed.

The Code

First, unless you’ve already done so, you will need to grab a copy of the Google Web APIs Developer’s Kit ( and create a Google account and obtain a license key [Chapter 9]. As I write this, the free license key entitles you to 1,000 automated queries per day. This is more than enough for a single IRC channel.

The googleapi.jar ...

Get Google Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.