feat(event): add options to ResourceDownloadEventData

This commit is contained in:
InfinityPacer
2024-12-06 10:47:56 +08:00
parent c030166cf5
commit 233d62479f
2 changed files with 10 additions and 14 deletions
+7 -5
View File
@@ -229,12 +229,14 @@ class DownloadChain(ChainBase):
context=context, context=context,
episodes=episodes, episodes=episodes,
channel=channel, channel=channel,
source=source, origin=source,
downloader=downloader, downloader=downloader,
save_path=save_path, options={
userid=userid, "save_path": save_path,
username=username, "userid": userid,
media_category=media_category "username": username,
"media_category": media_category
}
) )
# 触发资源下载事件 # 触发资源下载事件
event = eventmanager.send_event(ChainEventType.ResourceDownload, event_data) event = eventmanager.send_event(ChainEventType.ResourceDownload, event_data)
+3 -9
View File
@@ -1,5 +1,5 @@
from pathlib import Path from pathlib import Path
from typing import Optional, Dict, Any, List, Set, Union from typing import Optional, Dict, Any, List, Set
from pydantic import BaseModel, Field, root_validator from pydantic import BaseModel, Field, root_validator
@@ -183,10 +183,7 @@ class ResourceDownloadEventData(ChainEventData):
channel (MessageChannel): 通知渠道 channel (MessageChannel): 通知渠道
origin (str): 来源(消息通知、Subscribe、Manual等) origin (str): 来源(消息通知、Subscribe、Manual等)
downloader (str): 下载器 downloader (str): 下载器
save_path (str): 保存路径 options (dict): 其他参数
userid (Union[str, int]): 用户ID
username (str): 调用下载的用户名/插件名
media_category (str): 自定义媒体类别
# 输出参数 # 输出参数
cancel (bool): 是否取消下载,默认值为 False cancel (bool): 是否取消下载,默认值为 False
@@ -199,10 +196,7 @@ class ResourceDownloadEventData(ChainEventData):
channel: Optional[MessageChannel] = Field(None, description="通知渠道") channel: Optional[MessageChannel] = Field(None, description="通知渠道")
origin: Optional[str] = Field(None, description="来源") origin: Optional[str] = Field(None, description="来源")
downloader: Optional[str] = Field(None, description="下载器") downloader: Optional[str] = Field(None, description="下载器")
save_path: Optional[str] = Field(None, description="保存路径") options: Optional[dict] = Field(None, description="其他参数")
userid: Optional[Union[str, int]] = Field(None, description="用户ID")
username: Optional[str] = Field(None, description="调用下载的用户名/插件名")
media_category: Optional[str] = Field(None, description="自定义媒体类别")
# 输出参数 # 输出参数
cancel: bool = Field(False, description="是否取消下载") cancel: bool = Field(False, description="是否取消下载")