def checkSteamID64(id): foundID = 0 if(str(steam.SteamID(id)) == id): #Check if id matches a found one foundID = id else: foundID = steam.steamid.steam64_from_url("http://steamcommunity.com/id/"+id) #Check if id matches a custom url if(foundID and str(steam.SteamID(foundID).type)=="EType.Individual"): #If found check if that is the id for an individual return foundID return 0
def getSteamID64(user_input): """ Returns a steamID64 (as an int) for a given Steam profile. """ steamID64 = steam.steamid.steam64_from_url("https://steamcommunity.com/" + "id/" + user_input) # customURL case if steamID64 is None: steamID64 = int(steam.SteamID(user_input)) # steamID32 & steamID64 case checkSteamID(steamID64, user_input) return steamID64
def getProfileDetails(steamID64): """ Prints all the details linked to a steamID64. """ steamInstance = steam.SteamID(steamID64) sys.stdout.write("\033[32m") print("steam3ID:\t" + steamInstance.as_steam3) print("steamID32:\t" + steamInstance.as_steam2) print("steamID64:\t" + str(steamInstance.as_64)) sys.stdout.write("\033[0m")
def index_result(): sid = request.forms.get('inputid') sid = sid.strip("/ ") ssid = [] try: if sid.find("steamcommunity") != -1: sid = sid.split('/') sid = sid[-1] if sid.isdigit(): theid = steam.SteamID(sid) ssid.append(theid.as_steam2) ssid.append(theid.as_steam2_zero) ssid.append(str(theid.as_64)) ssid.append(theid.as_steam3) ssid.append(theid.community_url) return {'ssid': ssid, 'cond': True} else: sid = api.ISteamUser.ResolveVanityURL(vanityurl=sid) sid = sid['response']['steamid'] theid = steam.SteamID(sid) ssid.append(theid.as_steam2) ssid.append(theid.as_steam2_zero) ssid.append(str(theid.as_64)) ssid.append(theid.as_steam3) ssid.append(theid.community_url) return {'ssid': ssid, 'cond': True} else: theid = steam.SteamID(sid) if theid.is_valid(): ssid.append(theid.as_steam2) ssid.append(theid.as_steam2_zero) ssid.append(str(theid.as_64)) ssid.append(theid.as_steam3) ssid.append(theid.community_url) return {'ssid': ssid, 'cond': True} else: return {'cond': False} except Exception: return {'cond': False}
def get_persona_names( self, steam_ids: Sequence[steam.SteamID]) -> Dict[steam.SteamID, str]: if self._dummy: return {steam_id: "" for steam_id in steam_ids} # TODO: handle more than 100 IDs. if len(steam_ids) > 100: raise ValueError("TODO: May request only 100 players at a time!") steam_ids = [str(sid.as_64) for sid in steam_ids] steam_ids = ",".join(steam_ids) resp = self.ISteamUser.GetPlayerSummaries( steamids=steam_ids)["response"]["players"] return {steam.SteamID(r["steamid"]): r["personaname"] for r in resp}
async def amain(input_message: str) -> None: client = steam.Client() client.http.user = steam.SteamID() # type: ignore fake_ws = SteamWebSocket(client._connection, None, None, None) # type: ignore def parser(msg: MsgBase[betterproto.Message]) -> None: print(f"{msg.msg=}") print(black.format_str(str(msg.body), mode=black.Mode())) if msg.body._unknown_fields: print(f"Unknown fields: {msg.body._unknown_fields}") async def handle_multi(msg: MsgProto[CMsgMulti]) -> None: print("This is a multi message, unpacking...") black.format_str(str(msg.body), mode=black.Mode()) await fake_ws.handle_multi(msg) fake_ws.parsers = defaultdict(lambda: parser) fake_ws.parsers[EMsg.Multi] = handle_multi await fake_ws.receive(b64decode(input_message)) await asyncio.sleep(2)
def checkRocketID(platform1, id1, returnFull=False): if(not platform1): return False if(platform1=="1" and str(steam.SteamID(id1)) != id1): #Check if id was inputted as custom url testID = steam.steamid.steam64_from_url("http://steamcommunity.com/id/"+id1) if(testID): id1 = testID else: testID = steam.steamid.steam64_from_url(id1) if(testID): id1 = testID #Use the RL api to check if the ID exists try: rl = RocketLeague(api_key='3PE3QPQJDC6RTQOEI76ALAAW3KO6GI9F') response = rl.players.player(id=id1, platform=platform1) if returnFull: return response.json() else: return id1 except Exception as e: #Check if not found, raise if any other error occours if(str(type(e))=="<class 'rls.exceptions.ResourceNotFound'>"): return False else: raise e
def login(self, username, password, sentry_hash=None, code=None): self.steam_id = steam.SteamID(0) self.steam_id.universe = EUniverse.Public self.steam_id.account_type = EAccountType.Individual self.session_id = None self.username = username self.password = password self.sentry_hash = sentry_hash self.code = code self.jobs = {} self.msg_queue = Queue.Queue() self.current_job = 0 for i in xrange(3): for server in random.sample(steam.servers, len(steam.servers)): print 'connecting to:', server try: self.connection = Connection(*server) return except Exception: print 'timeout' raise socket.error('could not connect to server')
def parse_players( self, resp: bytes, adapter: adapters.WebAdminAdapter) -> List[adapters.PlayerWrapper]: parsed_html = self.parse_html(resp) if not parsed_html: logger.error("unable to parse players; no response" " data to parse") return [] player_table = parsed_html.find("table", attrs={"id": "players"}) player_headers = player_table.find("thead") player_headers = player_headers.find_all("th") player_table = player_table.find("tbody") player_table = player_table.find_all("tr") player_table = self._parse_table(player_table) # Not expecting this header to ever change order. # We could probably hard-code this... player_headers = [ph.text for ph in player_headers] player_headers[player_headers.index(TEAM_INDEX_KEY)] = "Team Index" if (len(player_table) == 1) and player_table[0] == NO_PLAYERS: logger.debug("no players") return [] if not all(len(p) for p in player_table): logger.error("player rows in player table differ in length") return [] if not len(player_table[0]) == len(player_headers): logger.error("player table and player headers differ in length") return [] # We use 'Unique ID' column here instead of 'Steam ID' # column because 'Steam ID' column is sometimes not filled. # 'Unique ID' is just a hex-string of the user's SteamID64 # anyway. id_index = player_headers.index(UNIQUE_ID_KEY) players = [] id_to_stats = {} steam_ids = [] for player_row in player_table: steam_id = player_row[id_index] try: steam_id = int(steam_id, 16) except ValueError as ve: logger.error("unable to convert Unique ID to SteamID64") logger.exception(ve) steam_id = 0 steam_ids.append(steam.SteamID(steam_id)) stats = { key: value for key, value in zip(player_headers, player_row) if key.lower() != "actions" } id_to_stats[steam_id] = stats persona_names = SteamWebAPI().get_persona_names(steam_ids=steam_ids) for steam_id in steam_ids: persona_name = "" try: persona_name = persona_names[steam_id] except KeyError as ke: logger.error("error getting persona name for Steam ID: {sid}", sid=steam_id) logger.exception(ke) p_stats = id_to_stats[steam_id] player = models.Player( steam_id=steam_id, stats=p_stats, persona_name=persona_name, ) players.append( adapters.PlayerWrapper( player=player, adapter=adapter, )) return players
async def printRecord(ctx, mapname, track): if mapname.startswith('"'): sql = "SELECT time, jumps, sync, strafes, date, map, u.name, p.auth FROM " + TABLE_PREFIX + "playertimes p, " + TABLE_PREFIX + "users u WHERE map = " + str( mapname) + " AND track = " + str( track ) + " AND style = 0 AND u.auth = p.auth ORDER BY time ASC LIMIT 1" else: sql = "SELECT time, jumps, sync, strafes, date, map, u.name, p.auth FROM " + TABLE_PREFIX + "playertimes p, " + TABLE_PREFIX + "users u WHERE map LIKE '%" + str( mapname) + "%' AND track = " + str( track ) + " AND style = 0 AND u.auth = p.auth ORDER BY time ASC LIMIT 1" conn = mysql.connector.connect(**db) cursor = conn.cursor() cursor.execute(sql) results = cursor.fetchone() conn.close() cursor.close() time = results[0] jumps = str(results[1]) sync = str(results[2]) strafes = str(results[3]) timestamp = results[4] mapname = str(results[5]) user = str(results[6]) auth = results[7] if track == 0: trackName = "Map" trackColour = 0x1183f4 else: trackName = "Bonus" trackColour = 0xe79f0c time = formatSeconds(results[0]) date_time = datetime.fromtimestamp(timestamp) d = date_time.strftime("%d/%m/%Y") link = "http://www.steamcommunity.com/profiles/" + str(SID.SteamID(auth)) if STATS_PAGE: statslink = STATS_PAGE + "/?track=" + str(track) + "&map=" + mapname embed = discord.Embed(title=trackName + " Record", description="[" + mapname + "](" + statslink + ")", color=trackColour) if not STATS_PAGE: embed = discord.Embed(title=trackName + " Record", description=mapname, color=trackColour) embed.set_thumbnail(url=ICON) embed.set_footer(text="Join: steam://connect/" + IP + ":" + str(PORT)) embed.add_field(name="Player", value="[" + user + "](" + link + ")", inline=True) embed.add_field(name="Time", value=time, inline=True) embed.add_field(name="Jumps", value=jumps, inline=True) embed.add_field(name="Sync", value=sync + "%", inline=True) embed.add_field(name="Strafes", value=strafes, inline=True) embed.add_field(name="Date", value=d, inline=True) await ctx.send(embed=embed)