Last active
December 6, 2023 07:19
-
-
Save qwqtoday/40ed7cdf2e6777404756737bae73e500 to your computer and use it in GitHub Desktop.
Finds a list of users for a Roblox game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import roblox | |
| from roblox.jobs import ServerType, Server | |
| from roblox.thumbnails import ThumbnailFormat, AvatarThumbnailType, ThumbnailState, Thumbnail | |
| from roblox.utilities.iterators import SortOrder | |
| from roblox.users import User | |
| from itertools import batched | |
| import asyncio | |
| # Configuration | |
| place_id = 7239319209 | |
| client = roblox.Client() # Requires token | |
| async def get_enemies(): | |
| enemies = [1] | |
| return enemies | |
| async def on_found(user: User, server: Server): | |
| ... | |
| async def main(): | |
| enemies = await get_enemies() | |
| enemies_thumbnails: list[Thumbnail] = [] | |
| for enemies_batch in batched(enemies, 20): | |
| enemies_thumbnails_batch = await client.thumbnails.get_user_avatar_thumbnails( | |
| enemies_batch, | |
| AvatarThumbnailType.headshot, | |
| (150, 150), | |
| ThumbnailFormat.png | |
| ) | |
| enemies_thumbnails.extend(enemies_thumbnails_batch) | |
| place = await client.get_place(place_id) | |
| servers: list[Server] = await place.get_servers(ServerType.public, 100, SortOrder.Ascending).flatten() | |
| for server in servers: | |
| thumbnails = await server.get_player_thumbnails( | |
| size=(150, 150), | |
| format=ThumbnailFormat.png, | |
| requestId=server.id | |
| ) | |
| for thumbnail in thumbnails: | |
| if thumbnail.state == ThumbnailState.completed: | |
| for enemy_thumbnail in enemies_thumbnails: | |
| if enemy_thumbnail.image_url == thumbnail.image_url: | |
| enemy = await client.get_user(enemy_thumbnail.target_id) | |
| await on_found(enemy, server) | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment