diff --git a/sopel/bot.py b/sopel/bot.py index 86bae49a14..a59ae9ed53 100644 --- a/sopel/bot.py +++ b/sopel/bot.py @@ -305,26 +305,26 @@ def say(self, text, recipient, max_messages=1): recipient_id = Identifier(recipient) - recipient = self.stack.setdefault(recipient_id, { + recipient_stack = self.stack.setdefault(recipient_id, { 'messages': [], 'flood_left': self.config.core.flood_burst_lines, }) - if not recipient['flood_left']: - elapsed = time.time() - recipient['messages'][-1][0] - recipient['flood_left'] = min( + if not recipient_stack['flood_left']: + elapsed = time.time() - recipient_stack['messages'][-1][0] + recipient_stack['flood_left'] = min( self.config.core.flood_burst_lines, int(elapsed) * self.config.core.flood_refill_rate) - if not recipient['flood_left']: - elapsed = time.time() - recipient['messages'][-1][0] + if not recipient_stack['flood_left']: + elapsed = time.time() - recipient_stack['messages'][-1][0] penalty = float(max(0, len(text) - 50)) / 70 wait = self.config.core.flood_empty_wait + penalty if elapsed < wait: time.sleep(wait - elapsed) # Loop detection - messages = [m[1] for m in recipient['messages'][-8:]] + messages = [m[1] for m in recipient_stack['messages'][-8:]] # If what we about to send repeated at least 5 times in the # last 2 minutes, replace with '...' @@ -335,9 +335,9 @@ def say(self, text, recipient, max_messages=1): return self.write(('PRIVMSG', recipient), text) - recipient['flood_left'] = max(0, recipient['flood_left'] - 1) - recipient['messages'].append((time.time(), self.safe(text))) - recipient['messages'] = recipient['messages'][-10:] + recipient_stack['flood_left'] = max(0, recipient_stack['flood_left'] - 1) + recipient_stack['messages'].append((time.time(), self.safe(text))) + recipient_stack['messages'] = recipient_stack['messages'][-10:] finally: self.sending.release() # Now that we've sent the first part, we need to send the rest. Doing