detecting bots by user-agent in rails

First i thought using the browser-gem and browser.bot? would give me the correct answer. But somehow it did not work. So i am now using this litte snippet to detect bots.


class BotDetection

  def self.bot?(agent)
    matches = nil
    matches = agent.match(/(facebook|postrank|voyager|twitterbot|googlebot|slurp|butterfly|pycurl|tweetmemebot|metauri|evrinid|reddit|digg|sitebot|msnbot|robot)/mi) if agent
    return (agent.nil? or matches)
   end

end

In my Base-Controller:


def bot_request?
  uAgent = request.env["HTTP_USER_AGENT"]
  if(uAgent.nil?)
    false
  else
    BotDetection.bot?(uAgent)
  end
end

A list of user-agents may be found at http://www.user-agents.org/