Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot: rate limit effects are no longer logged #2648

Open
dgw opened this issue Jan 14, 2025 · 0 comments
Open

bot: rate limit effects are no longer logged #2648

dgw opened this issue Jan 14, 2025 · 0 comments

Comments

@dgw
Copy link
Member

dgw commented Jan 14, 2025

The old code path for calling plugin callables (bot.call()) had some nice logging that kicked in if a rate limit was applied:

sopel/sopel/bot.py

Lines 728 to 756 in da05822

if not trigger.admin and not func.unblockable:
if func in self._times[nick]:
usertimediff = current_time - self._times[nick][func]
if func.user_rate > 0 and usertimediff < func.user_rate:
LOGGER.info(
"%s prevented from using %s in %s due to user limit: %d < %d",
trigger.nick, func.__name__, trigger.sender, usertimediff,
func.user_rate
)
return
if func in self._times[self.nick]:
globaltimediff = current_time - self._times[self.nick][func]
if func.global_rate > 0 and globaltimediff < func.global_rate:
LOGGER.info(
"%s prevented from using %s in %s due to global limit: %d < %d",
trigger.nick, func.__name__, trigger.sender, globaltimediff,
func.global_rate
)
return
if not trigger.is_privmsg and func in self._times[trigger.sender]:
chantimediff = current_time - self._times[trigger.sender][func]
if func.channel_rate > 0 and chantimediff < func.channel_rate:
LOGGER.info(
"%s prevented from using %s in %s due to channel limit: %d < %d",
trigger.nick, func.__name__, trigger.sender, chantimediff,
func.channel_rate
)
return

This code path still gets used by coretasks.handle_url_callbacks(), but that's the only remaining use of this method that I could find.

It would be helpful for future debugging, I think, if the bot.call_rule() code path had something like this. Right now it just sends a notice if the rate limit has a message, else it just silently returns without doing anything:

sopel/sopel/bot.py

Lines 666 to 670 in da05822

limited, limit_msg = self.rate_limit_info(rule, trigger)
if limit_msg:
sopel.notice(limit_msg, destination=nick)
if limited:
return

Would be nice to have in the logs (INFO or DEBUG, either works) which rate limit was applied, in case there's some confusion during plugin dev.

@dgw dgw added this to the 8.1.0 milestone Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant