Skip to content

rules: allow toggling case sensitivity #2484

@dgw

Description

@dgw

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions