Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: dgw <[email protected]>
  • Loading branch information
Exirel and dgw authored Oct 18, 2024
1 parent 23d4436 commit e7a3ec1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,25 +594,22 @@ def rate_limit_info(
) -> tuple[bool, Optional[str]]:
if trigger.admin or rule.is_unblockable():
return False, None

nick = trigger.nick
is_channel = trigger.sender and not trigger.sender.is_nick()
channel = trigger.sender if is_channel else None

user_metrics = rule.get_user_metrics(nick)
channel_metrics = rule.get_channel_metrics(channel)
global_metrics = rule.get_global_metrics()

at_time = trigger.time
if rule.is_user_rate_limited(trigger.nick, at_time):
if rule.is_user_rate_limited(nick, at_time):
template = rule.user_rate_template
rate_limit_type = "user"
rate_limit = rule.user_rate_limit
metrics = user_metrics
metrics = rule.get_user_metrics(nick)
elif is_channel and rule.is_channel_rate_limited(channel, at_time):
template = rule.channel_rate_template
rate_limit_type = "channel"
rate_limit = rule.channel_rate_limit
metrics = channel_metrics
metrics = rule.get_channel_metrics(channel)
elif rule.is_global_rate_limited(at_time):
template = rule.global_rate_template
rate_limit_type = "global"
Expand Down

0 comments on commit e7a3ec1

Please sign in to comment.