Skip to content

Instantly share code, notes, and snippets.

@courtenay
Created December 21, 2012 01:30
Show Gist options
  • Select an option

  • Save courtenay/4350099 to your computer and use it in GitHub Desktop.

Select an option

Save courtenay/4350099 to your computer and use it in GitHub Desktop.

Revisions

  1. courtenay created this gist Dec 21, 2012.
    5 changes: 5 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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
    30 changes: 30 additions & 0 deletions hipchat_command.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    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