old_contents: # -*- coding: utf-8 -*-
  """
  Created on May 20, 2014
  
  @author: Tyranic-Moron
  """
  from twisted.plugin import IPlugin
  from desertbot.moduleinterface import IModule
  from desertbot.modules.commandinterface import BotCommand
  from zope.interface import implementer
  
  import re
  
  from desertbot.message import IRCMessage
  from desertbot.response import IRCResponse, ResponseType
  
  from desertbot.utils import string
  
  
  @implementer(IPlugin, IModule)
  class Find(BotCommand):
      def triggers(self):
          return ['find', 'google', 'g']
  
      def help(self, query):
          return 'find/google/g <searchterm> - returns the first google result for the given search term'
  
      def execute(self, message):
          """
          @type message: IRCMessage
          """
          try:
              results = self.bot.moduleHandler.runActionUntilValue('search-web', message.Parameters)
  
              if not results:
                  return IRCResponse(ResponseType.Say,
                                     u'[google developer key missing]',
                                     message.ReplyTo)
  
              firstResult = results[u'items'][0]
  
              title = firstResult[u'title']
              title = re.sub(r'\s+', ' ', title)
              content = firstResult[u'snippet']
              content = re.sub(r'\s+', ' ', content)  # replace multiple spaces with single ones (includes newlines?)
              content = string.unescapeXHTML(content)
              url = firstResult[u'link']
              replyText = u'{1}{0}{2}{0}{3}'.format(string.graySplitter, title, content, url)
  
              return IRCResponse(ResponseType.Say, replyText, message.ReplyTo)
          except Exception as x:
              self.logger.exception("Exception when finding a thing {}".format(message.Parameters))
              return IRCResponse(ResponseType.Say, x.args, message.ReplyTo)
  
  
  find = Find()
  
new_contents: # -*- coding: utf-8 -*-
  """
  Created on May 20, 2014
  
  @author: Tyranic-Moron
  """
  from twisted.plugin import IPlugin
  from desertbot.moduleinterface import IModule
  from desertbot.modules.commandinterface import BotCommand
  from zope.interface import implementer
  
  import re
  
  from desertbot.message import IRCMessage
  from desertbot.response import IRCResponse, ResponseType
  
  from desertbot.utils import string
  
  
  @implementer(IPlugin, IModule)
  class Find(BotCommand):
      def triggers(self):
          return ['find', 'google', 'g']
  
      def help(self, query):
          return 'find/google/g <searchterm> - returns the first google result for the given search term'
  
      def execute(self, message):
          """
          @type message: IRCMessage
          """
          try:
              results = self.bot.moduleHandler.runActionUntilValue('search-web', message.Parameters)
  
              if not results:
                  return IRCResponse(ResponseType.Say,
                                     u'[google developer key missing]',
                                     message.ReplyTo)
  
              if u'items' not in results:
                  return IRCResponse(ResponseType.Say,
                                     u'No results found for query!',
                                     message.ReplyTo)
  
              firstResult = results[u'items'][0]
  
              title = firstResult[u'title']
              title = re.sub(r'\s+', ' ', title)
              content = firstResult[u'snippet']
              content = re.sub(r'\s+', ' ', content)  # replace multiple spaces with single ones (includes newlines?)
              content = string.unescapeXHTML(content)
              url = firstResult[u'link']
              replyText = u'{1}{0}{2}{0}{3}'.format(string.graySplitter, title, content, url)
  
              return IRCResponse(ResponseType.Say, replyText, message.ReplyTo)
          except Exception as x:
              self.logger.exception("Exception when finding a thing {}".format(message.Parameters))
              return IRCResponse(ResponseType.Say, str(x.args), message.ReplyTo)
  
  
  find = Find()
  
subject: add error message for no results found, and hopefully fix exception response string