# File lib/rbot/ircsocket.rb, line 301 def run_throttle(more=0) now = Time.new if @throttle_bytes > 0 # If we ever reach the limit, we halve the actual allowed byterate # until we manage to reset the throttle. if @throttle_bytes >= @bytes_per @throttle_div = 0.5 end delta = ((now - @last_throttle)*@throttle_div*@bytes_per/@seconds_per).floor if delta > 0 @throttle_bytes -= delta @throttle_bytes = 0 if @throttle_bytes < 0 @last_throttle = now end else @throttle_div = 1 end @throttle_bytes += more end