Download plugins/linkai/utils.py from hhz520/webchat: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/hhz520/webchat/resolve/main/plugins/linkai/utils.py
- Command line
-
hf download hf://spaces/hhz520/webchat/plugins/linkai/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/hhz520/webchat/resolve/main/plugins/linkai/utils.py
1.02 kB
| from config import global_config | |
| from bridge.reply import Reply, ReplyType | |
| from plugins.event import EventContext, EventAction | |
| class Util: | |
| 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"] | |
| 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 | |