Skip to content

Instantly share code, notes, and snippets.

@smiler
Created June 15, 2011 09:56
Show Gist options
  • Save smiler/1026816 to your computer and use it in GitHub Desktop.
Save smiler/1026816 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'rexml/document'
class EveOnline < Plugin
def on_load()
@triggers = Hash[".tq" => "get_tq_status"]
end
def name
"EVE Online server status v0.1"
end
def get_tq_status(nick, user, host, channel, args)
url = URI.parse('http://api.eve-online.com')
begin
request = Net::HTTP.start(url.host, url.port) { |http|
http.get('/Server/ServerStatus.xml.aspx')
}
rescue => ex
$irc.putchan(channel, "Failed to connect to API server: #{ex.message}")
return
end
status = REXML::Document.new request.body
if status.elements['/eveapi/error'] != nil
$irc.putchan(channel, "Error: " + status.elements['/eveapi/error'].text)
else
open = status.elements['/eveapi/result/serverOpen'].text.strip.downcase
if open == "true"
count = status.elements['/eveapi/result/onlinePlayers'].text
$irc.putchan(channel, "TQ is online with #{count} players.")
else
$irc.putchan(channel, "TQ is offline.")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment