refactor: 独立resprule为单独的包

This commit is contained in:
RockChinQ
2024-01-25 18:07:28 +08:00
parent ea9ae85428
commit f4ead5ec5c
11 changed files with 236 additions and 114 deletions
+22
View File
@@ -0,0 +1,22 @@
import random
import mirai
from .. import rule as rule_model
from .. import entities
class RandomRespRule(rule_model.GroupRespondRule):
async def match(
self,
message_text: str,
message_chain: mirai.MessageChain,
rule_dict: dict
) -> entities.RuleJudgeResult:
random_rate = rule_dict['random_rate']
return entities.RuleJudgeResult(
matching=random.random() < random_rate,
replacement=message_chain
)