Skip to content

Instantly share code, notes, and snippets.

@hackervera
Forked from donpdonp/gist:493101
Created August 1, 2010 04:14
Show Gist options
  • Save hackervera/502937 to your computer and use it in GitHub Desktop.
Save hackervera/502937 to your computer and use it in GitHub Desktop.
issac bot ruby
require 'json'
require 'isaac'
configure do |c|
c.nick = "icecondor"
c.server = "irc.freenode.net"
c.port = 6667
end
on :connect do
join "#geoloqi"
end
on :channel, /^icecondor: where is (.*)/ do
msg channel, "#{nick}: I dont know where '#{match[0]}' is. "
end
on :channel, /^icecondor: foursquare (.*) (.*)/ do |lat,long|
msg channel, "#{nick}: closest venue: #{closest_foursquare(lat,long)}"
end
on :channel, /^icecondor: (.*)/ do
msg channel, "Quote: '#{match[0]}' by #{nick}"
end
def closest_foursquare(lat,long)
j= JSON.parse(`curl -u user:pass 'http://api.foursquare.com/v1/venues.json?geolat=#{lat}&geolong=#{long}'`)
j["error"] || j["groups"].first["venues"].first["name"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment