Class: Cinch::Plugins::Deploy

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/deploy.rb

Instance Method Summary collapse

Instance Method Details

#listen(m) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cinch/plugins/deploy.rb', line 8

def listen(m)
  return if @running
  @running = true
  config[:configurations].each do |config|
    if config[:channels].include?(m.channel.to_s) and config[:users].include?(m.user.nick) and m.message =~ Regexp.new(config[:trigger])
      IO.popen("#{config[:command]} 2>&1") do |handle|
        while line = handle.gets
          # do not use ,true for nick, it breaks on split
          m.reply "#{m.user.nick}: #{config[:command]} > #{line}"
        end
      end
    end
  end
rescue Exception => e
  m.reply "#{config[:command]} - exception: #{e.message}"
  puts e.backtrace
ensure
  @running = nil
end