[RSS] Make RSS work with cog disabling API (#160)
* [RSS] Make RSS work with cog disabling API * Update feed qualifier to work with disabling Instead of the catch-all dealing with feeds having no time, just let the catch-all handle everything. If the cog has been disabled for a long period of time and there are no matches via the saved feed information, the feed will only post 1 feed post instead of all of them (10, 20, 25 posts depending on the feed usually). If the cog is reinstated and there is only a partial match (say, 18 out of 20 feeds before it finds a qualifying match)... it will still post all 18 posts. Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
This commit is contained in:
16
rss/rss.py
16
rss/rss.py
@@ -25,7 +25,7 @@ from .tag_type import INTERNAL_TAGS, VALID_IMAGES, TagType
|
||||
log = logging.getLogger("red.aikaterna.rss")
|
||||
|
||||
|
||||
__version__ = "1.1.17"
|
||||
__version__ = "1.1.18"
|
||||
|
||||
|
||||
class RSS(commands.Cog):
|
||||
@@ -861,13 +861,10 @@ class RSS(commands.Cog):
|
||||
)
|
||||
break
|
||||
|
||||
# the saved title/link doesn't match anything in the entire feed post list and the time
|
||||
# value didn't help because it doesn't exist so let's just post 1 instead of every post
|
||||
# available in the entire feed
|
||||
if not entry_time:
|
||||
if len(feedparser_plus_objects) == len(sorted_feed_by_post_time):
|
||||
log.debug(f"Couldn't match anything for feed {name} on cid {channel.id}, only posting 1 post")
|
||||
feedparser_plus_objects = [feedparser_plus_objects[0]]
|
||||
# nothing in the whole feed matched to what was saved, so let's only post 1 instead of every single post
|
||||
if len(feedparser_plus_objects) == len(sorted_feed_by_post_time):
|
||||
log.debug(f"Couldn't match anything for feed {name} on cid {channel.id}, only posting 1 post")
|
||||
feedparser_plus_objects = [feedparser_plus_objects[0]]
|
||||
|
||||
# post oldest first
|
||||
feedparser_plus_objects.reverse()
|
||||
@@ -1042,6 +1039,9 @@ class RSS(commands.Cog):
|
||||
await self.config.channel_from_id(int(channel_id)).clear() # Remove entries from dead channel
|
||||
continue
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, channel.guild):
|
||||
continue
|
||||
|
||||
for feed_key, feed in channel_feed_list.items():
|
||||
for feed_name, feed_data in feed.items():
|
||||
rss_feed = SimpleNamespace(channel=channel, feed_name=feed_name, feed_data=feed_data)
|
||||
|
||||
Reference in New Issue
Block a user