From d517e48e8cc276af72e07f3686461657a7808f1f Mon Sep 17 00:00:00 2001 From: "E. S" Date: Sat, 29 Mar 2025 01:30:54 +0300 Subject: [PATCH] fix --- idb_channel_bot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/idb_channel_bot.py b/idb_channel_bot.py index c7665d1..33fc2d1 100755 --- a/idb_channel_bot.py +++ b/idb_channel_bot.py @@ -35,6 +35,9 @@ class PostNotFound(Exception): class NoPostsLeft(Exception): pass +class PostTypeMismatch(Exception): + pass + class PostType(Enum): ARTICLE = 'article' @@ -290,9 +293,9 @@ async def do_send(type: Optional[PostType] = None, if db.is_already_published(filename): continue post = Post(filename) - if post.type == type: - break - post = None + if post.type != type: + raise PostTypeMismatch() + break if not post: raise NoPostsLeft() @@ -404,7 +407,7 @@ if __name__ == '__main__': asyncio.run(do_send(type=PostType(args.type) if args.type else None, mark_as_published=args.prod or args.mark, post_name=args.name)) - except NoPostsLeft: + except (NoPostsLeft, PostTypeMismatch): logger.warning('no unpublished posts matching the current mode criteria') break