progval / Supybot-plugins

Collection of plugins for Supybot/Limnoria I wrote or forked.
https://github.com/ProgVal/Limnoria/
107 stars 63 forks source link

RateLimit: fix error on @get with nonexistent user #349

Closed ghost closed 9 months ago

ghost commented 2 years ago

this can happen if a user that had rate limits set up got unregistered.

progval commented 2 years ago

The try block is a little too wide. eg. it would catch KeyError raised by an incorrect translation of the string in format_ratelimit.

Could you rewrite it like this?

                try:
                    user = ircdb.users.getUser(record.user)
                except KeyError:  # nonexistent user
                    continue
                else:
                    users.append('%s: %s' % (user.name,
                                             format_ratelimit(record)))