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.
This commit is contained in:
Kumi 2024-03-02 17:44:42 +01:00
parent bd6210bb4a
commit ec815b1487
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 3 additions and 1 deletions

View file

@ -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:

View file

@ -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)