正则引擎联动
向 LumenBridge 的正则引擎注册自定义动作,可在 rules.json 中通过 callPluginCommand 调用:
python
def on_load(lumen):
# 注册自定义动作「queryMoney」
def query_money(params, pack, context):
qq = params[0] if params else str(pack.get("user_id", ""))
money = lumen.storage.read("money.json", {}).get(qq, 0)
return {"money": money} # 写入 $money 变量
lumen.register_regex_action("queryMoney", query_money)在 rules.json 中使用:
json
{
"id": "rule_query_money",
"pattern": "^查余额$",
"actions": [
{"type": "callPluginCommand", "params": "queryMoney,$userId"},
{"type": "replyText", "params": "你的余额:$money 金币"}
]
}