Changeset 263
- Timestamp:
- 05/20/06 12:11:06 (3 years ago)
- Location:
- trunk/tools/irc
- Files:
-
- 2 modified
-
bogswiddle.rb (modified) (2 diffs)
-
trac.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/irc/bogswiddle.rb
r255 r263 38 38 # Which server/s to connect to 39 39 Servers = { 40 'irc.freenode.net' => ['#faeriemud' ],40 'irc.freenode.net' => ['#faeriemud', '#flood'], 41 41 } 42 42 43 44 ### Load in our custom plugin 45 def initialize( *args ) 46 super 47 require File.join( File.dirname(__FILE__), 'trac' ) 48 end 43 49 44 50 45 51 ### Log to the database instead of a file 46 52 def log( message, where="server" ) 47 # :TODO: Log to the database, creating a table for the 'where' if it53 # :TODO: Log to the database, creating a table for the 'where' if it 48 54 # doesn't exist already. Or maybe only for public messages? 49 55 end … … 58 64 59 65 end # class bogswiddle 60 -
trunk/tools/irc/trac.rb
r262 r263 1 1 #!/usr/bin/ruby 2 # 3 # TracPlugin - An rbot plugin for tracking Trac. 4 # 5 # == Synopsis 6 # 7 # 8 # 9 # == Authors 10 # 11 # * Martin Chase <stillflame@FaerieMUD.org> 12 # 13 # == Copyright 14 # 15 # Copyright (c) 2006 The FaerieMUD Consortium. All rights reserved. 16 # 17 # This module is free software. You may use, modify, and/or redistribute this 18 # software under the terms of the Perl Artistic License. (See 19 # http://language.perl.com/misc/Artistic.html) 20 # 21 # == Subversion Id 22 # 23 # $Id$ 24 # 2 25 3 26 require 'rbot/plugins' 4 27 require 'rss/1.0' 5 28 require 'rss/2.0' … … 10 33 11 34 def help( plugin, topic="" ) 12 "trac plugin: periodicly notifies channel sof Trac activity. " +13 "'trac <url>': reports on a Trac"35 "trac plugin: periodicly notifies channel of Trac activity. " + 36 "'trac <url>': reports on a Trac" 14 37 end 15 38 16 39 def initialize 17 super18 @feeds = {}19 @period = 6020 @bot.timer.add( @period, self ) { |tracer|21 tracer.feed22 }40 super 41 @feeds = {} 42 @period = 60 43 @bot.timer.add( @period, self ) { |tracer| 44 tracer.feed 45 } 23 46 end 24 47 25 48 def feed 26 puts @feeds.to_yaml27 @feeds.each {|url,params|28 begin29 open( url ) {|page|30 data = page.read31 @bot.say params[:where], parse( data, params )32 }33 rescue OpenURI::HTTPError, EOFError34 retry #:MC: is this going to be very bad?35 end36 }49 puts @feeds.to_yaml 50 @feeds.each {|url,params| 51 begin 52 open( url ) {|page| 53 data = page.read 54 @bot.say params[:where], parse( data, params ) 55 } 56 rescue OpenURI::HTTPError, EOFError 57 retry #:MC: is this going to be really bad, like, if the connection goes down? 58 end 59 } 37 60 end 38 61 … … 41 64 42 65 def parse( data, params ) 43 begin 44 rss = RSS::Parser.parse( data ) 45 rescue RSS::InvalidRSSError 46 rss = RSS::Parser.parse( data, false ) 47 end 48 message = '' 49 newest = params[:last_change] 50 rss.channel.items.find_all {|item| 51 params[:last_change] < item.pubDate 52 }.sort_by {|item| item.pubDate}.each {|item| 53 newest = item.pubDate 54 message += DisplayString % Elements.map {|element| 55 value = item.send( element ) || '' 56 value = "???" if value.kind_of?(String) and value.empty? 57 value 58 } + "\n" 59 } 60 params[:last_change] = newest 61 return message 66 begin 67 rss = RSS::Parser.parse( data ) 68 rescue RSS::InvalidRSSError 69 rss = RSS::Parser.parse( data, false ) 70 end 71 message = '' 72 newest = params[:last_change] 73 rss.channel.items.find_all {|item| 74 params[:last_change] < item.pubDate 75 }.sort_by {|item| 76 item.pubDate 77 }.each {|item| 78 newest = item.pubDate 79 message += DisplayString % Elements.map {|element| 80 value = item.send( element ) || '' 81 value = "???" if value.kind_of?(String) and value.empty? 82 value 83 } + "\n" 84 } 85 params[:last_change] = newest 86 return message 62 87 end 63 88 64 89 def feed_on( m, params ) 65 puts "m is '#{m.to_yaml}'" 66 puts "params is '#{params.to_yaml}'" 67 url = params[:what] 68 @feeds[url] = { 69 :last_change => Time.at(0), 70 :where => m.channel 71 } 90 @feeds[params[:what]] = { 91 :last_change => Time.at(0), 92 :where => m.channel 93 } #:TODO: these may want to be persistant 72 94 end 73 95
