def post_to_feeds(self):
# guilds aren't available until the bot is ready, and this task begins before the bot
# is ready. so let's wait for it to be ready before updating feeds
await self.bot.wait_until_ready()
logger.debug('Bot is ready, proceeding to Reddit feed update loop...')
while True:
# sleep up here so we don't update immediately
# wait the main sleep interval
await asyncio.sleep(self.update_interval)
logger.debug('Going to update all feeds...')
# fetch all feeds, and update them all
feeds = await self.bot.pgpool.fetch('SELECT * FROM reddit_feeds')
# enumerate through all feeds
for idx, feed in enumerate(feeds):
logger.debug('Updating feed {}/{}!'.format(idx + 1, len(feeds)))
# wait a minute or two to prevent rate limiting (doesn't really help but w/e)
await asyncio.sleep(random.random() + self.fuzz_interval)
# update the feed
await self.update_feed(feed)
logger.debug('Updated.')
评论列表
文章目录