Created
December 12, 2012 06:46
-
-
Save ohlol/4265592 to your computer and use it in GitHub Desktop.
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
def do_stash | |
if @event['check']['status'] > 0 | |
begin | |
timeout(3) do | |
res = api_request(:POST, '/stashes/grouped/irccat/' + stash_key) do |req| | |
req['content-type'] = 'application/json' | |
req.body = {"timestamp"=>Time.now.to_i, "roles"=>@event['client']['roles']}.to_json | |
end | |
end | |
rescue Timeout::Error | |
puts 'irccat -- timed out while setting group stash' | |
end | |
else | |
begin | |
timeout(3) do | |
res = api_request(:DELETE, '/stashes/grouped/irccat/' + stash_key) | |
if response.is_a?(Net::HTTPSuccess) | |
puts 'irccat -- deleted group stash for ' + stash_key | |
else | |
puts 'irccat -- failed to delete group stash for ' + stash_key | |
end | |
end | |
rescue Timeout::Error | |
puts 'irccat -- timed out while deleting group stash' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment