ruff
This commit is contained in:
@@ -8,10 +8,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["主动思考","自己发消息"],
|
||||
keywords=["主动思考", "自己发消息"],
|
||||
categories=["Chat", "Integration"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
extra={"is_built_in": True, "plugin_type": "functional"},
|
||||
)
|
||||
|
||||
@@ -63,7 +63,9 @@ class ColdStartTask(AsyncTask):
|
||||
logger.info(f"【冷启动】发现全新用户 {chat_id},准备发起第一次问候。")
|
||||
elif stream.last_active_time < self.bot_start_time:
|
||||
should_wake_up = True
|
||||
logger.info(f"【冷启动】发现沉睡的聊天流 {chat_id} (最后活跃于 {datetime.fromtimestamp(stream.last_active_time)}),准备唤醒。")
|
||||
logger.info(
|
||||
f"【冷启动】发现沉睡的聊天流 {chat_id} (最后活跃于 {datetime.fromtimestamp(stream.last_active_time)}),准备唤醒。"
|
||||
)
|
||||
|
||||
if should_wake_up:
|
||||
person_id = person_api.get_person_id(platform, user_id)
|
||||
@@ -166,7 +168,9 @@ class ProactiveThinkingTask(AsyncTask):
|
||||
continue
|
||||
|
||||
# 检查冷却时间
|
||||
recent_messages = await message_api.get_recent_messages(chat_id=stream.stream_id, limit=1,limit_mode="latest")
|
||||
recent_messages = await message_api.get_recent_messages(
|
||||
chat_id=stream.stream_id, limit=1, limit_mode="latest"
|
||||
)
|
||||
last_message_time = recent_messages[0]["time"] if recent_messages else stream.create_time
|
||||
time_since_last_active = time.time() - last_message_time
|
||||
if time_since_last_active > next_interval:
|
||||
@@ -209,7 +213,7 @@ class ProactiveThinkingTask(AsyncTask):
|
||||
logger.info("日常唤醒任务被正常取消。")
|
||||
break
|
||||
except Exception as e:
|
||||
traceback.print_exc() # 打印完整的堆栈跟踪
|
||||
traceback.print_exc() # 打印完整的堆栈跟踪
|
||||
logger.error(f"【日常唤醒】任务出现错误,将在60秒后重试: {e}", exc_info=True)
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
@@ -143,14 +143,16 @@ class ProactiveThinkerExecutor:
|
||||
else "今天没有日程安排。"
|
||||
)
|
||||
|
||||
recent_messages = await message_api.get_recent_messages(stream.stream_id,limit=50,limit_mode="latest",hours=12)
|
||||
recent_messages = await message_api.get_recent_messages(
|
||||
stream.stream_id, limit=50, limit_mode="latest", hours=12
|
||||
)
|
||||
recent_chat_history = (
|
||||
await message_api.build_readable_messages_to_str(recent_messages) if recent_messages else "无"
|
||||
)
|
||||
|
||||
action_history_list = await get_actions_by_timestamp_with_chat(
|
||||
chat_id=stream.stream_id,
|
||||
timestamp_start=time.time() - 3600 * 24, #过去24小时
|
||||
timestamp_start=time.time() - 3600 * 24, # 过去24小时
|
||||
timestamp_end=time.time(),
|
||||
limit=7,
|
||||
)
|
||||
@@ -195,11 +197,9 @@ class ProactiveThinkerExecutor:
|
||||
person_id = person_api.get_person_id(user_info.platform, int(user_info.user_id))
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_info = await person_info_manager.get_values(person_id, ["user_id", "platform", "person_name"])
|
||||
cross_context_block = await Prompt.build_cross_context(
|
||||
stream.stream_id, "s4u", person_info
|
||||
)
|
||||
cross_context_block = await Prompt.build_cross_context(stream.stream_id, "s4u", person_info)
|
||||
|
||||
# 获取关系信息
|
||||
# 获取关系信息
|
||||
short_impression = await person_info_manager.get_value(person_id, "short_impression") or "无"
|
||||
impression = await person_info_manager.get_value(person_id, "impression") or "无"
|
||||
attitude = await person_info_manager.get_value(person_id, "attitude") or 50
|
||||
|
||||
Reference in New Issue
Block a user