Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -3,7 +3,6 @@ import heapq
|
||||
import math
|
||||
import json
|
||||
from typing import List, Optional
|
||||
|
||||
from src.common.logger import get_logger
|
||||
|
||||
logger = get_logger("normal_chat")
|
||||
@@ -26,8 +25,7 @@ class PrioritizedMessage:
|
||||
"""
|
||||
age = time.time() - self.arrival_time
|
||||
decay_factor = math.exp(-decay_rate * age)
|
||||
priority = sum(self.interest_scores) + decay_factor
|
||||
return priority
|
||||
return sum(self.interest_scores) + decay_factor
|
||||
|
||||
def __lt__(self, other: "PrioritizedMessage") -> bool:
|
||||
"""用于堆排序的比较函数,我们想要一个最大堆,所以用 >"""
|
||||
@@ -44,12 +42,12 @@ class PriorityManager:
|
||||
self.normal_queue: List[PrioritizedMessage] = [] # 普通消息队列 (最大堆)
|
||||
self.normal_queue_max_size = normal_queue_max_size
|
||||
|
||||
def add_message(self, message_data: dict, interest_score: Optional[float] = None):
|
||||
def add_message(self, message_data: dict, interest_score: float = 0):
|
||||
"""
|
||||
添加新消息到合适的队列中。
|
||||
"""
|
||||
user_id = message_data.get("user_id")
|
||||
|
||||
|
||||
priority_info_raw = message_data.get("priority_info")
|
||||
priority_info = {}
|
||||
if isinstance(priority_info_raw, str):
|
||||
|
||||
@@ -83,10 +83,10 @@ class S4UMessageProcessor:
|
||||
# 1. 消息解析与初始化
|
||||
groupinfo = message.message_info.group_info
|
||||
userinfo = message.message_info.user_info
|
||||
messageinfo = message.message_info
|
||||
message_info = message.message_info
|
||||
|
||||
chat = await get_chat_manager().get_or_create_stream(
|
||||
platform=messageinfo.platform,
|
||||
platform=message_info.platform,
|
||||
user_info=userinfo,
|
||||
group_info=groupinfo,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user