ruff fix但指定了--unsafe-fixes
This commit is contained in:
committed by
Windpicker-owo
parent
04feb585b4
commit
2a89efe47a
@@ -234,7 +234,7 @@ class AffinityInterestCalculator(BaseInterestCalculator):
|
||||
return 0.8 # 提及机器人名字,高分
|
||||
else:
|
||||
# 检查是否被提及(文本匹配)
|
||||
bot_aliases = [bot_nickname] + global_config.bot.alias_names
|
||||
bot_aliases = [bot_nickname, *global_config.bot.alias_names]
|
||||
is_text_mentioned = any(alias in processed_plain_text for alias in bot_aliases if alias)
|
||||
|
||||
# 如果被提及或是私聊,都视为提及了bot
|
||||
|
||||
@@ -97,7 +97,7 @@ class ChatterInterestScoringSystem:
|
||||
details=details,
|
||||
)
|
||||
|
||||
async def _calculate_interest_match_score(self, content: str, keywords: list[str] = None) -> float:
|
||||
async def _calculate_interest_match_score(self, content: str, keywords: list[str] | None = None) -> float:
|
||||
"""计算兴趣匹配度 - 使用智能embedding匹配"""
|
||||
if not content:
|
||||
return 0.0
|
||||
@@ -109,7 +109,7 @@ class ChatterInterestScoringSystem:
|
||||
# 智能匹配未初始化,返回默认分数
|
||||
return 0.3
|
||||
|
||||
async def _calculate_smart_interest_match(self, content: str, keywords: list[str] = None) -> float:
|
||||
async def _calculate_smart_interest_match(self, content: str, keywords: list[str] | None = None) -> float:
|
||||
"""使用embedding计算智能兴趣匹配"""
|
||||
try:
|
||||
# 如果没有传入关键词,则提取
|
||||
@@ -228,7 +228,7 @@ class ChatterInterestScoringSystem:
|
||||
return 0.0
|
||||
|
||||
# 检查是否被提及
|
||||
bot_aliases = [bot_nickname] + global_config.bot.alias_names
|
||||
bot_aliases = [bot_nickname, *global_config.bot.alias_names]
|
||||
is_mentioned = msg.is_mentioned or any(alias in msg.processed_plain_text for alias in bot_aliases if alias)
|
||||
|
||||
# 如果被提及或是私聊,都视为提及了bot
|
||||
|
||||
@@ -369,7 +369,7 @@ class ChatterPlanFilter:
|
||||
flattened_unread = [msg.flatten() for msg in unread_messages]
|
||||
|
||||
# 尝试获取兴趣度评分(返回以真实 message_id 为键的字典)
|
||||
interest_scores = await self._get_interest_scores_for_messages(flattened_unread)
|
||||
await self._get_interest_scores_for_messages(flattened_unread)
|
||||
|
||||
# 为未读消息分配短 id(保持与 build_readable_messages_with_id 的一致结构)
|
||||
message_id_list = assign_message_ids(flattened_unread)
|
||||
@@ -378,7 +378,7 @@ class ChatterPlanFilter:
|
||||
for idx, msg in enumerate(flattened_unread):
|
||||
mapped = message_id_list[idx]
|
||||
synthetic_id = mapped.get("id")
|
||||
original_msg_id = msg.get("message_id") or msg.get("id")
|
||||
msg.get("message_id") or msg.get("id")
|
||||
msg_time = time.strftime("%H:%M:%S", time.localtime(msg.get("time", time.time())))
|
||||
user_nickname = msg.get("user_nickname", "未知用户")
|
||||
msg_content = msg.get("processed_plain_text", "")
|
||||
|
||||
@@ -105,7 +105,6 @@ class ChatterActionPlanner:
|
||||
reply_not_available = True
|
||||
interest_updates: list[dict[str, Any]] = []
|
||||
aggregate_should_act = False
|
||||
aggregate_should_reply = False
|
||||
|
||||
if unread_messages:
|
||||
# 直接使用消息中已计算的标志,无需重复计算兴趣值
|
||||
@@ -126,7 +125,6 @@ class ChatterActionPlanner:
|
||||
)
|
||||
|
||||
if message_should_reply:
|
||||
aggregate_should_reply = True
|
||||
aggregate_should_act = True
|
||||
reply_not_available = False
|
||||
break
|
||||
|
||||
@@ -242,7 +242,7 @@ class ChatterRelationshipTracker:
|
||||
"last_update_time": self.last_update_time,
|
||||
}
|
||||
|
||||
def update_config(self, max_tracking_users: int = None, update_interval_minutes: int = None):
|
||||
def update_config(self, max_tracking_users: int | None = None, update_interval_minutes: int | None = None):
|
||||
"""更新配置"""
|
||||
if max_tracking_users is not None:
|
||||
self.max_tracking_users = max_tracking_users
|
||||
|
||||
@@ -41,7 +41,7 @@ class EmojiAction(BaseAction):
|
||||
2. 这是一个适合表达情绪的场合
|
||||
3. 发表情包能使当前对话更有趣
|
||||
4. 不要发送太多表情包,如果你已经发送过多个表情包则回答"否"
|
||||
|
||||
|
||||
请回答"是"或"否"。
|
||||
"""
|
||||
|
||||
@@ -138,7 +138,7 @@ class EmojiAction(BaseAction):
|
||||
你是一个正在进行聊天的网友,你需要根据一个理由和最近的聊天记录,从一个情感标签列表中选择最匹配的一个。
|
||||
这是最近的聊天记录:
|
||||
{messages_text}
|
||||
|
||||
|
||||
这是理由:“{reason}”
|
||||
这里是可用的情感标签:{available_emotions}
|
||||
请直接返回最匹配的那个情感标签,不要进行任何解释或添加其他多余的文字。
|
||||
@@ -202,7 +202,7 @@ class EmojiAction(BaseAction):
|
||||
你是一个正在进行聊天的网友,你需要根据一个理由和最近的聊天记录,从一个表情包描述列表中选择最匹配的一个。
|
||||
这是最近的聊天记录:
|
||||
{messages_text}
|
||||
|
||||
|
||||
这是理由:“{reason}”
|
||||
这里是可用的表情包描述:{emoji_descriptions}
|
||||
请直接返回最匹配的那个表情包描述,不要进行任何解释或添加其他多余的文字。
|
||||
|
||||
@@ -72,7 +72,7 @@ class ContentService:
|
||||
prompt = f"""
|
||||
你是'{bot_personality}',现在是{current_time}({weekday}),你想写一条{prompt_topic}的说说发表在qq空间上。
|
||||
{bot_expression}
|
||||
|
||||
|
||||
请严格遵守以下规则:
|
||||
1. **绝对禁止**在说说中直接、完整地提及当前的年月日或几点几分。
|
||||
2. 你应该将当前时间作为创作的背景,用它来判断现在是“清晨”、“傍晚”还是“深夜”。
|
||||
@@ -318,7 +318,7 @@ class ContentService:
|
||||
7. **严禁重复**:下方会提供你最近发过的说说历史,你必须创作一条全新的、与历史记录内容和主题都不同的说说。
|
||||
8. 不要刻意突出自身学科背景,不要浮夸,不要夸张修辞。
|
||||
9. 只输出一条说说正文的内容,不要有其他的任何正文以外的冗余输出。
|
||||
|
||||
|
||||
注意:
|
||||
- 如果活动是学习相关的,可以分享学习心得或感受
|
||||
- 如果活动是休息相关的,可以分享放松的感受
|
||||
|
||||
@@ -204,7 +204,7 @@ class QZoneService:
|
||||
|
||||
# 1. 将评论分为用户评论和自己的回复
|
||||
user_comments = [c for c in comments if str(c.get("qq_account")) != str(qq_account)]
|
||||
my_replies = [c for c in comments if str(c.get("qq_account")) == str(qq_account)]
|
||||
[c for c in comments if str(c.get("qq_account")) == str(qq_account)]
|
||||
|
||||
if not user_comments:
|
||||
return
|
||||
|
||||
@@ -51,10 +51,10 @@ class ReplyTrackerService:
|
||||
return False
|
||||
for comment_id, timestamp in comments.items():
|
||||
# 确保comment_id是字符串格式,如果是数字则转换为字符串
|
||||
if not isinstance(comment_id, (str, int)):
|
||||
if not isinstance(comment_id, str | int):
|
||||
logger.error(f"无效的评论ID格式: {comment_id}")
|
||||
return False
|
||||
if not isinstance(timestamp, (int, float)):
|
||||
if not isinstance(timestamp, int | float):
|
||||
logger.error(f"无效的时间戳格式: {timestamp}")
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -29,7 +29,7 @@ message_queue = asyncio.Queue()
|
||||
|
||||
def get_classes_in_module(module):
|
||||
classes = []
|
||||
for name, member in inspect.getmembers(module):
|
||||
for _name, member in inspect.getmembers(module):
|
||||
if inspect.isclass(member):
|
||||
classes.append(member)
|
||||
return classes
|
||||
|
||||
@@ -171,7 +171,6 @@ class SendHandler:
|
||||
处理适配器命令类 - 用于直接向Napcat发送命令并返回结果
|
||||
"""
|
||||
logger.info("处理适配器命令中")
|
||||
message_info: BaseMessageInfo = raw_message_base.message_info
|
||||
message_segment: Seg = raw_message_base.message_segment
|
||||
seg_data: Dict[str, Any] = message_segment.data if isinstance(message_segment.data, dict) else {}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class ManagementCommand(PlusCommand):
|
||||
|
||||
⚙️ 插件控制:
|
||||
• `/pm plugin load <插件名>` - 加载指定插件
|
||||
• `/pm plugin unload <插件名>` - 卸载指定插件
|
||||
• `/pm plugin unload <插件名>` - 卸载指定插件
|
||||
• `/pm plugin reload <插件名>` - 重新加载指定插件
|
||||
• `/pm plugin force_reload <插件名>` - 强制重载指定插件(深度清理)
|
||||
• `/pm plugin add_dir <目录路径>` - 添加插件目录
|
||||
|
||||
Reference in New Issue
Block a user