1
1
/* global JsonConfigFile WSClient mc ll logger Format */
2
2
3
3
// 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" />
5
5
6
6
// 控制台颜色控制符
7
7
const conGreen = '\u001b[0;32m' ;
@@ -20,6 +20,7 @@ config.init('enable_groups', ['']);
20
20
config . init ( 'log_level' , 4 ) ;
21
21
config . init ( 'cmd_prefix' , '/' ) ;
22
22
config . init ( 'cmd_status' , '查询' ) ;
23
+ config . init ( 'allow_cmd' , [ '^list$' ] ) ;
23
24
24
25
const ws = new WSClient ( ) ;
25
26
const reqCache = new Map ( ) ;
@@ -310,6 +311,18 @@ ${playerLi
310
311
` . trim ( ) ;
311
312
}
312
313
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
+
313
326
/**
314
327
* 群消息处理
315
328
* @param {object } ev
@@ -356,14 +369,14 @@ function processGroupMsg(ev) {
356
369
357
370
// 执行指令
358
371
if ( txtMsg . startsWith ( config . get ( 'cmd_prefix' ) ) ) {
372
+ const cmd = txtMsg . slice ( config . get ( 'cmd_prefix' ) . length ) ;
359
373
if (
360
374
config
361
375
. get ( 'superusers' )
362
376
. map ( ( i ) => i . toString ( ) )
363
- . includes ( userId . toString ( ) )
377
+ . includes ( userId . toString ( ) ) ||
378
+ isAllowedCmd ( cmd )
364
379
) {
365
- const cmd = txtMsg . slice ( 1 ) ;
366
-
367
380
const { success, output } = mc . runcmdEx ( cmd ) ;
368
381
const stateTxt = success ? '成功' : '失败' ;
369
382
fastReply ( `执行${ stateTxt } \n${ output } ` ) ;
@@ -603,7 +616,7 @@ mc.regConsoleCmd('cqreconnect', '手动重连GoCQHTTP', () => {
603
616
return reconnectGoCQ ( ) ;
604
617
} ) ;
605
618
606
- ll . registerPlugin ( 'GoCQSync' , '依赖GoCQHTTP的群服互通' , [ 0 , 4 , 0 ] , {
619
+ ll . registerPlugin ( 'GoCQSync' , '依赖GoCQHTTP的群服互通' , [ 0 , 4 , 2 ] , {
607
620
Author : 'student_2333' ,
608
621
License : 'Apache-2.0' ,
609
622
} ) ;
0 commit comments