11import plugins
22from bridge .context import ContextType
33from bridge .reply import Reply , ReplyType
4- from config import global_config
54from plugins import *
65from .midjourney import MJBot
76from .summary import LinkSummary
87from bridge import bridge
98from common .expired_dict import ExpiredDict
109from common import const
1110import os
12-
11+ from . utils import Util
1312
1413@plugins .register (
1514 name = "linkai" ,
@@ -129,7 +128,7 @@ def _process_admin_cmd(self, e_context: EventContext):
129128
130129 if len (cmd ) == 2 and (cmd [1 ] == "open" or cmd [1 ] == "close" ):
131130 # 知识库开关指令
132- if not _is_admin (e_context ):
131+ if not Util . is_admin (e_context ):
133132 _set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
134133 return
135134 is_open = True
@@ -147,7 +146,7 @@ def _process_admin_cmd(self, e_context: EventContext):
147146 if not context .kwargs .get ("isgroup" ):
148147 _set_reply_text ("该指令需在群聊中使用" , e_context , level = ReplyType .ERROR )
149148 return
150- if not _is_admin (e_context ):
149+ if not Util . is_admin (e_context ):
151150 _set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
152151 return
153152 app_code = cmd [2 ]
@@ -164,7 +163,7 @@ def _process_admin_cmd(self, e_context: EventContext):
164163
165164 if len (cmd ) == 3 and cmd [1 ] == "sum" and (cmd [2 ] == "open" or cmd [2 ] == "close" ):
166165 # 知识库开关指令
167- if not _is_admin (e_context ):
166+ if not Util . is_admin (e_context ):
168167 _set_reply_text ("需要管理员权限执行" , e_context , level = ReplyType .ERROR )
169168 return
170169 is_open = True
@@ -253,23 +252,6 @@ def _send_info(e_context: EventContext, content: str):
253252 channel = e_context ["channel" ]
254253 channel .send (reply , e_context ["context" ])
255254
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-
273255
274256def _find_user_id (context ):
275257 if context ["isgroup" ]:
0 commit comments