Created
December 16, 2010 05:32
-
-
Save daz/743074 to your computer and use it in GitHub Desktop.
Skype status checker for Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check Skype status. You need to enable 'Show my status on the web' in Skype prefs | |
# | |
# skype = SkypeStatus.new('some.username') | |
# skype.online? | |
# => true | |
require 'net/http' | |
require 'uri' | |
class SkypeStatus | |
attr_reader :status | |
attr_reader :username | |
def initialize(username) | |
@username = username.to_s | |
update! | |
end | |
def update! | |
@status = "Offline" | |
url = URI.parse("http://mystatus.skype.com/#{@username}.txt") | |
begin | |
@status = Net::HTTP.get(url) | |
rescue | |
end | |
end | |
def online? | |
@status == "Online" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment