aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/example_rule.json
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2025-04-27 12:29:42 +0800
committerGitHub <noreply@github.com>2025-04-27 12:29:42 +0800
commit013fc7460e77799825b8ae5aff9a4e59feec6453 (patch)
tree04e4bb4c368e6266fec7c010362aa77d2a657b80 /test/example_rule.json
parent5319feea52f7266029b9a3a609a3f1ae494c6a60 (diff)
parent9f7e4b5d0a4aa6d9536a6eb1471a110d716e2566 (diff)
downloadconventional_role_play-013fc7460e77799825b8ae5aff9a4e59feec6453.tar.gz
conventional_role_play-013fc7460e77799825b8ae5aff9a4e59feec6453.zip
Merge pull request #8 from pineoncellar/main
feat: 🎨 refactor log parsing logic with simplified rules and priority-based matching
Diffstat (limited to 'test/example_rule.json')
-rw-r--r--test/example_rule.json100
1 files changed, 46 insertions, 54 deletions
diff --git a/test/example_rule.json b/test/example_rule.json
index 0cb5b6c..73abe3f 100644
--- a/test/example_rule.json
+++ b/test/example_rule.json
@@ -1,66 +1,58 @@
-[
+{
+ // 匹配日志元数据,提取 id、QQ 账号和时间。例如:墨勒托.DW(1571806261) 2025-01-27 19:58:15
+ "metadata": {
+ "type": "metadata",
+ "patterns": [
+ "^(\\S+)\\((\\d+)\\)\\s+(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})"
+ ],
+ "groups": ["user_name", "user_id", "time"]
+ },
+ "content": [
{
- // 匹配日志元数据,提取 id、QQ 账号和时间。例如:墨勒托.DW(1571806261) 2025-01-27 19:58:15
- "type": "metadata",
- "patterns": [
- "^(\\S+)\\((\\d+)\\)\\s+(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})"
- ],
- "groups": [
- "user_name",
- "user_id",
- "time"
- ]
+ "type": "action",
+ "match_type": "prefix",
+ "priority": 1001, // 优先级,数字越小优先级越高,范围为1-5000
+ "patterns": ["^#(.+)"],
+ "groups": ["action_content"]
},
{
- "type": "action",
- "patterns": [
- "^#s*((?:(?![“”\"(【】]).)+)"
- ], // 排除后续特殊符号
- "groups": [
- "action_content"
- ]
+ "type": "speech",
+ "match_type": "enclosed",
+ "priority": 101,
+ "patterns": [
+ "[“”\"](.+?)[“”\"]" // 匹配各种引号
+ ],
+ "groups": ["speech_content"]
},
{
- "type": "speech",
- "patterns": [
- "[“](.+?)[”]", // 中文引号
- "\"(.*?)\"", // 英文引号
- "”(.+?)“" // 混合引号
- ],
- "groups": [
- "speech_content"
- ]
+ "type": "ooc_speech",
+ "match_type": "enclosed",
+ "priority": 103,
+ "patterns": [
+ "[\\((](.+?)[\\))]" // 匹配各种括号
+ ],
+ "groups": ["ooc_content"]
},
{
- "type": "ooc_speech",
- "patterns": [
- // "((.*?))", // 英文括号
- "((.*?))", // 中文括号
- // "((.*)", // 未闭合英文括号
- "((.*)" // 未闭合中文括号
- ],
- "groups": [
- "ooc_content"
- ]
+ "type": "suffix_ooc_speech",
+ "match_type": "suffix",
+ "priority": 2001,
+ "patterns": ["(.+)b$"],
+ "groups": ["suffix_ooc_speech"]
},
{
- // 匹配掷骰指令,以 . 或 。开头但是不匹配连续的指令前缀。例如:匹配".ra智力",不匹配"。。。"
- "type": "dice_order",
- "patterns": [
- "^(?:[\\.。]([^.。].+))"
- ],
- "groups": [
- "dice_command"
- ]
+ "type": "dice_order",
+ "match_type": "prefix",
+ "priority": 1,
+ "patterns": ["^[.。](.+)"],
+ "groups": ["dice_command"]
},
{
- // 匹配角色心理活动。例如:【这里好可怕】
- "type": "thought",
- "patterns": [
- "【(.+)】"
- ],
- "groups": [
- "thought_content"
- ]
+ "type": "thought",
+ "match_type": "enclosed",
+ "priority": 102,
+ "patterns": ["【(.+)】"],
+ "groups": ["thought_content"]
}
-] \ No newline at end of file
+ ]
+}