sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
949 stars 403 forks source link

rules: allow toggling case sensitivity #2484

Open dgw opened 1 year ago

dgw commented 1 year ago

Requested Feature

Plugin rules defined using @rule, @search, @find, and friends are currently forced to be case insensitive. Bot-owner users ask often enough about making certain custom triggers case-sensitive that we should allow for it in the API.

We've dropped enough old Python versions that we should be able to add keyword-only arguments to the relevant decorators.

Problems Solved

Use cases for this functionality mostly revolve around reducing accidental triggering of rules that overlap with common words/abbreviations. I can see a few places in first-party code where it could be useful, too, like in sopel-reddit's slash-reference matching.

Alternatives

Alternatives are pretty hacky: defining the case-insensitive rule or matching on all messages, and then matching a second time at the beginning of the plugin callable with a case-sensitive pattern.

Matching the same line twice is inefficient, on top of making the plugin code messy.

Notes

No response