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)
评论列表
文章目录