Class: Output::RocketChat

Inherits:
Base::RocketChat show all
Defined in:
lib/xify/output/rocket_chat.rb

Instance Method Summary collapse

Methods inherited from Base::RocketChat

#initialize, #request

Constructor Details

This class inherits a constructor from Base::RocketChat

Instance Method Details

#process(event) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/xify/output/rocket_chat.rb', line 9

def process(event)
  request :post, '/api/v1/chat.postMessage' do |req|
    req['Content-Type'] = 'application/json'
    req.body = {
      channel: @config['channel'],
      alias: event.author,
      attachments: [
        {
          title: event.args[:parent],
          title_link: event.args[:parent_link],
          text: event.args[:link] ? "#{event.message.chomp} ([more](#{event.args[:link]}))" : event.message.chomp
        }
      ]
    }.to_json
  end
end