Class: Cinch::Plugins::ByeDaddy

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/byedaddy.rb

Instance Method Summary collapse

Instance Method Details

#execute(m, a_uri) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/cinch/plugins/byedaddy.rb', line 15

def execute(m, a_uri)
  api_uri = "http://byedaddy.org/api" + (a_uri.casecmp("top") == 0 ? "/top" : "/url/#{CGI::escape(a_uri.match(/.+\..+/) ? a_uri : a_uri+".com")}")
  response = JSON.parse(open(api_uri,&:read))
  if a_uri.casecmp("top") == 0
    m.reply "The top 10 current GoDaddy users: #{response[0..-2].join(", ") + ", and " + response[-1]}."
  else
    m.reply "#{response["domain"]} is #{response["result"] ? "still using GoDaddy! Boo!" : "not using GoDaddy! Yay!"}", true
  end
end