uptime.py 文件源码

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

项目:CactusBot 作者: CactusDev 项目源码 文件源码
def default(self, *, channel: "channel"):
        """Default response."""

        response = await (await aiohttp.get(
            "https://beam.pro/api/v1/channels/{}".format(channel)
        )).json()

        if "id" in response:
            data = await (await aiohttp.get(
                self.BEAM_MANIFEST_URL.format(channel=response["id"])
            )).json()

            if "startedAt" in data:
                time = datetime.datetime.utcnow() - datetime.datetime.strptime(
                    data["startedAt"], "%Y-%m-%dT%H:%M:%S.%fZ")
                time -= datetime.timedelta(microseconds=time.microseconds)
                return "Channel has been live for {}.".format(time)

        return "Channel is offline."
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号