1
- import plugin from ' ../../../lib/plugins/plugin.js'
2
- import Cfg from ' ../model/Cfg.js'
3
- import fs from ' node:fs'
4
- import _ from ' lodash'
1
+ import plugin from " ../../../lib/plugins/plugin.js" ;
2
+ import Cfg from " ../model/Cfg.js" ;
3
+ import fs from " node:fs" ;
4
+ import _ from " lodash" ;
5
5
6
6
export class ji_config extends plugin {
7
- constructor ( ) {
8
- super ( {
9
- name : '寄·配置' ,
10
- dsc : '' ,
11
- event : 'message' ,
12
- priority : Cfg . getConfig ( 'config' ) . priority ?? - 114514 ,
13
- rule : [
14
- {
15
- reg : / ^ # ( 社 区 ) ? 签 到 ( 添 加 | 删 除 ) ? ( 白 名 单 | 推 送 ) ( 群 ) ? .* $ / i,
16
- permission : 'master' ,
17
- fnc : 'setwhite'
18
- } ,
19
- {
20
- reg : '^#?设置社区签到(经验|米币)$' ,
21
- fnc : 'setbbs'
22
- } ,
23
- {
24
- reg : '^#?(原神|星铁|绝区零)?(禁用|解禁)(uid)?\\s*(1[0-9]|[1-9])?[0-9]{8}$' ,
25
- fnc : 'banUid'
26
- } ,
27
- {
28
- reg : '^#?寄(替换|还原)$' ,
29
- permission : 'master' ,
30
- fnc : 'jicopy'
31
- }
32
- ]
33
- } )
7
+ constructor ( ) {
8
+ super ( {
9
+ name : "寄·配置" ,
10
+ dsc : "" ,
11
+ event : "message" ,
12
+ priority : Cfg . getConfig ( "config" ) . priority ?? - 114514 ,
13
+ rule : [
14
+ {
15
+ reg : "^#?设置社区签到(经验|米币)$" ,
16
+ fnc : "setbbs" ,
17
+ } ,
18
+ {
19
+ reg : "^#?(原神|星铁|绝区零)?(禁用|解禁)(uid)?\\s*(1[0-9]|[1-9])?[0-9]{8}$" ,
20
+ fnc : "banUid" ,
21
+ } ,
22
+ {
23
+ reg : "^#?寄(替换|还原)$" ,
24
+ permission : "master" ,
25
+ fnc : "jicopy" ,
26
+ } ,
27
+ ] ,
28
+ } ) ;
29
+ }
30
+ async setbbs ( e ) {
31
+ let id = Number ( e . user_id ) || String ( e . user_id ) ;
32
+
33
+ if ( e . msg . includes ( "经验" ) ) {
34
+ return e . reply ( `\n社区签到模式已设置:【米币+经验】` , false , {
35
+ at : true ,
36
+ } ) ;
37
+ } else if ( e . msg . includes ( "米币" ) ) {
38
+ if ( index !== - 1 ) {
39
+ e . reply ( `\n社区签到模式已设置:【米币】` , false , { at : true } ) ;
40
+ } else {
41
+ e . reply ( `\n当前社区签到模式:【米币】` , false , { at : true } ) ;
42
+ }
43
+ return ;
34
44
}
35
-
36
- async setwhite ( e ) {
37
- let white = Cfg . getConfig ( 'white' )
38
- let id = e . msg . replace ( / # ( 社 区 ) ? 签 到 ( 添 加 | 删 除 ) ? ( 白 名 单 | 推 送 ) ( 群 ) ? \s * / i, '' ) . trim ( )
39
- if ( e . msg . includes ( '群' ) || e . msg . includes ( '推送' ) ) return e . reply ( '建议使用锅巴配置' )
40
-
41
- let action = e . msg . includes ( '添加' ) ? '添加' : '删除'
42
- let set = white [ e . msg . includes ( '群' ) ? 'Group' : e . msg . includes ( '社区' ) ? 'bbsQQ' : 'QQ' ]
43
- let name = e . msg . includes ( '群' ) ? '群' : 'QQ'
44
- let push = e . msg . includes ( '推送' ) ? '推送' : '白'
45
-
46
- if ( ! id ) id = e . user_id
47
-
48
- id = Number ( id ) || String ( id )
49
-
50
- if ( action === '添加' ) {
51
- if ( set && set . includes ( id ) )
52
- return e . reply ( `${ name } :${ id } 已在${ push } 名单中` )
53
- set . push ( id )
54
- Cfg . setConfig ( 'white' , white )
55
- return e . reply ( `已${ action } ${ push } 名单${ name } :${ id } ` )
56
- } else if ( action === '删除' ) {
57
- if ( set . length === 0 )
58
- return e . reply ( `未添加${ push } 名单${ name } ` )
59
-
60
- let index = set . findIndex ( q => q == id )
61
- if ( index !== - 1 ) {
62
- set . splice ( index , 1 )
63
- Cfg . setConfig ( 'white' , white )
64
- e . reply ( `已${ action } ${ push } 名单${ name } :${ id } ` )
65
- } else {
66
- e . reply ( `${ name } :${ id } 未在${ push } 名单中` )
67
- }
68
- return
69
- } else {
70
- let msg = set . slice ( )
71
- msg = msg . map ( ( e , i ) => `${ i + 1 } . ${ e } ` ) . join ( ', ' )
72
- return e . reply ( msg , false )
73
- }
74
- }
75
-
76
- async setbbs ( e ) {
77
- let white = Cfg . getConfig ( 'white' )
78
- let id = Number ( e . user_id ) || String ( e . user_id )
79
-
80
- if ( e . msg . includes ( '经验' ) ) {
81
- if ( white . exQQ ?. includes ( id ) )
82
- return e . reply ( `\n当前社区签到模式:【米币+经验】` , false , { at : true } )
83
-
84
- white . exQQ . push ( id )
85
- Cfg . setConfig ( 'white' , white )
86
- return e . reply ( `\n社区签到模式已设置:【米币+经验】` , false , { at : true } )
87
- } else if ( e . msg . includes ( '米币' ) ) {
88
- if ( white . exQQ . length === 0 )
89
- return e . reply ( `\n当前社区签到模式:【米币】` , false , { at : true } )
90
-
91
- let index = white . exQQ . findIndex ( q => q == id )
92
- if ( index !== - 1 ) {
93
- white . exQQ . splice ( index , 1 )
94
- Cfg . setConfig ( 'white' , white )
95
- e . reply ( `\n社区签到模式已设置:【米币】` , false , { at : true } )
96
- } else {
97
- e . reply ( `\n当前社区签到模式:【米币】` , false , { at : true } )
98
- }
99
- return
100
- }
45
+ }
46
+
47
+ async banUid ( e ) {
48
+ let uid = Number (
49
+ e . msg . replace ( / # ? ( 原 神 | 星 铁 | 绝 区 零 ) ? ( 禁 用 | 解 禁 ) ( u i d ) ? \s * / i, "" ) . trim ( )
50
+ ) ;
51
+
52
+ if ( ! uid ) return e . reply ( "未输入UID" ) ;
53
+
54
+ let Uid = Cfg . getConfig ( "banuid" ) ;
55
+
56
+ let name = e . msg . includes ( "原神" )
57
+ ? "原神"
58
+ : e . msg . includes ( "星铁" )
59
+ ? "星铁"
60
+ : "绝区零" ;
61
+ let set =
62
+ Uid [
63
+ e . msg . includes ( "原神" ) ? "gs" : e . msg . includes ( "星铁" ) ? "sr" : "zzz"
64
+ ] ;
65
+ let action = e . msg . includes ( "禁用" ) ? "禁用" : "解禁" ;
66
+ let g = e . msg . includes ( "原神" )
67
+ ? "gs"
68
+ : e . msg . includes ( "星铁" )
69
+ ? "sr"
70
+ : "zzz" ;
71
+
72
+ if ( ! e . isMaster ) {
73
+ let { cks } = await Cfg . getcks ( false , e . user_id ) ;
74
+ if ( _ . isEmpty ( cks [ g ] ) )
75
+ return e . reply ( "未绑定ck,或此UID已禁用" , false , { at : true } ) ;
76
+ if ( ! cks [ g ] [ uid ] )
77
+ return e . reply ( `只能${ action } 自己已绑ck的uid\n或此UID已禁用` ) ;
101
78
}
102
79
103
- async banUid ( e ) {
104
- let uid = Number ( e . msg . replace ( / # ? ( 原 神 | 星 铁 | 绝 区 零 ) ? ( 禁 用 | 解 禁 ) ( u i d ) ? \s * / i, '' ) . trim ( ) )
105
-
106
- if ( ! uid ) return e . reply ( '未输入UID' )
107
-
108
- let Uid = Cfg . getConfig ( 'banuid' )
109
-
110
- let name = e . msg . includes ( '原神' ) ? '原神' : e . msg . includes ( '星铁' ) ? '星铁' : '绝区零'
111
- let set = Uid [ e . msg . includes ( '原神' ) ? 'gs' : e . msg . includes ( '星铁' ) ? 'sr' : 'zzz' ]
112
- let action = e . msg . includes ( '禁用' ) ? '禁用' : '解禁'
113
- let g = e . msg . includes ( '原神' ) ? 'gs' : e . msg . includes ( '星铁' ) ? 'sr' : 'zzz'
114
-
115
- if ( ! e . isMaster ) {
116
- let { cks } = await Cfg . getcks ( false , e . user_id )
117
- if ( _ . isEmpty ( cks [ g ] ) )
118
- return e . reply ( '未绑定ck,或此UID已禁用' , false , { at : true } )
119
- if ( ! cks [ g ] [ uid ] )
120
- return e . reply ( `只能${ action } 自己已绑ck的uid\n或此UID已禁用` )
121
- }
122
-
123
- if ( action === '禁用' ) {
124
- if ( set && set . includes ( uid ) )
125
- return e . reply ( `${ name } UID:${ uid } 已禁用` )
126
-
127
- set . push ( uid )
128
- Cfg . setConfig ( 'banuid' , Uid )
129
- return e . reply ( `已${ action } ${ name } UID:${ uid } ` )
130
- } else {
131
- if ( set . length === 0 )
132
- return e . reply ( `未添加禁用UID` )
133
-
134
- let index = set . findIndex ( q => q == uid )
135
- if ( index !== - 1 ) {
136
- set . splice ( index , 1 )
137
- Cfg . setConfig ( 'banuid' , Uid )
138
- e . reply ( `已${ action } ${ name } UID:${ uid } ` )
139
- } else {
140
- e . reply ( `${ name } UID:${ uid } 未禁用` )
141
- }
142
- return
143
- }
80
+ if ( action === "禁用" ) {
81
+ if ( set && set . includes ( uid ) ) return e . reply ( `${ name } UID:${ uid } 已禁用` ) ;
82
+
83
+ set . push ( uid ) ;
84
+ Cfg . setConfig ( "banuid" , Uid ) ;
85
+ return e . reply ( `已${ action } ${ name } UID:${ uid } ` ) ;
86
+ } else {
87
+ if ( set . length === 0 ) return e . reply ( `未添加禁用UID` ) ;
88
+
89
+ let index = set . findIndex ( ( q ) => q == uid ) ;
90
+ if ( index !== - 1 ) {
91
+ set . splice ( index , 1 ) ;
92
+ Cfg . setConfig ( "banuid" , Uid ) ;
93
+ e . reply ( `已${ action } ${ name } UID:${ uid } ` ) ;
94
+ } else {
95
+ e . reply ( `${ name } UID:${ uid } 未禁用` ) ;
96
+ }
97
+ return ;
144
98
}
145
-
146
- async jicopy ( e ) {
147
- let info = './plugins/genshin/model/mys/mysInfo.js'
148
- if ( ! fs . existsSync ( `${ Cfg . resfile } temp` ) )
149
- fs . mkdirSync ( `${ Cfg . resfile } temp` )
150
-
151
- if ( e . msg . includes ( '替换' ) ) {
152
- if ( fs . existsSync ( `${ Cfg . resfile } temp/mysInfo.js` ) )
153
- return e . reply ( '已有未还原备份,若无更新冲突无需替换\n否则请【#寄还原】后更新本体再替换' )
154
- fs . copyFileSync ( info , `${ Cfg . resfile } temp/mysInfo.js` )
155
- fs . copyFileSync ( `${ Cfg . defile } /mysInfo.js` , info )
156
- return e . reply ( '替换成功,重启后生效' )
157
- } else {
158
- if ( ! fs . existsSync ( `${ Cfg . resfile } temp/mysInfo.js` ) )
159
- return e . reply ( '你还没有替换过,无法还原哦' )
160
- fs . copyFileSync ( `${ Cfg . resfile } temp/mysInfo.js` , info )
161
- fs . unlinkSync ( `${ Cfg . resfile } temp/mysInfo.js` )
162
- return e . reply ( '还原成功' )
163
- }
99
+ }
100
+
101
+ async jicopy ( e ) {
102
+ let info = "./plugins/genshin/model/mys/mysInfo.js" ;
103
+ if ( ! fs . existsSync ( `${ Cfg . resfile } temp` ) )
104
+ fs . mkdirSync ( `${ Cfg . resfile } temp` ) ;
105
+
106
+ if ( e . msg . includes ( "替换" ) ) {
107
+ if ( fs . existsSync ( `${ Cfg . resfile } temp/mysInfo.js` ) )
108
+ return e . reply (
109
+ "已有未还原备份,若无更新冲突无需替换\n否则请【#寄还原】后更新本体再替换"
110
+ ) ;
111
+ fs . copyFileSync ( info , `${ Cfg . resfile } temp/mysInfo.js` ) ;
112
+ fs . copyFileSync ( `${ Cfg . defile } /mysInfo.js` , info ) ;
113
+ return e . reply ( "替换成功,重启后生效" ) ;
114
+ } else {
115
+ if ( ! fs . existsSync ( `${ Cfg . resfile } temp/mysInfo.js` ) )
116
+ return e . reply ( "你还没有替换过,无法还原哦" ) ;
117
+ fs . copyFileSync ( `${ Cfg . resfile } temp/mysInfo.js` , info ) ;
118
+ fs . unlinkSync ( `${ Cfg . resfile } temp/mysInfo.js` ) ;
119
+ return e . reply ( "还原成功" ) ;
164
120
}
165
- }
121
+ }
122
+ }
0 commit comments