mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-05-07 03:32:18 +08:00
fix: mj open auth bug
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from config import global_config
|
||||
from bridge.reply import Reply, ReplyType
|
||||
from plugins.event import EventContext, EventAction
|
||||
|
||||
|
||||
class Util:
|
||||
@staticmethod
|
||||
def is_admin(e_context: EventContext) -> bool:
|
||||
"""
|
||||
判断消息是否由管理员用户发送
|
||||
:param e_context: 消息上下文
|
||||
:return: True: 是, False: 否
|
||||
"""
|
||||
context = e_context["context"]
|
||||
if context["isgroup"]:
|
||||
actual_user_id = context.kwargs.get("msg").actual_user_id
|
||||
for admin_user in global_config["admin_users"]:
|
||||
if actual_user_id and actual_user_id in admin_user:
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
return context["receiver"] in global_config["admin_users"]
|
||||
|
||||
@staticmethod
|
||||
def set_reply_text(content: str, e_context: EventContext, level: ReplyType = ReplyType.ERROR):
|
||||
reply = Reply(level, content)
|
||||
e_context["reply"] = reply
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
Reference in New Issue
Block a user