import logging import tomllib from wcferry import WxMsg, Wcf from robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager from xiuren.random_pic import get_xiuren_pic class Xiuren: def __init__(self, wcf: Wcf, gbm: GroupBotManager): self.LOG = logging.getLogger(__name__) self.wcf = wcf # 假设 wcf 对象在此类中初始化 self.gbm = gbm # 权限功能 with open("xiuren/config.toml", "rb") as f: plugin_config = tomllib.load(f) config = plugin_config["Xiuren"] self.enable = config["enable"] self.command = config["command"] self.LOG.info(f"[秀人] 组件初始化完成,指令: {self.command}") def handle_message(self, message: WxMsg): if not self.enable: return content = str(message.content).strip() command = content.split(" ") if command[0] not in self.command: return # 如果触发了指令,但是没有权限,则返回权限不足 if self.gbm.get_group_permission(message.roomid, Feature.PIC) == PermissionStatus.DISABLED: return pic_path = get_xiuren_pic() self.wcf.send_file(pic_path, message.roomid)