lobsters / lobsters-ansible

Ansible playbook for lobste.rs
ISC License
78 stars 25 forks source link

Add rate-limiting to the peterson sopel trigger. #51

Closed alanpost closed 4 years ago

alanpost commented 4 years ago

We have a trigger in #lobsters such that if a user names Jordon Peterson (via [Pp]eterson) we issue our standard blurb regarding non-association despite both communities using the label "Lobsters:"

13:05 peterson 13:05 alynpost: The site has nothing to do with Jordan Peterson: https://lobste.rs/about#michaelbolton

This trigger is implemented in the following sopel module:

https://github.com/lobsters/lobsters-ansible/blob/master/roles/mockturtle/files/sopel_modules/peterson.py

The problem is that it triggers every time a user matches the trigger. It would be better if the trigger had a rate limit so it only replied every 5 minutes. The sopel API has a rate limiter, which can be used for this trigger to do just that:

https://sopel.chat/docs/plugin.html#sopel.module.rate

This issue covers adding that rate limiter as a decorator in the peterson module.

bbuccianti commented 4 years ago

Great explanation!

I think this commit resolves this issue https://github.com/bbuccianti/lobsters-ansible/commit/34999617b71eca1b8e514a3f13d6a186443b663b

alanpost commented 4 years ago

Fixed in PR #52.