ro-py / ro.py Goto Github PK
View Code? Open in Web Editor NEWro.py is a modern, asynchronous Python 3 wrapper for the Roblox API.
Home Page: https://ro.py.jmk.gg/
License: MIT License
ro.py is a modern, asynchronous Python 3 wrapper for the Roblox API.
Home Page: https://ro.py.jmk.gg/
License: MIT License
Describe the bug
To Reproduce
When calling user.get_friends(), the following error is thrown:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Thonny\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "D:\TkinterStuff\GUI.py", line 210, in buttonClick
asyncio.get_event_loop().run_until_complete(getID(values_list))
File "C:\Users\user\AppData\Local\Programs\Thonny\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "D:\TkinterStuff\GUI.py", line 183, in getID
friends = await user.get_friends()
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\roblox\bases\baseuser.py", line 112, in get_friends
return [Friend(shared=self._shared, data=friend_data) for friend_data in friends_data]
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\roblox\bases\baseuser.py", line 112, in
return [Friend(shared=self._shared, data=friend_data) for friend_data in friends_data]
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\roblox\friends.py", line 33, in init
self.presence_type: int = data["presenceType"]
KeyError: 'presenceType'
To Reproduce
Expected behavior
Returns a list of the users friends
Right now, the Client has a lot of methods and is kind of polluted.
Assets:
get_asset()
get_base_asset()
Badges:
get_badge()
get_base_badge()
Groups:
get_group()
get_base_group()
Places:
get_place()
get_places()
Plugins:
get_plugin()
get_plugins()
Universes:
get_universe()
get_universes()
Users:
get_user()
get_user_by_username()
get_users()
get_users_by_usernames()
get_base_user()
get_authenticated_user()
user_search()
Maybe we could split these up into sub-providers, where each one deals with items of a certain type.
# Current syntax
user = await client.get_user(1)
# Proposed syntax (one of the following)
user = await client.users.get(1)
user = await client.users.by_id(1)
Whenever I try to run the roblox.BasePlace.get_instances() to check for active game instances in my game, it throws an error 404. Code is below.
import asyncio
import roblox
client = roblox.Client("cookie here")
id = int(input('place id: '))
place = roblox.BasePlace(client, id)
async def main():
print(await place.get_instances())
asyncio.run(main())
Desktop:
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
NO
If your feature is related to implementing a new Roblox API, provide information here.
API URL: https://users.roblox.com/v1/users/{userId}
Documented: Yes/No
no
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
It would be cool if we could check a user's inventory for checking gamepasses or asset's and then from there, ranking them in your group.
Additional context
Add any other context or screenshots about the feature request here.
So when I try to install the latest version using the readme as a guide, I get an exit code of 128 and am unable to install.
Cloning git://github.com/ro-py/ro.py.git to c:\users\willy\appdata\local\temp\pip-req-build-6sxtv1nh
Running command git clone --filter=blob:none --quiet git://github.com/ro-py/ro.py.git 'C:\Users\###\AppData\Local\Temp\pip-req-build-6sxtv1nh'
fatal: unable to connect to github.com:
github.com[0: 140.82.113.4]: errno=Unknown error
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet git://github.com/ro-py/ro.py.git 'C:\Users\###\AppData\Local\Temp\pip-req-build-6sxtv1nh' did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet git://github.com/ro-py/ro.py.git 'C:\Users\###\AppData\Local\Temp\pip-req-build-6sxtv1nh' did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.```
I am trying to make a code that gets the player username and friends count, I got the player username but the friends count are showing in the message like this <coroutine object BaseUser.get_friend_count at 0x0000020F355B0790>
The code:
@client.command() @commands.guild_only() async def find(ctx, *, user_id): user = await RobloxClient.get_user(user_id) await ctx.channel.send("**The Account Name is {}**".format(user.name)) friends = user.get_friend_count() await ctx.send("**And {}'s has {} Friends**".format(user.name,friends))
place.get_instances()
Returns a 404 error for https://www.roblox.com/games/getgameinstancesjson?placeId=2534724415&startIndex=0
I was told to create a bug report by jmk
Describe the bug
When calling group.get_member(id)
, the following error is thrown:
To Reproduce
Call .get_member(id)
on a group object.
Expected behaviour
Expected the call to not error and return a Member
object.
Additional context
A request to https://groups.roblox.com/v2/users/{userId}/groups/roles is sent, and passed on to Member
. It will attempt to index the user
key on the data, which errors because the endpoint does not return that data.
There is an issue with production right now, there is little to no strong typing on anything.
All implementations for the rewrite should be strong typed, as it is supported.
The benefits of this include stronger intellisense.
If you look at my libraries they show strong typed code, with predicable interfaces, it is preferable to do this because it is more convenient than having to go to some documentation page.
You can disregard this issue if you wish, but take it into mind.
Can someone explain the error?
So I have this code, where it tries to find-out the bots username, it returns with AttributeError: 'Client' object has no attribute 'user'
, is there a way to fix this?
from fastapi import FastAPI, Request, HTTPException, APIRouter
from fastapi.responses import HTMLResponse
import os
import requests
import ro_py
from ro_py.client import Client
from dotenv import load_dotenv
load_dotenv()
RobloxCookie = os.getenv("COOKIE")
client = ro_py.Client(RobloxCookie)
router = APIRouter()
async def get_bot_username():
bot_username = client.user.name
return bot_username
@router.get("/bot/username", response_class=HTMLResponse)
async def about(request: Request):
bot_username = await get_bot_username()
return bot_username
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
If your feature is related to implementing a new Roblox API, provide information here.
API URL: https://users.roblox.com/v1/users/{userId}
Documented: Yes/No
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Describe the bug
await user.get_primary_group_role()
Key Error: 'memberCount'
Copy of error:
File "/robloranker/./main.py", line 37, in promote
await promote_command(interaction, roblox_client, username, reason)
File "/robloranker/commands/promote.py", line 30, in promote_command
operator_user_primary_role = await operator_user.get_primary_group_role()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/roblox/bases/baseuser.py", line 255, in get_primary_group_role
group=Group(
^^^^^^
File "/usr/local/lib/python3.11/site-packages/roblox/groups.py", line 52, in __init__
self.member_count: int = data["memberCount"]
~~~~^^^^^^^^^^^^^^^
KeyError: 'memberCount'
To Reproduce
Use await user.get_primary_group_role()
.
In my case, I only accessed the primary role .group.id
:
operator_user_primary_role = await operator_user.get_primary_group_role()
if operator_user_role is None or operator_user_primary_role is None:
await interaction.followup.send(f"There was an error getting your group role.")
return
if operator_user_primary_role.group.id is not get_main_group_id():
await interaction.followup.send(f"Cannot promote {target_user.name} as ___ is not your primary group.")
return
The operator_user in my case holds the owner role in the primary group.
Expected behavior
A clear and concise description of what you expected to happen.
VPS:
I've been scrolling the docs for 30 minutes now and can't find where I can group payout.
Describe the bug
I get this error when I run the following code in the next section:
Traceback (most recent call last):
File "main.py", line 32, in <module>
bot.run(os.environ.get('token'), background=True)
File "/home/runner/RobloxBot/venv/lib/python3.10/site-packages/ro_py/extensions/bots.py", line 69, in run
self.notifications.on_notification = self._on_notification
AttributeError: 'NoneType' object has no attribute 'on_notification'
To Reproduce
Code to reproduce the behavior:
from roblox.extensions.bots import Bot
import os,asyncio
bot = Bot()
@bot.command()
async def hello(ctx):
await ctx.send("Hello")
bot.run(os.environ.get('token')) # this is a valid roblosecurity key/token
The Python 3.7 feature "Dataclasses" could be very useful for ro.py. Our objects, like User, should be immutable as the only way to return new information is generating a new object entirely.
https://docs.python.org/3.9/library/dataclasses.html
Improving the docs would improve developers workflow and code efficiency which would result in lower amount of requests aswell.
My suggestion on how to improve docs:
Is your feature request related to a problem? Please describe.
Yes, I wanted to customise timeouts but I didn't have a way so I wrote spaghetti code :=)
If your feature is related to implementing a new Roblox API, provide information here.
API URL: none
Documented: none
Describe the solution you'd like
Add an option to pass your own requests class into the client
Describe alternatives you've considered
None
Additional context
session = httpx.Session(timeout=10)
requests = Requests(
url_generator=None,
session=session
)
client = Client(requests=requests)
Is your feature request related to a problem? Please describe.
I'm always frustrated when I can't use the expand function in the rewrite anymore to expand my users or other objects I need full information from.
Describe the solution you'd like
I would like expand functions to come back
Describe alternatives you've considered
using client.get_xyz for everything but using expand is just 100% easier and more effective since it makes the change that I expand the wrong thing 0 (node with expand you just add it behind your object and you go form a partial object to a full one)
Additional context
I think it would help make it easier to get full objects when you need them also you never know what information what partial information the api wrapper gives back whiteout going deep in to the documentation or code.
Also adding this back would be 1 less breaking change form version 1.0,0 to 2.* depending on when you implement it
its showing unauthorized 401
Roblox endpoints that take in a single ID, like users.roblox.com/v1/users/{userId}
, usually raise errors when the passed ID is invalid or does not exist. For example, /v1/users/{userId}
returns the following data and a 404 error when an invalid user ID is passed:
{
"errors": [
{
"code": 3,
"message": "The user id is invalid.",
"userFacingMessage": "Something went wrong"
}
]
}
In ro.py, this means we can raise a NotFound
error:
roblox.utilities.exceptions.NotFound: 404 Not Found: https://users.roblox.com/v1/users/4.
Errors:
3: The user id is invalid.
User-facing message: Something went wrong
Endpoints that take in multiple user IDs, like games.roblox.com/v1/games/multiget-place-details
, tend to ignore invalid IDs and don't raise errors if none of the IDs are valid. In ro.py, all of our get_PLURAL
functions like get_places
and get_universes
maintain this behavior and do not raise errors for invalid IDs.
The issue is that not all of our get_SINGULAR
functions use endpoints that only take in one ID. multiget-place-details
is the only endpoint ro.py uses for places. Because it does not raise an error, get_place
returns None
if the place is invalid and doesn't raise an exception. Multiple other methods also have this behavior.
This causes an inconsistency between methods where some methods (the ones that send requests that take just one ID) raise errors with invalid inputs, but other methods (the ones that take multiple IDs but only pass one) don't raise errors.
The following Client
methods all return None with invalid IDs:
get_user_by_username()
get_universe()
get_place()
get_plugin()
All other singular methods raise exceptions for invalid IDs.
This causes an inconsistency between methods. What should we do?
We have a couple options here:
None
instead of raising exceptions
NotFound
errors on these methods in particular
NotFound
for actual 404 errors.UserNotFound
that are raised in place of NotFound
on get_user
and get_user_by_username
, and do the same for other methods
NotFound
on get_user
anymore, which is breaking.HTTPException
kind of breaks the rules because it's really only for 4xx/5xx HTTP status codes, not for other purposes.RobloxException
means we're not raising the right exception for get_user
anymore. That's an actual HTTP exception, so I think we should keep that there.get_user_by_username
and not get_user
is a bit weird for the developer because there's an exception called UserNotFound
that isn't raised on the method used to get users but is raised on the method used to get users by username.get_user_by_username
, get_universe
, get_place
and get_plugin
and force developers to use their plural counterparts: get_users_by_username
, get_universes
, get_places
and get_plugins
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.