Skip to content

Commit a3b8b9c

Browse files
committed
2 parents 52c8832 + 376c2a5 commit a3b8b9c

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

GoCQSync/GoCQSync.lxl.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global JsonConfigFile WSClient mc ll logger Format */
22

33
// LiteLoaderScript Dev Helper
4-
/// <reference path="E:\Coding\bds\.vscode\LLSEDevHelper/Library/JS/Api.js" />
4+
/// <reference path="c:\Users\Administrator\Desktop\llse\LLSEPlugins\.vscode\Library/dts/llaids/src/index.d.ts"/>
55

66
// 控制台颜色控制符
77
const conGreen = '\u001b[0;32m';
@@ -20,6 +20,7 @@ config.init('enable_groups', ['']);
2020
config.init('log_level', 4);
2121
config.init('cmd_prefix', '/');
2222
config.init('cmd_status', '查询');
23+
config.init('allow_cmd', ['^list$']);
2324

2425
const ws = new WSClient();
2526
const reqCache = new Map();
@@ -310,6 +311,18 @@ ${playerLi
310311
`.trim();
311312
}
312313

314+
/**
315+
* @param {string} cmd
316+
* @returns {boolean}
317+
*/
318+
function isAllowedCmd(cmd) {
319+
const allowed = config.get('allow_cmd');
320+
for (const reg of allowed) {
321+
if (RegExp(reg).test(cmd)) return true;
322+
}
323+
return false;
324+
}
325+
313326
/**
314327
* 群消息处理
315328
* @param {object} ev
@@ -356,14 +369,14 @@ function processGroupMsg(ev) {
356369

357370
// 执行指令
358371
if (txtMsg.startsWith(config.get('cmd_prefix'))) {
372+
const cmd = txtMsg.slice(config.get('cmd_prefix').length);
359373
if (
360374
config
361375
.get('superusers')
362376
.map((i) => i.toString())
363-
.includes(userId.toString())
377+
.includes(userId.toString()) ||
378+
isAllowedCmd(cmd)
364379
) {
365-
const cmd = txtMsg.slice(1);
366-
367380
const { success, output } = mc.runcmdEx(cmd);
368381
const stateTxt = success ? '成功' : '失败';
369382
fastReply(`执行${stateTxt}\n${output}`);
@@ -603,7 +616,7 @@ mc.regConsoleCmd('cqreconnect', '手动重连GoCQHTTP', () => {
603616
return reconnectGoCQ();
604617
});
605618

606-
ll.registerPlugin('GoCQSync', '依赖GoCQHTTP的群服互通', [0, 4, 0], {
619+
ll.registerPlugin('GoCQSync', '依赖GoCQHTTP的群服互通', [0, 4, 2], {
607620
Author: 'student_2333',
608621
License: 'Apache-2.0',
609622
});

GoCQSync/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<!-- markdownlint-disable MD031 MD033 -->
1+
<!-- markdownlint-disable MD031 MD033 MD036 -->
22

33
# GoCQSync
44

5-
**项目暂停更新,请使用nodejs版ll的用户移步 [QBotForLiteloader](https://github.com/yanhy2000/QBotForLiteloader)**
5+
**目前已不推荐使用本插件,请移步 YoyoRobot、QBotForLiteLoader 等插件**
66

77
一个依赖 [GoCQHTTP](https://github.com/Mrs4s/go-cqhttp) 的群服互通插件
88

@@ -98,15 +98,17 @@
9898
"enable_groups": ["987654321"],
9999
100100
// 日志输出等级:Number
101-
// 见 https://docs.litebds.com/#/zh_CN/Development/ScriptAPI/Logger?id=%e6%a6%82%e5%bf%b5%ef%bc%9a%e5%85%b3%e4%ba%8e%e6%97%a5%e5%bf%97%e8%be%93%e5%87%ba%e7%ad%89%e7%ba%a7
102-
// 本插件只会输出 ERROR INFO DEBUG 等级的日志,一般情况保持默认即可
101+
// 一般情况保持默认即可
103102
"log_level": 4,
104103
105104
// 管理员执行控制台指令的消息前缀
106105
"cmd_prefix": "/",
107106
108107
// 查询服务器状态指令(与戳一戳相同)
109-
"cmd_status": "查询"
108+
"cmd_status": "查询",
109+
110+
// 群聊中非 superuser 可以执行的指令,使用正则表达式匹配
111+
"allow_cmd": ["^list$"]
110112
}
111113
```
112114

@@ -161,5 +163,9 @@ QQ:3076823485
161163
- 修复正则匹配 CQ 码
162164
- 0.4.0
163165
- 添加配置项`cmd_prefix`、`cmd_status`,详情见[配置文件](#配置文件)
166+
- 0.4.1
167+
- 修复`cmd_prefix`长度大于 1 时出现的问题
168+
- 0.4.2
169+
- 添加配置项`allow_cmd`
164170

165171
## 文档待完善 (\*σ´∀`)σ

0 commit comments

Comments
 (0)