From 7aa828f6c6631343d610cd6288524e1bee08efd6 Mon Sep 17 00:00:00 2001 From: aigoncharov Date: Thu, 18 Jul 2024 21:46:56 +0100 Subject: [PATCH] Fix broken update --- pyproject.toml | 2 +- telegram_to_rss/poll_telegram.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0be42f9..e5aca24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "telegram-to-rss" -version = "0.2.4" +version = "0.2.5" description = "" authors = ["aigoncharov"] license = "MIT" diff --git a/telegram_to_rss/poll_telegram.py b/telegram_to_rss/poll_telegram.py index dd5385a..bffd2b0 100644 --- a/telegram_to_rss/poll_telegram.py +++ b/telegram_to_rss/poll_telegram.py @@ -69,10 +69,18 @@ async def update_feed(self, dialog: custom.Dialog): feed = await Feed.get(id=dialog.id) last_feed_entry = await FeedEntry.filter(feed=feed).order_by("-date").first() - [_, tg_message_id] = parse_feed_entry_id(last_feed_entry.id) + get_dialog_messages_args = {} + if last_feed_entry: + [_, tg_message_id] = parse_feed_entry_id(last_feed_entry.id) + get_dialog_messages_args["min_message_id"] = tg_message_id + logging.warning( + f"TelegramPoller.update_feed -> feed {feed.name} ({feed.id}) does not have associated feed entries" + ) + else: + get_dialog_messages_args["limit"] = self._new_feed_limit + new_dialog_messages = await self._client.get_dialog_messages( - dialog=dialog, - min_message_id=tg_message_id, + dialog=dialog, **get_dialog_messages_args ) feed_entries = await self._process_new_dialog_messages(