kz.py 文件源码

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

项目:tmerc-cogs 作者: tmercswims 项目源码 文件源码
def _steam_url_to_text_id(self, server_id: str,
                                    vanityurl: str) -> str:
        api_key = self.settings[server_id]["steam_api_key"]

        url = "http://api.steampowered.com/ISteamUser/"
        "ResolveVanityURL/v0001/?key={}&vanityurl={}".format(
            api_key, vanityurl)

        steam64_id = None
        async with aiohttp.get(url) as res:
            response = json.loads(await res.text())["response"]
            if response["success"] != 1:
                raise SteamUrlError(
                    "'{}' is not a Steam vanity URL.".format(vanityurl))
            steam64_id = int(response["steamid"])

        account_id = steam64_id & ((1 << 32) - 1)
        universe = (steam64_id >> 56) & ((1 << 8) - 1)

        I = universe
        J = account_id & 1
        K = (account_id >> 1) & ((1 << 31) - 1)

        return "STEAM_{}:{}:{}".format(I, J, K)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号