diff --git a/music/bot_music.py b/music/bot_music.py index b569a6e..36fcf11 100644 --- a/music/bot_music.py +++ b/music/bot_music.py @@ -100,4 +100,4 @@ class BotMusic: 1 """ - self.wcf.forward_msg(message.sender, xml) + self.wcf.send_xml(message.sender, xml, 3, cover_url) diff --git a/robot.py b/robot.py index 7f9147c..43a4ed6 100644 --- a/robot.py +++ b/robot.py @@ -47,6 +47,7 @@ from message_report.process_message import process_message from message_report.write_db import write_to_db, generate_and_send_ranking from message_summary.message_summary_4o import message_summary from sehuatang.shehuatang import pdf_file_path +from xiuren.main import Xiuren from xiuren.meitu_dl import meitu_dowload_pic, meitu_dowload_pub_pic, meitu_dowload_heisi_pic from xiuren.random_pic import get_xiuren_pic, get_xiuren_heisi_pic from xiuren.xiuren_pdf import generate_pdf_from_images @@ -87,6 +88,8 @@ class Robot(Job): self.trade = PointTrade(wcf, self.gbm, self.db_pool) # 获取视频模块 self.video = BotVideo(wcf, self.gbm) + # 秀人模块 + self.xiuren = Xiuren(wcf, self.gbm) if ChatType.is_in_chat_types(chat_type): if chat_type == ChatType.TIGER_BOT.value and TigerBot.value_check(self.config.TIGERBOT): @@ -214,25 +217,6 @@ class Robot(Job): self.message_summary_robot((msg.roomid if msg.from_group() else msg.sender)) return True # 暂时只支持4K群要图 - elif q == "#图来": - if self.gbm.get_group_permission(msg.roomid, Feature.PIC) == PermissionStatus.DISABLED: - return True - else: - try: - file_path = get_xiuren_pic() - self.LOG.info(f"发送文件:{file_path}") - self.wcf.send_file(file_path, msg.roomid) - # 正则表达式匹配路径中的数字目录 - # match = re.search(r'\\(\d+)\\', file_path) - # if match: - # self.wcf.send_text( - # f"目录:[{match.group(1)}]\n输入 删除 {match.group(1)} 进行丑图排除", msg.roomid) - - except Exception as e: - self.LOG.error(f"图来发图出错:{e}") - return True - - # 暂时只支持4K群要图 elif q == "#黑丝": if self.gbm.get_group_permission(msg.roomid, Feature.PIC) == PermissionStatus.DISABLED: return True @@ -353,12 +337,18 @@ class Robot(Job): except Exception as e: self.LOG.error(f"point trade error: {e}") - # 加入积分赠与功能 + # 加入黑丝视频功能 try: self.video.get_video(message=msg) except Exception as e: self.LOG.error(f"video get_video error: {e}") + # 加入秀人图来功能 + try: + self.xiuren.handle_message(message=msg) + except Exception as e: + self.LOG.error(f"xiuren.handle_message error: {e}") + if msg.is_at(self.wxid): # 被@ self.toAt(msg) return # 处理完群聊信息,后面就不需要处理了 @@ -650,8 +640,3 @@ class Robot(Job): except Exception as e: self.LOG.error(f"xiu_ren_pdf_send error:{e}") - - -if __name__ == '__main__': - heisi_path = generate_pdf_from_images("xiuren/heisi") - print(heisi_path) diff --git a/xiuren/config.toml b/xiuren/config.toml new file mode 100644 index 0000000..8c7d7a1 --- /dev/null +++ b/xiuren/config.toml @@ -0,0 +1,3 @@ +[Xiuren] +enable = true +command = ["图来", "秀人"] \ No newline at end of file diff --git a/xiuren/main.py b/xiuren/main.py new file mode 100644 index 0000000..b996d7e --- /dev/null +++ b/xiuren/main.py @@ -0,0 +1,39 @@ +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)