diff options
-rwxr-xr-x | nsa | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -331,11 +331,47 @@ class Irc end end +class Counter + include MonitorMixin + + def initialize + super + @count = 5 + @ready = new_cond + + Thread.new { + begin + while true + synchronize do + if @count < 8 + @count = @count + 1 + @ready.signal + end + end + sleep 1 + end + rescue => e + puts e.class.to_s+": "+e.message + puts e.backtrace + end + Thread.main.exit + } + end + + def pop + synchronize do + @ready.wait_until{ @count > 0 } + @count = @count - 1 + end + end +end + Thread.abort_on_exception = true Dir.chdir( CONFIG['mailin'] + "/new" ) Log.init +counter = Counter.new bot = Irc.new bot.waitUntilOnline sleep 1 @@ -402,6 +438,7 @@ while (1) do line = pr + line channellist = CONFIG['projects'].has_key?(project) ? CONFIG['projects'][project] : CONFIG['projects']['*'] channellist.each do |c| + counter.pop m = /^NOTICE:(.*)/.match c if m bot.print "NOTICE #{m[1]} :#{line}" |