Created
May 9, 2011 13:49
-
-
Save mfojtik/962549 to your computer and use it in GitHub Desktop.
redmine_bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'cinch' | |
require 'nokogiri' | |
require 'pp' | |
require 'rest-client' | |
FEED_URL="https://www.aeolusproject.org/redmine/activity.atom?key=296155b7b55159144a341f198e5909d24cd003ea" | |
def feed | |
client = RestClient::Resource.new(FEED_URL, '<username>', '<password>') | |
Nokogiri::HTML(client.get) | |
end | |
class RedmineWatch | |
include Cinch::Plugin | |
attr_accessor :last_id | |
timer 20, method: :refresh | |
def refresh | |
entries = (feed/"feed entry") | |
activity = entries.first | |
if (activity/'id').text.strip != @last_id | |
data = { | |
:text => (activity/'title').text.strip, | |
:author => (activity/'author name').text.strip, | |
} | |
project = data[:text].split('-').first.strip | |
data[:text].gsub!(/^(.+) \-/, '').strip | |
Channel("#deltacloud-internal").send("[\u000307#{data[:author]}\u000f] [#{project}] #{data[:text]}") | |
@last_id = (activity/'id').text.strip | |
end | |
end | |
end | |
bot = Cinch::Bot.new do | |
configure do |c| | |
c.server = "irc.freenode.net" | |
c.channels = ["#aeolus"] | |
c.nick = "redmine" | |
c.verbose = true | |
c.plugins.plugins = [RedmineWatch] | |
end | |
on :channel, /^!halibut (.+)/ do |m, text| | |
begin | |
m.reply "#{text.strip}: \u000305<`)))><\u000f tail slapped your chest and face" | |
rescue Exception => e | |
pp e.backtrace | |
end | |
end | |
end | |
bot.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment