mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
fix message cache
This commit is contained in:
+6
-11
@@ -133,10 +133,10 @@ class MessageChain(ChainBase):
|
|||||||
"""
|
"""
|
||||||
# 申明全局变量
|
# 申明全局变量
|
||||||
global _current_page, _current_meta, _current_media
|
global _current_page, _current_meta, _current_media
|
||||||
# 加载缓存
|
|
||||||
user_cache: Dict[str, dict] = self.load_cache(self._cache_file) or {}
|
|
||||||
# 处理消息
|
# 处理消息
|
||||||
logger.info(f'收到用户消息内容,用户:{userid},内容:{text}')
|
logger.info(f'收到用户消息内容,用户:{userid},内容:{text}')
|
||||||
|
# 加载缓存
|
||||||
|
user_cache: Dict[str, dict] = self.load_cache(self._cache_file) or {}
|
||||||
# 保存消息
|
# 保存消息
|
||||||
if not text.startswith('CALLBACK:'):
|
if not text.startswith('CALLBACK:'):
|
||||||
self.messagehelper.put(
|
self.messagehelper.put(
|
||||||
@@ -272,6 +272,8 @@ class MessageChain(ChainBase):
|
|||||||
"type": "Torrent",
|
"type": "Torrent",
|
||||||
"items": contexts
|
"items": contexts
|
||||||
}
|
}
|
||||||
|
# 保存缓存
|
||||||
|
self.save_cache(user_cache, self._cache_file)
|
||||||
# 发送种子数据
|
# 发送种子数据
|
||||||
logger.info(f"搜索到 {len(contexts)} 条数据,开始发送选择消息 ...")
|
logger.info(f"搜索到 {len(contexts)} 条数据,开始发送选择消息 ...")
|
||||||
self.__post_torrents_message(channel=channel,
|
self.__post_torrents_message(channel=channel,
|
||||||
@@ -467,10 +469,12 @@ class MessageChain(ChainBase):
|
|||||||
logger.info(f"搜索到 {len(medias)} 条相关媒体信息")
|
logger.info(f"搜索到 {len(medias)} 条相关媒体信息")
|
||||||
# 记录当前状态
|
# 记录当前状态
|
||||||
_current_meta = meta
|
_current_meta = meta
|
||||||
|
# 保存缓存
|
||||||
user_cache[userid] = {
|
user_cache[userid] = {
|
||||||
'type': action,
|
'type': action,
|
||||||
'items': medias
|
'items': medias
|
||||||
}
|
}
|
||||||
|
self.save_cache(user_cache, self._cache_file)
|
||||||
_current_page = 0
|
_current_page = 0
|
||||||
_current_media = None
|
_current_media = None
|
||||||
# 发送媒体列表
|
# 发送媒体列表
|
||||||
@@ -493,15 +497,6 @@ class MessageChain(ChainBase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# 保存缓存
|
|
||||||
self.save_cache(user_cache, self._cache_file)
|
|
||||||
|
|
||||||
# 清理内存
|
|
||||||
user_cache.clear()
|
|
||||||
del user_cache
|
|
||||||
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def _handle_callback(self, text: str, channel: MessageChannel, source: str,
|
def _handle_callback(self, text: str, channel: MessageChannel, source: str,
|
||||||
userid: Union[str, int], username: str,
|
userid: Union[str, int], username: str,
|
||||||
original_message_id: Optional[Union[str, int]] = None,
|
original_message_id: Optional[Union[str, int]] = None,
|
||||||
|
|||||||
Reference in New Issue
Block a user