1
1
import plugins
2
2
from bridge .context import ContextType
3
3
from bridge .reply import Reply , ReplyType
4
- from config import global_config
5
4
from plugins import *
6
5
from .midjourney import MJBot
7
6
from .summary import LinkSummary
8
7
from bridge import bridge
9
8
from common .expired_dict import ExpiredDict
10
9
from common import const
11
10
import os
12
-
11
+ from . utils import Util
13
12
14
13
@plugins .register (
15
14
name = "linkai" ,
@@ -129,7 +128,7 @@ def _process_admin_cmd(self, e_context: EventContext):
129
128
130
129
if len (cmd ) == 2 and (cmd [1 ] == "open" or cmd [1 ] == "close" ):
131
130
# 知识库开关指令
132
- if not _is_admin (e_context ):
131
+ if not Util . is_admin (e_context ):
133
132
_set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
134
133
return
135
134
is_open = True
@@ -147,7 +146,7 @@ def _process_admin_cmd(self, e_context: EventContext):
147
146
if not context .kwargs .get ("isgroup" ):
148
147
_set_reply_text ("该指令需在群聊中使用" , e_context , level = ReplyType .ERROR )
149
148
return
150
- if not _is_admin (e_context ):
149
+ if not Util . is_admin (e_context ):
151
150
_set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
152
151
return
153
152
app_code = cmd [2 ]
@@ -164,7 +163,7 @@ def _process_admin_cmd(self, e_context: EventContext):
164
163
165
164
if len (cmd ) == 3 and cmd [1 ] == "sum" and (cmd [2 ] == "open" or cmd [2 ] == "close" ):
166
165
# 知识库开关指令
167
- if not _is_admin (e_context ):
166
+ if not Util . is_admin (e_context ):
168
167
_set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
169
168
return
170
169
is_open = True
@@ -253,23 +252,6 @@ def _send_info(e_context: EventContext, content: str):
253
252
channel = e_context ["channel" ]
254
253
channel .send (reply , e_context ["context" ])
255
254
256
- # 静态方法
257
- def _is_admin (e_context : EventContext ) -> bool :
258
- """
259
- 判断消息是否由管理员用户发送
260
- :param e_context: 消息上下文
261
- :return: True: 是, False: 否
262
- """
263
- context = e_context ["context" ]
264
- if context ["isgroup" ]:
265
- actual_user_id = context .kwargs .get ("msg" ).actual_user_id
266
- for admin_user in global_config ["admin_users" ]:
267
- if actual_user_id and actual_user_id in admin_user :
268
- return True
269
- return False
270
- else :
271
- return context ["receiver" ] in global_config ["admin_users" ]
272
-
273
255
274
256
def _find_user_id (context ):
275
257
if context ["isgroup" ]:
0 commit comments