Class: Slacktail::Command

Inherits:
MisterBin::Command
  • Object
show all
Includes:
HasClient
Defined in:
lib/slacktail/command.rb

Instance Attribute Summary

Attributes included from HasClient

#client

Instance Method Summary collapse

Instance Method Details

#run(args = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/slacktail/command.rb', line 16

def run(args = nil)
  args ||= {}
  @channels = args['CHANNELS'] || []

  say "Connecting... " if Client.can_connect?

  client.on :message do |data|
    # File.write 'debug.yml', data.to_yaml
    @message = Message.new data
    @message.render unless skip?
  end

  client.on(:hello) { resay "!txtgrn!Ready\n" }
  client.on(:closed) { |_data| say "Goodbye" }
  client.start!
end