From 651c509111cd6cfd356253f189e53deb845a96b4 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 15 May 2025 14:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95seht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- robot.py | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 16857ce..2c961f7 100644 --- a/main.py +++ b/main.py @@ -60,7 +60,7 @@ def main(chat_type: int): robot.onEveryTime("09:30", robot.generate_and_send_ranking) # # # sehuatang - # robot.onEveryTime("15:30", robot.generate_sehuatang_pdf) + robot.onEveryTime("15:30", robot.generate_sehuatang_pdf) # # # 秀人网每天自动下载帖子 robot.onEveryTime("01:30", robot.xiu_ren_download_task) diff --git a/robot.py b/robot.py index fe22d42..ba681d6 100644 --- a/robot.py +++ b/robot.py @@ -18,6 +18,7 @@ from plugin_common.message_plugin_interface import MessagePluginInterface from plugin_common.plugin_interface import PluginStatus from plugin_common.plugin_manager import PluginManager from plugin_common.plugin_registry import PluginRegistry +from sehuatang.shehuatang import pdf_file_path from utils.revoke.message_auto_revoke import MessageAutoRevoke from utils.robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus @@ -464,6 +465,17 @@ class Robot(Job): except Exception as e: self.LOG.error(f"send_group_txt_message:{feature.description} error:{e}") + async def send_group_file_message(self, path: str, feature: Feature): + try: + receivers = self.gbm.get_group_list() + if not receivers: + return + for r in receivers: + if self.gbm.get_group_permission(r, feature) == PermissionStatus.ENABLED: + await self.ipad_bot.send_image_message(r,path) + except Exception as e: + self.LOG.error(f"send_group_file_message:{feature.description} error:{e}") + async def process_plugin_message(self, msg) -> bool: """使用插件处理消息""" # 获取所有消息处理插件 @@ -647,14 +659,14 @@ class Robot(Job): except Exception as e: self.LOG.error(f"write_to_db error:{e}") - # def generate_sehuatang_pdf(self): - # try: - # self.LOG.info("开始生成PDF,generate_sehuatang_pdf") - # path = pdf_file_path() - # # 暂时只发4K群 - # self.send_group_file_message(path, Feature.PDF_CAPABILITY) - # except Exception as e: - # self.LOG.error(f"generateSehuatangPdf error:{e}") + def generate_sehuatang_pdf(self): + try: + self.LOG.info("开始生成PDF,generate_sehuatang_pdf") + path = pdf_file_path() + # 暂时只发4K群 + self.send_group_file_message(path, Feature.PDF_CAPABILITY) + except Exception as e: + self.LOG.error(f"generateSehuatangPdf error:{e}") def xiu_ren_download_task(self): try: # 每天下载10组图,然后发一个帖子PDF