Skip to content

Commit

Permalink
Missed some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaaak authored Mar 26, 2019
1 parent 87f718c commit 0f642e3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,21 @@ def say(self, text, recipient, max_messages=1):
'flood_left': self.config.core.flood_burst_lines,
})

if not reciprec['flood_left']:
elapsed = time.time() - reciprec['messages'][-1][0]
reciprec['flood_left'] = min(
if not recipient['flood_left']:
elapsed = time.time() - recipient['messages'][-1][0]
recipient['flood_left'] = min(
self.config.core.flood_burst_lines,
int(elapsed) * self.config.core.flood_refill_rate)

if not reciprec['flood_left']:
elapsed = time.time() - reciprec['messages'][-1][0]
if not recipient['flood_left']:
elapsed = time.time() - recipient['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 reciprec['messages'][-8:]]
messages = [m[1] for m in recipient['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)
reciprec['flood_left'] = max(0, reciprec['flood_left'] - 1)
reciprec['messages'].append((time.time(), self.safe(text)))
reciprec['messages'] = reciprec['messages'][-10:]
recipient['flood_left'] = max(0, recipient['flood_left'] - 1)
recipient['messages'].append((time.time(), self.safe(text)))
recipient['messages'] = recipient['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 0f642e3

Please sign in to comment.