-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2244 from sopel-irc/plugin.allow_bots
loader, plugin, plugins.rules: add `allow_bots` decorator
- Loading branch information
Showing
6 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,6 +687,45 @@ def test_rule_match_privmsg_echo(mockbot): | |
assert match.group(0) == 'Hi!' | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'is_bot, allow_bots, is_echo, allow_echo, should_match', | ||
[ | ||
(True, True, True, True, True), | ||
(True, True, True, False, False), | ||
(True, True, False, True, True), | ||
(True, True, False, False, True), | ||
(True, False, True, True, True), | ||
(True, False, True, False, False), | ||
(True, False, False, True, False), | ||
(True, False, False, False, False), | ||
(False, True, True, True, True), | ||
(False, True, True, False, False), | ||
(False, True, False, True, True), | ||
(False, True, False, False, True), | ||
(False, False, True, True, True), | ||
(False, False, True, False, False), | ||
(False, False, False, True, True), | ||
(False, False, False, False, True), | ||
]) | ||
def test_rule_match_privmsg_echo_and_bot_tag( | ||
is_bot, allow_bots, is_echo, allow_echo, should_match, mockbot | ||
): | ||
line = '{tags}:{nick}[email protected] PRIVMSG #sopel :Hi!'.format( | ||
tags='@bot ' if is_bot else '', | ||
nick=mockbot.nick if is_echo else 'SomeUser', | ||
) | ||
pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
regex = re.compile(r'.*') | ||
|
||
rule = rules.Rule([regex], allow_bots=allow_bots, allow_echo=allow_echo) | ||
matches = list(rule.match(mockbot, pretrigger)) | ||
|
||
if should_match: | ||
assert len(matches) == 1, 'This combination should match the Rule' | ||
else: | ||
assert not matches, 'This combination should not match the Rule' | ||
|
||
|
||
def test_rule_match_join(mockbot): | ||
line = ':[email protected] JOIN #sopel' | ||
pretrigger = trigger.PreTrigger(mockbot.nick, line) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters