diff --git a/src/nonebot_plugin_pixivbot/handler/command/schedule.py b/src/nonebot_plugin_pixivbot/handler/command/schedule.py index 3d4df08..2368c08 100644 --- a/src/nonebot_plugin_pixivbot/handler/command/schedule.py +++ b/src/nonebot_plugin_pixivbot/handler/command/schedule.py @@ -83,7 +83,13 @@ async def parse_args(self, args: Sequence[str]) -> dict: # noinspection PyMethodOverriding async def actual_handle(self, *, code: str): - if await scheduler.remove_task(self.post_dest, code): + if code != "all": + ok = await scheduler.remove_task(self.post_dest, code) + else: + await scheduler.remove_all_by_subscriber(self.post_dest) + ok = True + + if ok: await self.post_plain_text(message="取消订阅成功") else: raise BadRequestError("取消订阅失败,不存在该订阅") diff --git a/src/nonebot_plugin_pixivbot/handler/command/watch.py b/src/nonebot_plugin_pixivbot/handler/command/watch.py index 1e3b088..ba318ac 100644 --- a/src/nonebot_plugin_pixivbot/handler/command/watch.py +++ b/src/nonebot_plugin_pixivbot/handler/command/watch.py @@ -142,7 +142,13 @@ async def parse_args(self, args: Sequence[str]) -> dict: # noinspection PyMethodOverriding async def actual_handle(self, *, code: str): - if await watchman.remove_task(self.post_dest, code): + if code != "all": + ok = await watchman.remove_task(self.post_dest, code) + else: + await watchman.remove_all_by_subscriber(self.post_dest) + ok = True + + if ok: await self.post_plain_text(message="取消订阅成功") else: raise BadRequestError("取消订阅失败,不存在该订阅") diff --git a/src/nonebot_plugin_pixivbot/service/interval_task_worker.py b/src/nonebot_plugin_pixivbot/service/interval_task_worker.py index bc6c358..8fa2999 100644 --- a/src/nonebot_plugin_pixivbot/service/interval_task_worker.py +++ b/src/nonebot_plugin_pixivbot/service/interval_task_worker.py @@ -74,7 +74,7 @@ async def _on_trigger(self, item: T): if not available: logger.info(f"[{self.tag}] {post_dest} is no longer available, removing all his tasks...") - await self.unschedule_all_by_subscriber(post_dest) + await self.remove_all_by_subscriber(post_dest) @abstractmethod def _make_job_trigger(self, item: T) -> BaseTrigger: @@ -122,7 +122,7 @@ async def remove_task(self, post_dest: PostDestination[T_UID, T_GID], code: str) else: return False - async def unschedule_all_by_subscriber(self, post_dest: PostDestination[T_UID, T_GID]): + async def remove_all_by_subscriber(self, post_dest: PostDestination[T_UID, T_GID]): old = await self.repo.delete_many_by_subscriber(get_bot_user_identifier(post_dest.bot), post_dest.identifier) for item in old: