All pastes #147073 Raw Edit

svnwatch.rb

public ruby v1 · immutable
#147073 ·published 2006-08-24 02:52 UTC
rendered paste body
## svnwatch - a subversion plugin for rbot.# author(s): Robby Russell and Ben Bleything of the PDX.rb# # This file should be placed in the rbot plugins/ directroy. When you load rbot# it will scan the directory and load this plugin. DRb will automatically start up.require 'drb'# Configuration Options@conf = {   :port => '7666',       # 7666 (you will need this to be the same in post-commit)  :host => 'localhost',  # localhost, don't set to remote ip unless you know what you are doing  :chan => '#bzfx'     # IRC channel that you want rbot to send notices to}class SvnWatch < Plugin  attr_writer :channel    def privmsg(m)      m.reply "I don't actually have anything to say. I just sit and wait for SVN to call me."      end    def svn_commit(info)    send_msg(build_msg(info))  end    # Sends a message to the channel defined. This will allow   # you to use the DRb instance to call the send_msg(str)    # method, which will output to the desired channel  private    def send_msg(str)      @bot.say @channel,  str    end      # yes this is really ugly.. we'll clean it up!      def build_msg(info)      author = info[:author]      repository = info[:repository]      revision = info[:revision]      note = info[:log]      message = "BZFX commit - author: '#{author}', rev: #{revision}, log: '#{note}'"      return message    end    end# register with rbot@svnwatch = SvnWatch.new@svnwatch.channel = @conf[:chan]@svnwatch.register("svnwatch")# start DRb in a new thread so it doesn't hang up the botThread.new {  # start the DRb instance  DRb.start_service("druby://#{@conf[:host]}:#{@conf[:port]}", @svnwatch)  DRb.thread.join}# that's all folks!