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

irc: configure anti-looping system #2320

Merged
merged 1 commit into from
Aug 6, 2022

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Jul 14, 2022

Description

Tin, fix #1618.

The feature was surprisingly easy to implement, this is a draft because I want to make sure I've the right names before writing more documentation.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added the Feature label Jul 14, 2022
@Exirel Exirel added this to the 8.0.0 milestone Jul 14, 2022
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep forgetting that people ask about that, even though we do have an issue about it. 😅 Thanks for just sitting down and writing the patch. Few general thoughts:

  • How about antiloop_ as a prefix for these options? Though I'm all ears for something that fits a bit better with flood_.
    • As ideas for new names:
      • anti_looping -> antiloop_threshold
      • anti_looping_repeat -> antiloop_silent_after
      • anti_looping_timeframe -> antiloop_window
  • With the other options already set, why not add a way to override the ... message? Maybe someone would like Sopel to say "Ditto", for example.

sopel/config/core_section.py Outdated Show resolved Hide resolved
@Exirel Exirel force-pushed the anti-loop-configuration branch 3 times, most recently from 8aeaab9 to b4a5771 Compare July 14, 2022 10:49
@Exirel Exirel marked this pull request as ready for review July 14, 2022 11:12
@Exirel
Copy link
Contributor Author

Exirel commented Jul 14, 2022

And I even added tests.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't I notice the hard-coded lookback number (8 lines) before? No idea. Must have looked at the code on my phone, which always makes it easy to get lost. Small screen problems.

And I even added tests.

Blasphemy! Ban this man! /s

docs/source/configuration.rst Outdated Show resolved Hide resolved
docs/source/configuration.rst Outdated Show resolved Hide resolved
docs/source/configuration.rst Outdated Show resolved Hide resolved
@Exirel
Copy link
Contributor Author

Exirel commented Jul 17, 2022

Albeit not perfect, the time window has it uses as it prevents some false positive. However, it's not really well done, because it only check if the last message is within that time window, so you could have one message 5s away, and the previous 7 a day old, and it'll still think there is a loop.

However, I don't feel like fixing that in this PR, I would like to keep the configuration change and the behavior change as separated as possible.

Why didn't I notice the hard-coded lookback number (8 lines) before?

On the other hand, Sopel remembers 10 messages per channel/user anyway. So I can remove that limit and just look at the last 10 messages directly.

@Exirel
Copy link
Contributor Author

Exirel commented Jul 17, 2022

And so I changed the 8 to 10 and changed the doc accordingly. I added a warning in the doc for good measure, because setting the threshold to more than 10 will deactivate the loop prevention system and that might not be obvious to a user.

@dgw
Copy link
Member

dgw commented Jul 17, 2022

Is there a reason not to clamp the value to max 10 with a custom parse (and/or serialize) function? Disabling the flood prevention is documented explicitly (and improved on by one of my recent PRs).

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more implementation thing about the number of messages considered, while I'm awaiting Exi's thoughts on clamping the antiloop_threshold value to max 10.

sopel/irc/__init__.py Show resolved Hide resolved
@Exirel Exirel force-pushed the anti-loop-configuration branch from 90ecf45 to 7371b73 Compare July 22, 2022 19:25
@Exirel
Copy link
Contributor Author

Exirel commented Jul 22, 2022

Given the status of the review, I squashed the commits while adding the min(10, 'antiloop_threshold'). I replaced the warning by the note, and that's all I did in here.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I squashed the commits while adding the min(10, 'antiloop_threshold'). I replaced the warning by the note, and that's all I did in here.

You also rebased while doing that, though. I can't click "force-pushed" in the event history to get the diff between the previous state and the current state without wading through clutter pulled from upstream. :/

So I re-reviewed everything, and came up with more line notes than I probably would have if I'd only had to look at the new changes. Serves you right. 🤪

docs/source/configuration.rst Outdated Show resolved Hide resolved
docs/source/configuration.rst Outdated Show resolved Hide resolved
sopel/config/core_section.py Outdated Show resolved Hide resolved
sopel/config/core_section.py Outdated Show resolved Hide resolved
sopel/irc/__init__.py Show resolved Hide resolved
sopel/irc/__init__.py Show resolved Hide resolved
@Exirel
Copy link
Contributor Author

Exirel commented Aug 5, 2022

And I applied the changes. No squash, no rebase yet. You tell me when it's all OK for you.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, this is good to go (squash). If I missed anything by reviewing on my phone, so be it. 🙃

Co-authored-by: dgw <dgw@technobabbl.es>
@Exirel Exirel force-pushed the anti-loop-configuration branch from 3431365 to f565f61 Compare August 6, 2022 22:47
@Exirel
Copy link
Contributor Author

Exirel commented Aug 6, 2022

Squashed.

@dgw dgw merged commit 6101e3a into sopel-irc:master Aug 6, 2022
@Exirel Exirel deleted the anti-loop-configuration branch April 8, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the disabling of repetition detection
2 participants