调试定时装饰器,优化代码

This commit is contained in:
liuwei
2025-03-20 15:08:04 +08:00
parent cf78facbad
commit 27220e0357
3 changed files with 89 additions and 36 deletions

View File

@@ -23,6 +23,7 @@ from base.func_claude import Claude
from configuration import Config
from constants import ChatType
from game_task.game_task_encyclopedia import game_process_message, get_group_ids, run_random_task_assignment
from job_decorators import scheduled_job
from message_storage.message_to_db import MessageStorage
from plugin_common.event_system import EventType, EventSystem
from plugin_common.message_plugin_interface import MessagePluginInterface
@@ -43,8 +44,6 @@ from xiuren.xiuren_pdf import generate_pdf_from_images
from db.connection import DBConnectionManager
from message_util import MessageUtil
# 在文件顶部导入装饰器
from job_decorators import register_scheduled_jobs
class Robot(Job):
@@ -105,8 +104,6 @@ class Robot(Job):
# 消息存档模块初始化,自动完成入库动作
self.message_storage = MessageStorage()
# 在初始化结束时注册所有被装饰的定时任务
register_scheduled_jobs(self)
if ChatType.is_in_chat_types(chat_type):
if chat_type == ChatType.TIGER_BOT.value and TigerBot.value_check(self.config.TIGERBOT):
self.chat = TigerBot(self.config.TIGERBOT)
@@ -546,3 +543,10 @@ class Robot(Job):
self.wcf.send_file(pub_path, "45317011307@chatroom")
except Exception as e:
self.LOG.error(f"xiu_ren_pdf_send error{e}")
@scheduled_job("*/1 * * * *", name="test_job")
def send_message(self):
try:
self.wcf.send_text("定时任务执行!", "filehelper")
except Exception as e:
self.LOG.error(f"send_message error{e}")