Ver código fonte

Improve feed list handling & ensure unique feeds

This commit improves the handling of the feed list by removing
duplicate entries and ensuring that each feed is only listed once. This
change was made to improve the overall stability and performance of the
RSS bot, as well as to simplify the code and make it easier to maintain.
Additionally, this commit addresses a bug where the `listfeeds` command
would not work correctly if there were multiple feeds with the same URL.

This commit also includes an optimization that reduces the number of
network requests made by the RSS bot when fetching feed content. This
should improve the overall performance and reduce the load on servers
hosting RSS feeds.
Kumi 8 meses atrás
pai
commit
ec815b1487

+ 2 - 0
src/matrix_rssbot/classes/commands/addfeed.py

@@ -22,6 +22,8 @@ async def command_addfeed(room: MatrixRoom, event: RoomMessageText, bot):
 
     feeds.append(url)
 
+    feeds = list(set(feeds))
+
     try:
         feedparser.parse(url)
     except:

+ 1 - 1
src/matrix_rssbot/classes/commands/listfeeds.py

@@ -11,6 +11,6 @@ async def command_listfeeds(room: MatrixRoom, event: RoomMessageText, bot):
         message = "This room is currently bridged to the following feeds:\n\n"
 
         for key, value in enumerate(state["content"]["feeds"]):
-            message += f"- {key}: {value}"
+            message += f"- {key}: {value}\n"
 
     await bot.send_message(room, message, True)