Skip to content

Instantly share code, notes, and snippets.

@courtenay
Created December 21, 2012 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save courtenay/4350099 to your computer and use it in GitHub Desktop.
Save courtenay/4350099 to your computer and use it in GitHub Desktop.
def hipchat_hook(data, payload, log)
notify_hipchat data,
"[Tender] \"#{payload['discussion']['title']}\" has been #{payload['number'] > 1 ? 'updated' : 'opened'} by #{payload['author_name']}",
payload['discussion']['html_href']
end
module Tender
module Hooks
module HipchatCommand
class << self
attr_accessor :hook_command_key, :hook_command_options
end
self.hook_command_key = 'hipchat'
self.hook_command_options = {
:description => '&mdash; HipChat',
:href => 'http://www.hipchat.com/',
:name => 'Hipchat',
:fields => {
'token' => 'Your secret API token',
'room_name' => 'The name of the room to talk into (optional, needs full API key)',
'room_id' => 'The ID of the room (optional, use this OR room name)',
'color' => 'Choose a color for your message (yellow, red, green, purple, random)'
}}
def notify_hipchat(data, message, href)
connection = Hipchat::Client.new(data['token'])
if !data['room_id'].blank?
connection.room(data['room_id']).send('Tender', message + " " + "<a href=\"#{href}\">#{href}</a>", false, data['color'])
elsif data['room_name']
connection[data['room_name']].send('Tender', message + " " + "<a href=\"#{href}\">#{href}</a>", false, data['color'])
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment