mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
commit
d7509f7030
@ -20,26 +20,36 @@ def init_none_plugin_count_manager():
|
|||||||
"""
|
"""
|
||||||
清除已删除插件数据
|
清除已删除插件数据
|
||||||
"""
|
"""
|
||||||
modules = [x.module for x in get_matchers()]
|
modules = [x.plugin_name for x in get_matchers()]
|
||||||
for module in none_plugin_count_manager.keys():
|
plugins_manager_list = list(plugins_manager.keys())
|
||||||
if module not in modules:
|
for module in plugins_manager_list:
|
||||||
none_plugin_count_manager.add_count(module)
|
if module not in modules or none_plugin_count_manager.check(module):
|
||||||
else:
|
|
||||||
none_plugin_count_manager.reset(module)
|
|
||||||
if none_plugin_count_manager.check(module):
|
|
||||||
try:
|
try:
|
||||||
plugin_name = plugins_manager.get(module)["plugin_name"]
|
plugin_name = plugins_manager.get(module)["plugin_name"]
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
plugin_name = ""
|
plugin_name = ""
|
||||||
try:
|
if none_plugin_count_manager.check(module):
|
||||||
plugins2settings_manager.delete(module)
|
try:
|
||||||
plugins2count_manager.delete(module)
|
plugins2settings_manager.delete(module)
|
||||||
plugins2cd_manager.delete(module)
|
plugins2settings_manager.save()
|
||||||
plugins2block_manager.delete(module)
|
plugins2count_manager.delete(module)
|
||||||
plugins_manager.delete(module)
|
plugins2count_manager.save()
|
||||||
resources_manager.remove_resource(module)
|
plugins2cd_manager.delete(module)
|
||||||
logger.info(f"{module}:{plugin_name} 插件疑似已删除,清除对应插件数据...")
|
plugins2cd_manager.save()
|
||||||
except Exception as e:
|
plugins2block_manager.delete(module)
|
||||||
logger.error(
|
plugins2block_manager.save()
|
||||||
f"{module}:{plugin_name} 插件疑似已删除,清除对应插件数据失败...{type(e)}:{e}"
|
plugins_manager.delete(module)
|
||||||
)
|
plugins_manager.save()
|
||||||
|
resources_manager.remove_resource(module)
|
||||||
|
none_plugin_count_manager.delete(module)
|
||||||
|
logger.info(f"{module}:{plugin_name} 插件疑似已删除,清除对应插件数据...")
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(
|
||||||
|
f"{module}:{plugin_name} 插件疑似已删除,清除对应插件数据失败...{type(e)}:{e}")
|
||||||
|
else:
|
||||||
|
none_plugin_count_manager.add_count(module)
|
||||||
|
logger.info(
|
||||||
|
f"{module}:{plugin_name} 插件疑似已删除,加载{none_plugin_count_manager._max_count}次失败后将清除对应插件数据,当前次数:{none_plugin_count_manager._data[module]}")
|
||||||
|
else:
|
||||||
|
none_plugin_count_manager.reset(module)
|
||||||
|
none_plugin_count_manager.save()
|
||||||
|
|||||||
@ -4,7 +4,6 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
class NonePluginCountManager(StaticData):
|
class NonePluginCountManager(StaticData):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
插件加载容忍管理器,当连续 max_count 次插件加载,视为删除插件,清楚数据
|
插件加载容忍管理器,当连续 max_count 次插件加载,视为删除插件,清楚数据
|
||||||
"""
|
"""
|
||||||
@ -15,6 +14,8 @@ class NonePluginCountManager(StaticData):
|
|||||||
:param max_count: 容忍最大次数
|
:param max_count: 容忍最大次数
|
||||||
"""
|
"""
|
||||||
super().__init__(file)
|
super().__init__(file)
|
||||||
|
if not self._data:
|
||||||
|
self._data = {}
|
||||||
self._max_count = max_count
|
self._max_count = max_count
|
||||||
|
|
||||||
def add_count(self, module: str, count: int = 1):
|
def add_count(self, module: str, count: int = 1):
|
||||||
@ -42,10 +43,5 @@ class NonePluginCountManager(StaticData):
|
|||||||
:param module: 模块
|
:param module: 模块
|
||||||
"""
|
"""
|
||||||
if module in self._data.keys():
|
if module in self._data.keys():
|
||||||
return self._data.keys() > self._max_count
|
return self._data[module] >= self._max_count
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user