diff options
author | 2010-02-18 21:53:10 +0000 | |
---|---|---|
committer | 2010-02-18 21:53:10 +0000 | |
commit | 0ea6cec493eb68fc4e660030eac14dd075bba640 (patch) | |
tree | f6566800bc9f2f0ab5025ab5834cb0b7425eac1a | |
parent | Bug #286552: Google changed their WAP url and broke stuff. Port this from the... (diff) | |
download | rbot-gentoo-0ea6cec493eb68fc4e660030eac14dd075bba640.tar.gz rbot-gentoo-0ea6cec493eb68fc4e660030eac14dd075bba640.tar.bz2 rbot-gentoo-0ea6cec493eb68fc4e660030eac14dd075bba640.zip |
Fixup tricks.
-rw-r--r-- | gentoo-fixup.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gentoo-fixup.rb b/gentoo-fixup.rb new file mode 100644 index 0000000..cd1ea2f --- /dev/null +++ b/gentoo-fixup.rb @@ -0,0 +1,62 @@ +require 'set' +class Stack + def initialize + @hash = {} + end + + def [](key) + @hash[key] = [] unless @hash[key] + @hash[key] + end + + def contains?(key) + @hash.has_key?(key) + end + + def clear(key) + @hash.delete(key) + end +end + +class GentooFixupPlugin < Plugin + def initialize + super + @stack = Stack.new + end + + def whois(m) + nick = m.whois[:nick].downcase + # need to see if the whois reply was invoked by this plugin + return unless @stack.contains?(nick) + #msg = "Real bot host:" + m.parse_channel_list.inspect + channels = Set.new + channels.merge(m.whois[:channels].compact) if m.whois.include?(:channels) + #msg = "Real bot channels:" + m.whois.channels + + want_channels = Set.new(@bot.config['irc.join_channels'].compact) + missing_channels = want_channels - channels + s = missing_channels.to_a.join(', ') + @bot.say 'robbat2|na', 'Fixing '+s + @bot.say 'robbat2', 'Fixing '+s + missing_channels.each do |chan| + @bot.part(chan, "Fixing bot channels") + @bot.join(chan) + end + + @stack.clear(nick) + end + + def fixup(m, params) + nick = @bot.config['irc.nick'] + nick.downcase! + @stack[nick] << m.replyto + @bot.whois(nick) + end + +end +plugin = GentooFixupPlugin.new +plugin.map 'fixupjoin', + :action => 'fixup', + :auth_path => 'move' + +# vim: et sts=2 ts=2 sw=2: |