Skip to content

Commit

Permalink
Fix variable name
Browse files Browse the repository at this point in the history
Co-Authored-By: kwaaak <kwaaak@users.noreply.github.com>
Co-Authored-By: Deathbybandaid <deathbybandaid@users.noreply.github.com>
  • Loading branch information
deathbybandaid and kwaaak committed Apr 3, 2019
1 parent 9a7bf59 commit 1eabf4f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '...'
Expand All @@ -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
Expand Down

0 comments on commit 1eabf4f

Please sign in to comment.