diff --git a/ntfy/bot.py b/ntfy/bot.py index a019b02..918b9ab 100644 --- a/ntfy/bot.py +++ b/ntfy/bot.py @@ -101,15 +101,14 @@ class NtfyBot(Plugin): task = self.tasks.get(topic_id) if task and not task.done(): self.log.debug("Cancelling subscription task for topic %d", - async def can_use_command(self, evt: MessageEvent) -> bool: - if evt.sender in self.config["admins"]: - return True - levels = await self.client.get_state_event(evt.room_id, EventType.ROOM_POWER_LEVELS) - user_level = levels.get_user_level(evt.sender) - if user_level < 50: - await evt.reply("You don't have the permission to manage ntfy subscriptions in this room.") - return False - return True + topic_id) + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + except Exception as exc: + self.log.exception("Subscription task errored", exc_info=exc) @command.new(name=lambda self: self.config["command_prefix"], help="Manage ntfy subscriptions.", require_subcommand=True)