mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix actions
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import copy
|
||||
|
||||
from app.actions import BaseAction
|
||||
from app.schemas import ActionParams, ActionContext
|
||||
from core.event import eventmanager
|
||||
|
||||
|
||||
class SendEventParams(ActionParams):
|
||||
@@ -14,6 +17,8 @@ class SendEventAction(BaseAction):
|
||||
发送事件
|
||||
"""
|
||||
|
||||
__success = False
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "发送事件"
|
||||
@@ -24,7 +29,19 @@ class SendEventAction(BaseAction):
|
||||
|
||||
@property
|
||||
def success(self) -> bool:
|
||||
return True
|
||||
return self.__success
|
||||
|
||||
async def execute(self, params: SendEventParams, context: ActionContext) -> ActionContext:
|
||||
pass
|
||||
"""
|
||||
发送events中的事件
|
||||
"""
|
||||
if context.events:
|
||||
# 按优先级排序,优先级高的先发送
|
||||
context.events.sort(key=lambda x: x.priority, reverse=True)
|
||||
for event in copy.deepcopy(context.events):
|
||||
eventmanager.send_event(etype=event.event_type, data=event.event_data)
|
||||
context.events.remove(event)
|
||||
self.__success = True
|
||||
|
||||
self.job_done()
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user