Skip to content

Commit

Permalink
Fix critical keyerror bug in rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
calebj committed Apr 16, 2016
1 parent 56d6b58 commit b00b22c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ def call(self, func, sopel, trigger):
self._times[nick] = dict()
if self.nick not in self._times:
self._times[self.nick] = dict()
if not trigger.is_privmsg and trigger.sender not in self._times:
self._times[trigger.sender] = dict()

if not trigger.admin and not func.unblockable:
usertimediff = current_time - self._times[nick][func]
Expand All @@ -450,11 +452,9 @@ def call(self, func, sopel, trigger):

if not trigger.is_privmsg:
chan = trigger.sender
if chan not in self._times:
self._times[chan] = dict()
chantimediff = current_time - self._times[chan][func]
if func.channel_rate > 0 and chantimediff < func.channel_rate and \
func in self._times[chan]:
chantimediff = current_time - self._times[chan][func]
self._times[chan][func] = current_time
LOGGER.info(
"%s prevented from using %s in %s due to channel limit: %d < %d",
Expand Down

0 comments on commit b00b22c

Please sign in to comment.