mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-17 11:31:18 +00:00
✨ add rule permission reflected operation support (#872)
Feature: 添加 Rule, Permission 反向位运算支持
This commit is contained in:
@ -91,5 +91,13 @@ class Rule:
|
||||
else:
|
||||
return Rule(*self.checkers, other)
|
||||
|
||||
def __or__(self, other) -> NoReturn:
|
||||
def __rand__(self, other: Optional[Union["Rule", T_RuleChecker]]) -> "Rule":
|
||||
if other is None:
|
||||
return self
|
||||
elif isinstance(other, Rule):
|
||||
return Rule(*other.checkers, *self.checkers)
|
||||
else:
|
||||
return Rule(other, *self.checkers)
|
||||
|
||||
def __or__(self, other: object) -> NoReturn:
|
||||
raise RuntimeError("Or operation between rules is not allowed.")
|
||||
|
Reference in New Issue
Block a user