Add reddit stream count

This commit is contained in:
Zeva Rose 2022-04-21 10:29:21 -06:00
parent 4157989040
commit 2cd67aceaf

View file

@ -174,7 +174,7 @@ async def reddit(bot: Snake) -> None:
guild = await bot.fetch_guild(follow.guild)
channel = await bot.fetch_channel(follow.channel)
if not guild or not channel:
logger.debug(f"Follow {follow.id} no longer valid, deleting")
logger.debug(f"Follow {follow.id} invalid, deleting")
await follow.delete()
count -= 1
continue
@ -183,7 +183,9 @@ async def reddit(bot: Snake) -> None:
logger.debug(f"Subreddit {sub.display_name} has no followers, removing")
await sub.delete()
old_count = 0
while True:
count = len(running)
subs = Subreddit.find(q(display_name__nin=running))
# Go through all actively followed subreddits
@ -214,6 +216,10 @@ async def reddit(bot: Snake) -> None:
# Create and run stream
coro = _stream(sub, bot)
asyncio.create_task(coro)
count += 1
if old_count != count:
logger.debug(f"Now streaming {count} subreddits")
old_count = count
# Check every 60 seconds
await asyncio.sleep(60)