1
This commit is contained in:
@@ -119,12 +119,10 @@ class ContentService:
|
|||||||
logger.error(f"生成说说内容时发生异常: {e}")
|
logger.error(f"生成说说内容时发生异常: {e}")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
async def generate_comment(self, content: str, target_name: str, rt_con: str = "", images=None) -> str:
|
async def generate_comment(self, content: str, target_name: str, rt_con: str = "", images: list = []) -> str:
|
||||||
"""
|
"""
|
||||||
针对一条具体的说说内容生成评论。
|
针对一条具体的说说内容生成评论。
|
||||||
"""
|
"""
|
||||||
if images is None:
|
|
||||||
images = []
|
|
||||||
for i in range(3): # 重试3次
|
for i in range(3): # 重试3次
|
||||||
try:
|
try:
|
||||||
chat_manager = get_chat_manager()
|
chat_manager = get_chat_manager()
|
||||||
@@ -182,8 +180,7 @@ class ContentService:
|
|||||||
return ""
|
return ""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@staticmethod
|
async def generate_comment_reply(self, story_content: str, comment_content: str, commenter_name: str) -> str:
|
||||||
async def generate_comment_reply(story_content: str, comment_content: str, commenter_name: str) -> str:
|
|
||||||
"""
|
"""
|
||||||
针对自己说说的评论,生成回复。
|
针对自己说说的评论,生成回复。
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ class CookieService:
|
|||||||
logger.error(f"无法读取或解析Cookie文件 {cookie_file_path}: {e}")
|
logger.error(f"无法读取或解析Cookie文件 {cookie_file_path}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
async def _get_cookies_from_adapter(self, stream_id: Optional[str]) -> Optional[Dict[str, str]]:
|
||||||
async def _get_cookies_from_adapter(stream_id: Optional[str]) -> Optional[Dict[str, str]]:
|
|
||||||
"""通过Adapter API获取Cookie"""
|
"""通过Adapter API获取Cookie"""
|
||||||
try:
|
try:
|
||||||
params = {"domain": "user.qzone.qq.com"}
|
params = {"domain": "user.qzone.qq.com"}
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ class ImageService:
|
|||||||
logger.error(f"处理AI配图时发生异常: {e}")
|
logger.error(f"处理AI配图时发生异常: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
async def _call_siliconflow_api(self, api_key: str, story: str, image_dir: str, batch_size: int) -> bool:
|
||||||
async def _call_siliconflow_api(api_key: str, story: str, image_dir: str, batch_size: int) -> bool:
|
|
||||||
"""
|
"""
|
||||||
调用硅基流动(SiliconFlow)的API来生成图片。
|
调用硅基流动(SiliconFlow)的API来生成图片。
|
||||||
|
|
||||||
|
|||||||
@@ -187,8 +187,7 @@ class QZoneService:
|
|||||||
|
|
||||||
# --- Internal Helper Methods ---
|
# --- Internal Helper Methods ---
|
||||||
|
|
||||||
@staticmethod
|
async def _get_intercom_context(self, stream_id: str) -> Optional[str]:
|
||||||
async def _get_intercom_context(stream_id: str) -> Optional[str]:
|
|
||||||
"""
|
"""
|
||||||
根据 stream_id 查找其所属的互通组,并构建该组的聊天上下文。
|
根据 stream_id 查找其所属的互通组,并构建该组的聊天上下文。
|
||||||
|
|
||||||
@@ -399,8 +398,7 @@ class QZoneService:
|
|||||||
logger.error(f"加载本地图片失败: {e}")
|
logger.error(f"加载本地图片失败: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def _generate_gtk(self, skey: str) -> str:
|
||||||
def _generate_gtk(skey: str) -> str:
|
|
||||||
hash_val = 5381
|
hash_val = 5381
|
||||||
for char in skey:
|
for char in skey:
|
||||||
hash_val += (hash_val << 5) + ord(char)
|
hash_val += (hash_val << 5) + ord(char)
|
||||||
@@ -437,8 +435,7 @@ class QZoneService:
|
|||||||
logger.error(f"更新或加载Cookie时发生异常: {e}")
|
logger.error(f"更新或加载Cookie时发生异常: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
async def _fetch_cookies_http(self, host: str, port: str, napcat_token: str) -> Optional[Dict]:
|
||||||
async def _fetch_cookies_http(host: str, port: str, napcat_token: str) -> Optional[Dict]:
|
|
||||||
"""通过HTTP服务器获取Cookie"""
|
"""通过HTTP服务器获取Cookie"""
|
||||||
url = f"http://{host}:{port}/get_cookies"
|
url = f"http://{host}:{port}/get_cookies"
|
||||||
max_retries = 5
|
max_retries = 5
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ class ReplyTrackerService:
|
|||||||
self._load_data()
|
self._load_data()
|
||||||
logger.debug(f"ReplyTrackerService initialized with data file: {self.reply_record_file}")
|
logger.debug(f"ReplyTrackerService initialized with data file: {self.reply_record_file}")
|
||||||
|
|
||||||
@staticmethod
|
def _validate_data(self, data: Any) -> bool:
|
||||||
def _validate_data(data: Any) -> bool:
|
|
||||||
"""验证加载的数据格式是否正确"""
|
"""验证加载的数据格式是否正确"""
|
||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
logger.error("加载的数据不是字典格式")
|
logger.error("加载的数据不是字典格式")
|
||||||
|
|||||||
@@ -129,8 +129,7 @@ class SchedulerService:
|
|||||||
logger.error(f"定时任务循环中发生未知错误: {e}\n{traceback.format_exc()}")
|
logger.error(f"定时任务循环中发生未知错误: {e}\n{traceback.format_exc()}")
|
||||||
await asyncio.sleep(300) # 发生错误后,等待一段时间再重试
|
await asyncio.sleep(300) # 发生错误后,等待一段时间再重试
|
||||||
|
|
||||||
@staticmethod
|
async def _is_processed(self, hour_str: str, activity: str) -> bool:
|
||||||
async def _is_processed(hour_str: str, activity: str) -> bool:
|
|
||||||
"""
|
"""
|
||||||
检查指定的任务(某个小时的某个活动)是否已经被成功处理过。
|
检查指定的任务(某个小时的某个活动)是否已经被成功处理过。
|
||||||
|
|
||||||
@@ -153,8 +152,7 @@ class SchedulerService:
|
|||||||
logger.error(f"检查日程处理状态时发生数据库错误: {e}")
|
logger.error(f"检查日程处理状态时发生数据库错误: {e}")
|
||||||
return False # 数据库异常时,默认为未处理,允许重试
|
return False # 数据库异常时,默认为未处理,允许重试
|
||||||
|
|
||||||
@staticmethod
|
async def _mark_as_processed(self, hour_str: str, activity: str, success: bool, content: str):
|
||||||
async def _mark_as_processed(hour_str: str, activity: str, success: bool, content: str):
|
|
||||||
"""
|
"""
|
||||||
将任务的处理状态和结果写入数据库。
|
将任务的处理状态和结果写入数据库。
|
||||||
|
|
||||||
@@ -187,7 +185,7 @@ class SchedulerService:
|
|||||||
send_success=success,
|
send_success=success,
|
||||||
)
|
)
|
||||||
session.add(new_record)
|
session.add(new_record)
|
||||||
await session.commit()
|
session.commit()
|
||||||
logger.info(f"已更新日程处理状态: {hour_str} - {activity} - 成功: {success}")
|
logger.info(f"已更新日程处理状态: {hour_str} - {activity} - 成功: {success}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"更新日程处理状态时发生数据库错误: {e}")
|
logger.error(f"更新日程处理状态时发生数据库错误: {e}")
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ class _SimpleQZoneAPI:
|
|||||||
if p_skey:
|
if p_skey:
|
||||||
self.gtk2 = self._generate_gtk(p_skey)
|
self.gtk2 = self._generate_gtk(p_skey)
|
||||||
|
|
||||||
@staticmethod
|
def _generate_gtk(self, skey: str) -> str:
|
||||||
def _generate_gtk(skey: str) -> str:
|
|
||||||
hash_val = 5381
|
hash_val = 5381
|
||||||
for char in skey:
|
for char in skey:
|
||||||
hash_val += (hash_val << 5) + ord(char)
|
hash_val += (hash_val << 5) + ord(char)
|
||||||
|
|||||||
Reference in New Issue
Block a user