Skip to content

rule: $nick in regex pattern is confusing #1885

@Exirel

Description

@Exirel

The problem

When using sopel.module.rule, you can have the variable $nick in the regex pattern:

r'$nickhello' # will match "Bot: hello"
r'$nick hello' # won't match "Bot: hello", but "Bot:  hello" (two spaces)

The $nick variable is super confusing as it should probably accept \s* instead of \s+ so a pattern like r'$nick hello' would be way easier to read and be less prone to error.

The solution

I don't know yet. Is \s* an acceptable change? Do we need to wait until Sopel 8 for that?

Notes

More documentation about these variables is required. Also this comes from a review by @dgw on #1873 where he points out that my comment should be more visible, and not just in a corner of the test suite.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions