<s> import httplib2 <EOL> import json <EOL> import urllib <EOL> from irc import IRCBot , run_bot <EOL> class GoogleBot ( IRCBot ) : <EOL> def fetch_result ( self , query ) : <EOL> sock = httplib2 . Http ( timeout = <NUM_LIT:1> ) <EOL> headers , response = sock . request ( <EOL> '<STR_LIT>' % urllib . quote ( query ) <EOL> ) <EOL> if headers [ '<STR_LIT:status>' ] in ( <NUM_LIT:200> , '<STR_LIT>' ) : <EOL> response = json . loads ( response ) <EOL> return response [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> def find_me ( self , nick , message , channel , query ) : <EOL> result = self . fetch_result ( query ) <EOL> if result : <EOL> return result <EOL> def command_patterns ( self ) : <EOL> return ( <EOL> self . ping ( '<STR_LIT>' , self . find_me ) , <EOL> ) <EOL> host = '<STR_LIT>' <EOL> port = <NUM_LIT> <EOL> nick = '<STR_LIT>' <EOL> run_bot ( GoogleBot , host , port , nick , [ '<STR_LIT>' ] ) </s>
