fix actions

This commit is contained in:
jxxghp
2025-02-22 09:57:32 +08:00
parent b84896b4f9
commit 0b3138fec6
10 changed files with 252 additions and 12 deletions
+19 -2
View File
@@ -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