feat: complete notification and LLM operation tools
这个提交存在于:
父节点
8d1c2088c1
当前提交
9b481c3c5d
共有 3 个文件被更改,包括 57 次插入 和 3 次删除
56
main.py
56
main.py
|
|
@ -40,7 +40,7 @@ def _media_result_chain(results: list[dict[str, object]]) -> list[object]:
|
|||
"astrbot_plugin_moviepilot",
|
||||
"AstrBot MoviePilot Contributors",
|
||||
"在 AstrBot 中通过命令和 LLM 控制 MoviePilot。",
|
||||
"0.15.0",
|
||||
"0.16.0",
|
||||
)
|
||||
class MoviePilotPlugin(star.Star):
|
||||
"""MoviePilot integration entrypoint."""
|
||||
|
|
@ -516,6 +516,60 @@ class MoviePilotPlugin(star.Star):
|
|||
f"准备下载《{title}》。请回复 /mp confirm {request.code} 确认。"
|
||||
)
|
||||
|
||||
@filter.llm_tool(name="moviepilot_list_notifications")
|
||||
async def llm_list_notifications(self, event: AstrMessageEvent, count: int = 10) -> None:
|
||||
"""????? MoviePilot ???"""
|
||||
if not self.access_policy.is_allowed(event):
|
||||
return
|
||||
try:
|
||||
items = await self.notification_poller.list_recent(count=max(1, min(count, 50)))
|
||||
yield event.plain_result("\n\n".join(format_notification(item) for item in items) or "???????")
|
||||
except Exception as exc:
|
||||
yield event.plain_result(f"???????{exc}")
|
||||
|
||||
@filter.llm_tool(name="moviepilot_trigger_subscription_search")
|
||||
async def llm_trigger_subscription_search(self, event: AstrMessageEvent, subscribe_id: int) -> None:
|
||||
"""???????????"""
|
||||
if not self.access_policy.is_allowed(event):
|
||||
return
|
||||
try:
|
||||
await self.subscription_service.trigger_subscription_search(subscribe_id)
|
||||
yield event.plain_result(f"????? {subscribe_id} ???")
|
||||
except Exception as exc:
|
||||
yield event.plain_result(f"?????????{exc}")
|
||||
|
||||
@filter.llm_tool(name="moviepilot_request_unsubscribe")
|
||||
async def llm_request_unsubscribe(self, event: AstrMessageEvent, subscription_id: str) -> None:
|
||||
"""??????????????"""
|
||||
if not self.access_policy.is_allowed(event):
|
||||
return
|
||||
subscriptions = await self.subscription_service.list_subscriptions()
|
||||
matched = next((item for item in subscriptions if str(item.get("id")) == str(subscription_id)), None)
|
||||
media_id = media_id_from_subscription(matched) if matched else str(subscription_id)
|
||||
if not media_id:
|
||||
yield event.plain_result("????????")
|
||||
return
|
||||
request = self.confirmations.create(
|
||||
session_origin=event.unified_msg_origin,
|
||||
user_id=event.get_sender_id(),
|
||||
operation="unsubscribe",
|
||||
target={"media_id": media_id, "season": matched.get("season") if matched else None},
|
||||
)
|
||||
yield event.plain_result(f"?????? {subscription_id}???? /mp confirm {request.code} ???")
|
||||
|
||||
@filter.llm_tool(name="moviepilot_request_delete_download")
|
||||
async def llm_request_delete_download(self, event: AstrMessageEvent, task_id: str) -> None:
|
||||
"""????????????????"""
|
||||
if not self.access_policy.is_allowed(event):
|
||||
return
|
||||
request = self.confirmations.create(
|
||||
session_origin=event.unified_msg_origin,
|
||||
user_id=event.get_sender_id(),
|
||||
operation="delete_download",
|
||||
target={"task_id": str(task_id)},
|
||||
)
|
||||
yield event.plain_result(f"???????? {task_id}???? /mp confirm {request.code} ???")
|
||||
|
||||
async def _send_notification(self, target: str, text: str) -> None:
|
||||
await self.context.send_message(target, MessageChain().message(text))
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ name: astrbot_plugin_moviepilot
|
|||
display_name: MoviePilot 控制
|
||||
description: 在 AstrBot 中通过命令和 LLM 控制 MoviePilot。
|
||||
short_desc: 搜索影视、订阅、下载和接收 MoviePilot 通知。
|
||||
version: 0.15.0
|
||||
version: 0.16.0
|
||||
author: AstrBot MoviePilot Contributors
|
||||
repo: https://github.com/jxxghp/MoviePilot
|
||||
astrbot_version: ">=4.16,<5"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def test_metadata_contains_required_plugin_fields() -> None:
|
|||
)
|
||||
|
||||
assert metadata["name"] == "astrbot_plugin_moviepilot"
|
||||
assert metadata["version"] == "0.15.0"
|
||||
assert metadata["version"] == "0.16.0"
|
||||
assert metadata["astrbot_version"] == ">=4.16,<5"
|
||||
assert "aiocqhttp" in metadata["support_platforms"]
|
||||
assert "telegram" in metadata["support_platforms"]
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用