Merge branch 'dev' of https://github.com/UnCLAS-Prommer/MaiMBot into dev
This commit is contained in:
@@ -178,7 +178,6 @@ MaiCore是一个开源项目,我们非常欢迎你的参与。你的贡献,
|
|||||||
|
|
||||||
## 致谢
|
## 致谢
|
||||||
|
|
||||||
- [nonebot2](https://github.com/nonebot/nonebot2): 跨平台 Python 异步聊天机器人框架
|
|
||||||
- [NapCat](https://github.com/NapNeko/NapCatQQ): 现代化的基于 NTQQ 的 Bot 协议端实现
|
- [NapCat](https://github.com/NapNeko/NapCatQQ): 现代化的基于 NTQQ 的 Bot 协议端实现
|
||||||
|
|
||||||
### 贡献者
|
### 贡献者
|
||||||
|
|||||||
@@ -421,14 +421,14 @@ class ChatObserver:
|
|||||||
logger.error(f"更新消息历史时出错: {str(e)}")
|
logger.error(f"更新消息历史时出错: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_message_history(self, limit: int = 50) -> List[Dict[str, Any]]:
|
def get_cached_messages(self, limit: int = 50) -> List[Dict[str, Any]]:
|
||||||
"""获取消息历史
|
"""获取缓存的消息历史
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
limit: 获取的最大消息数量
|
limit: 获取的最大消息数量,默认50
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List[Dict[str, Any]]: 消息历史列表
|
List[Dict[str, Any]]: 缓存的消息历史列表
|
||||||
"""
|
"""
|
||||||
return self.message_cache[:limit]
|
return self.message_cache[:limit]
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class Conversation:
|
|||||||
async def _send_timeout_message(self):
|
async def _send_timeout_message(self):
|
||||||
"""发送超时结束消息"""
|
"""发送超时结束消息"""
|
||||||
try:
|
try:
|
||||||
messages = self.chat_observer.get_message_history(limit=1)
|
messages = self.chat_observer.get_cached_messages(limit=1)
|
||||||
if not messages:
|
if not messages:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ class Conversation:
|
|||||||
logger.warning("没有生成回复")
|
logger.warning("没有生成回复")
|
||||||
return
|
return
|
||||||
|
|
||||||
messages = self.chat_observer.get_message_history(limit=1)
|
messages = self.chat_observer.get_cached_messages(limit=1)
|
||||||
if not messages:
|
if not messages:
|
||||||
logger.warning("没有最近的消息可以回复")
|
logger.warning("没有最近的消息可以回复")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class GoalAnalyzer:
|
|||||||
return self.goals[1:].copy()
|
return self.goals[1:].copy()
|
||||||
|
|
||||||
async def analyze_conversation(self, goal, reasoning):
|
async def analyze_conversation(self, goal, reasoning):
|
||||||
messages = self.chat_observer.get_message_history()
|
messages = self.chat_observer.get_cached_messages()
|
||||||
chat_history_text = ""
|
chat_history_text = ""
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S")
|
time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S")
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ReplyChecker:
|
|||||||
Tuple[bool, str, bool]: (是否合适, 原因, 是否需要重新规划)
|
Tuple[bool, str, bool]: (是否合适, 原因, 是否需要重新规划)
|
||||||
"""
|
"""
|
||||||
# 获取最新的消息记录
|
# 获取最新的消息记录
|
||||||
messages = self.chat_observer.get_message_history(limit=5)
|
messages = self.chat_observer.get_cached_messages(limit=5)
|
||||||
chat_history_text = ""
|
chat_history_text = ""
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S")
|
time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S")
|
||||||
|
|||||||
Reference in New Issue
Block a user