Sha256: f5bdc6a01c754fa03444ad68fe95cecb9ab887feb6479988de5ba0cfab62fb4b
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
require "cgi" module Cinch module Plugins class Gitlistener include Cinch::Plugin set :plugin_name, 'gitlistener' listen_to :api_callback def listen(m, json) hash = Yajl::Parser.parse(URI.unescape(json[8..-1])) bot.loggers.debug(hash.inspect) @bot.config.options['cogconf']['main']['channels'].each do |channel| #['#dev'].each do |channel| hash['commits'].each do |c| files = "" files += '[= ' + short(c['modified']).join(' ') + ' ] ' unless c['modified'].empty? files += '[- ' + short(c['removed']).join(' ') + ' ] ' unless c['removed'].empty? files += '[+ ' + short(c['added']).join(' ') + ' ] ' unless c['added'].empty? Channel(channel).msg "%s@%s: %s %s" % [ c['committer']['name'], hash['repository']['name'], CGI::unescape(c['message']), files ] end end end def short(x) x.map { |l| l.gsub(/([^\/]*)\//) { |s| s[0,1] + '/'} } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cogbot-0.1.1 | plugins/gitlistener.rb |
cogbot-0.1.0 | plugins/gitlistener.rb |
cogbot-0.0.3 | plugins/gitlistener.rb |
cogbot-0.0.2 | plugins/gitlistener.rb |