mirror of
https://github.com/maubot/rss.git
synced 2024-10-01 08:25:36 -04:00
Respond with error when trying to subscribe to already subscribed feed
This commit is contained in:
parent
79cd475312
commit
db492640d7
11
rss/bot.py
11
rss/bot.py
@ -294,8 +294,15 @@ class RSSBot(Plugin):
|
|||||||
self.db.add_entries(entries, override_feed_id=feed.id)
|
self.db.add_entries(entries, override_feed_id=feed.id)
|
||||||
elif feed.error_count > 0:
|
elif feed.error_count > 0:
|
||||||
self.db.set_backoff(feed, error_count=feed.error_count, next_retry=0)
|
self.db.set_backoff(feed, error_count=feed.error_count, next_retry=0)
|
||||||
self.db.subscribe(feed.id, evt.room_id, evt.sender)
|
feed_info = f"feed ID {feed.id}: [{feed.title}]({feed.url})"
|
||||||
await evt.reply(f"Subscribed to feed ID {feed.id}: [{feed.title}]({feed.url})")
|
sub, _ = self.db.get_subscription(feed.id, evt.room_id)
|
||||||
|
if sub is not None:
|
||||||
|
subscriber = ("You" if sub.user_id == evt.sender
|
||||||
|
else f"[{sub.user_id}](https://matrix.to/#/{sub.user_id})")
|
||||||
|
await evt.reply(f"{subscriber} had already subscribed this room to {feed_info}")
|
||||||
|
else:
|
||||||
|
self.db.subscribe(feed.id, evt.room_id, evt.sender)
|
||||||
|
await evt.reply(f"Subscribed to {feed_info}")
|
||||||
|
|
||||||
@rss.subcommand("unsubscribe", aliases=("u", "unsub"),
|
@rss.subcommand("unsubscribe", aliases=("u", "unsub"),
|
||||||
help="Unsubscribe this room from a feed.")
|
help="Unsubscribe this room from a feed.")
|
||||||
|
Loading…
Reference in New Issue
Block a user