Skip to content

Commit

Permalink
Change the 8 messages rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
Exirel committed Jul 17, 2022
1 parent 6d9ba2c commit 90ecf45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ Loop prevention

In order to prevent the bot from entering a loop (for example when there is
another bot in the same channel, or if a user spams a command), it'll try to
see if the next message to send is repeating too often in the last eight
messages in the last few minutes. If that happens, the bot will send ``...``
a few times before remaining silent::
see if the next message to send is repeating too often in the last ten messages
in the last few minutes. If that happens, the bot will send ``...`` a few times
before remaining silent::

<bot> I repeat myself!
<bot> I repeat myself!
Expand Down Expand Up @@ -394,8 +394,8 @@ For example this configuration::
antiloop_window = 60
antiloop_repeat_text = Ditto.

will activate the loop prevention feature if there is at least one message
in the last 60s, from the last 8 messages, 2 are already the same. In that case
will activate the loop prevention feature if there is at least one message in
the last 60s, from the last 10 messages, 2 are already the same. In that case
the bot will send ``...``, but only *once*. After that, the bot will remain
silent. This doesn't affect other messages, i.e. messages that don't repeat::

Expand All @@ -418,6 +418,12 @@ You can **deactivate** the loop prevention by setting
new configuration options are: ``antiloop_threshold``,
``antiloop_silent_after``, and ``antiloop_window``.

.. warning::

Since Sopel remembers only the last ten messages, setting
``antiloop_threshold`` to a number bigger than ten effectively deactivates
the loop prevention system.

Perform commands on connect
---------------------------

Expand Down
2 changes: 1 addition & 1 deletion sopel/irc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def say(

# Loop detection
if antiloop_threshold > 0 and elapsed < antiloop_window:
messages = [m[1] for m in recipient_stack['messages'][-8:]]
messages = [m[1] for m in recipient_stack['messages'][-10:]]

# If what we're about to send repeated at least N times
# in the anti-looping window, replace it
Expand Down

0 comments on commit 90ecf45

Please sign in to comment.