Class: Cinch::Plugins::GithubNotifications::Poster

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Poster

Returns a new instance of Poster.



9
10
11
12
13
14
# File 'lib/cinch/plugins/github_notifications/poster.rb', line 9

def initialize(*args)
  super

  checker = Checker.new(config)
  checker.start
end

Instance Method Details

#listen(m, info) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cinch/plugins/github_notifications/poster.rb', line 18

def listen(m, info)
  event = info['type'].gsub(/([A-Z])/,"_\\1")[1..-7].downcase.to_sym
  unless Messages.respond_to?(event)
    debug "A github \"#{info['type']}\" was received, but Cinch::Plugins::Github::Messages.#{event} is not defined."
    return nil
  end

  message = nil

  config[:announce].each_pair do |match, channels|
    if info['repo']['name'] =~ match
      channels.each do |channel|
        message ||= Messages.send(event,info)
        Channel(channel).send(message) unless message.nil?
      end
    end
  end
end