Merge pull request #127 from thsrite/main

This commit is contained in:
jxxghp 2023-08-15 19:52:23 +08:00 committed by GitHub
commit a204c45ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 18 deletions

View File

@ -4,13 +4,12 @@ from typing import Any, List, Dict, Tuple
from app.chain import ChainBase
from app.core.config import settings
from app.core.event import EventManager, eventmanager, Event
from app.core.event import EventManager
from app.db.models import Base
from app.db.plugindata_oper import PluginDataOper
from app.db.systemconfig_oper import SystemConfigOper
from app.helper.message import MessageHelper
from app.schemas import Notification, NotificationType, MessageChannel
from app.schemas.types import EventType
class PluginChian(ChainBase):
@ -183,16 +182,3 @@ class _PluginBase(metaclass=ABCMeta):
channel=channel, mtype=mtype, title=title, text=text,
image=image, link=link, userid=userid
))
@eventmanager.register(EventType.PluginReload)
def reload(self, event: Event):
"""
重新加载插件
"""
plugin_id = event.event_data.get("plugin_id")
if not plugin_id:
return
conf = self.get_config(plugin_id)
if not conf:
return
self.init_plugin(conf)

View File

@ -1,8 +1,11 @@
from typing import List, Tuple, Dict, Any
from python_hosts import Hosts, HostsEntry
from app.core.event import eventmanager
from app.log import logger
from app.plugins import _PluginBase
from app.schemas.types import EventType
from app.utils.ip import IpUtils
from app.utils.system import SystemUtils
@ -221,3 +224,15 @@ class CustomHosts(_PluginBase):
退出插件
"""
pass
@eventmanager.register(EventType.PluginReload)
def reload(self, event):
"""
响应插件重载事件
"""
plugin_id = event.event_data.get("plugin_id")
if not plugin_id:
return
if plugin_id != self.__class__.__name__:
return
return self.init_plugin(self.get_config())

View File

@ -492,7 +492,7 @@ class MediaSyncDel(_PluginBase):
try:
# 判断种子是否被删除完
self.handle_torrent(history_id=transferhis.id,
src=history.src,
src=transferhis.src,
torrent_hash=history.download_hash)
except Exception as e:
logger.error("删除种子失败,尝试删除源文件:%s" % str(e))
@ -640,7 +640,7 @@ class MediaSyncDel(_PluginBase):
try:
# 判断种子是否被删除完
self.handle_torrent(history_id=transferhis.id,
src=history.src,
src=transferhis.src,
torrent_hash=history.download_hash)
except Exception as e:
logger.error("删除种子失败,尝试删除源文件:%s" % str(e))