Skip to content

Instantly share code, notes, and snippets.

@ohlol
Created December 12, 2012 06:46
Show Gist options
  • Save ohlol/4265592 to your computer and use it in GitHub Desktop.
Save ohlol/4265592 to your computer and use it in GitHub Desktop.
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