File size: 6,582 Bytes
01fb5c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | import requests
HEADERS = {
"User-Agent": "neo1/1.0",
"Accept": "application/json",
}
def search_player(name):
try:
url = "https://users.roblox.com/v1/usernames/users"
resp = requests.post(
url,
json={"usernames": [name], "excludeBannedUsers": False},
headers=HEADERS,
timeout=8,
)
data = resp.json()
users = data.get("data", [])
if not users:
return None
user = users[0]
user_id = user["id"]
profile = get_profile(user_id)
avatar = get_avatar(user_id)
stats = get_stats(user_id)
return {
"id": user_id,
"name": user.get("name"),
"display_name": user.get("displayName"),
"description": profile.get("description", ""),
"created": profile.get("created", "Unknown"),
"is_banned": profile.get("isBanned", False),
"avatar": avatar,
"friends": stats.get("friends", "N/A"),
"followers": stats.get("followers", "N/A"),
"following": stats.get("following", "N/A"),
}
except Exception as e:
return {"error": str(e)}
def get_profile(user_id):
try:
url = f"https://users.roblox.com/v1/users/{user_id}"
resp = requests.get(url, headers=HEADERS, timeout=8)
return resp.json()
except Exception:
return {}
def get_avatar(user_id):
try:
url = (
f"https://thumbnails.roblox.com/v1/users/avatar-headshot"
f"?userIds={user_id}&size=420x420&format=Png&isCircular=false"
)
resp = requests.get(url, headers=HEADERS, timeout=8)
data = resp.json()
return data.get("data", [{}])[0].get("imageUrl", None)
except Exception:
return None
def get_stats(user_id):
result = {}
try:
r = requests.get(
f"https://friends.roblox.com/v1/users/{user_id}/friends/count",
headers=HEADERS, timeout=8,
)
result["friends"] = r.json().get("count", "N/A")
except Exception:
result["friends"] = "N/A"
try:
r = requests.get(
f"https://friends.roblox.com/v1/users/{user_id}/followers/count",
headers=HEADERS, timeout=8,
)
result["followers"] = r.json().get("count", "N/A")
except Exception:
result["followers"] = "N/A"
try:
r = requests.get(
f"https://friends.roblox.com/v1/users/{user_id}/followings/count",
headers=HEADERS, timeout=8,
)
result["following"] = r.json().get("count", "N/A")
except Exception:
result["following"] = "N/A"
return result
def search_game(name):
try:
url = f"https://games.roblox.com/v1/games/list?keyword={name}&maxRows=5&startRows=0"
resp = requests.get(url, headers=HEADERS, timeout=8)
data = resp.json()
games = data.get("games", [])
if not games:
return None
universe_id = games[0].get("universeId")
if not universe_id:
return None
return get_game_details(universe_id)
except Exception as e:
return {"error": str(e)}
def get_game_details(universe_id):
try:
url = f"https://games.roblox.com/v1/games?universeIds={universe_id}"
resp = requests.get(url, headers=HEADERS, timeout=8)
data = resp.json()
games = data.get("data", [])
if not games:
return None
g = games[0]
last_update = g.get("updated", "Unknown")
if last_update and last_update != "Unknown":
last_update = last_update[:10]
return {
"name": g.get("name"),
"genre": g.get("genre", "Uncategorized"),
"visits": g.get("visits", 0),
"last_update": last_update,
"description": g.get("description") or "No description.",
"creator": g.get("creator", {}).get("name", "Unknown"),
"playing": g.get("playing", 0),
"id": universe_id,
}
except Exception as e:
return {"error": str(e)}
def format_player(data):
if not data:
return "I couldn't find that player on Roblox. Please check that the username is correct."
if "error" in data:
return f"An error occurred while searching for the player: {data['error']}"
description = data.get("description") or "No description."
created = data.get("created", "Unknown")
if created != "Unknown":
created = created[:10]
banned = "Yes โ ๏ธ" if data.get("is_banned") else "No โ
"
friends = data.get("friends", "N/A")
followers = data.get("followers", "N/A")
following = data.get("following", "N/A")
lines = [
"Here's the public data for this Roblox player ๐",
"",
f"๐ค **Username:** {data['name']}",
f"โ๏ธ **Display name:** {data['display_name']}",
f"๐ **ID:** {data['id']}",
f"๐ **Description:** {description}",
f"๐
**Account created:** {created}",
f"๐ซ **Banned?:** {banned}",
"",
"๐ **Stats:**",
f"๐ซ **Friends:** {friends}",
f"๐ฅ **Followers:** {followers}",
f"โก๏ธ **Following:** {following}",
]
if data.get("avatar"):
lines.append(f"\n๐ผ๏ธ **Avatar:** {data['avatar']}")
return "\n".join(lines)
def format_game(data):
if not data:
return "I couldn't find that game on Roblox. Try a different name."
if "error" in data:
return f"An error occurred while searching for the game: {data['error']}"
visits = data.get("visits", 0)
try:
visits = f"{int(visits):,}"
except Exception:
visits = str(visits)
playing = data.get("playing", 0)
try:
playing = f"{int(playing):,}"
except Exception:
playing = str(playing)
lines = [
"Roblox game data ๐",
"",
f"๐ฎ **Name:** {data.get('name', 'Unknown')}",
f"๐ญ **Genre:** {data.get('genre', 'Uncategorized')}",
f"๐๏ธ **Visits:** {visits}",
f"๐ **Last update:** {data.get('last_update', 'Unknown')}",
f"๐ **Description:** {data.get('description', 'No description.')}",
"",
f"๐ค **Creator:** {data.get('creator', 'Unknown')}",
f"๐ฅ **Currently playing:** {playing}",
]
return "\n".join(lines)
|