reddit.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:dogbot 作者: slice 项目源码 文件源码
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.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号