Giter Club home page Giter Club logo

ro.py's People

Contributors

auriosi avatar boegie19 avatar bulieme avatar iranathan avatar jmkd3v avatar jodenee avatar lordmerc avatar maxgurbanli avatar mdm9300404 avatar nikita-petko avatar shadow01148 avatar zmadie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ro.py's Issues

Key error when calling get_friends()

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

  1. Call user.get_friends()
  2. See error

Expected behavior
Returns a list of the users friends

Problems with .join() and browser_tracker_id

Describe the bug
When trying to launch a game I get this error
pycharm64_RoMMnoEtNO

To Reproduce
Use .join() on a root game place

Expected behavior
Expected the game to start

Additional context
I am using the Bleeding Edge version as the stable one had the error in the screenshot
pycharm64_099xeypO9t

Split up methods for different item types into different "providers"

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)

Error 404 on attempt to use roblox.BasePlace.get_instances()

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:

  • OS: Windows 7 x64 SP1
  • ro.py v2.0.0

Checking a user's inventory

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.

PIP install Error

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.```

get_friend_count() is not working with me.

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))

404 Not Found when using .get_instances()

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

Calling group.get_member(id) errors

Describe the bug
When calling group.get_member(id), the following error is thrown:

obraz

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.

obraz

Advice for the rewrite

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.

image
image

You can disregard this issue if you wish, but take it into mind.

Client Bot Username

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

Add a function for change the password

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.

Primary Role Key Error

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:

  • OS: Ubuntu
  • Version: 22.04

Group Payouts?

I've been scrolling the docs for 30 minutes now and can't find where I can group payout.

ro_py.extensions.bot fails to run

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

Improve docs

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:

  • Add ~40px space or a separator between each method so its visible what belongs where
  • Remove unnecessary source code snippets and replace them with code examples (on the methods which might sound confusing)
  • Remove unnecessary init constructors found at some methods
  • Make an examples tab

Add an option to pass your own requests class into the client

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)

Bring back expand

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

Inconsistencies between return types on different Client methods

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:

  • Make the other methods also return None instead of raising exceptions
    • Not only is this a large breaking change, but it's also not proper when compared to API responses which do raise errors. I feel better about raising errors manually than I do about replacing the API's error behavior.
  • Raise fake NotFound errors on these methods in particular
    • I don't like this because we're only supposed to raise NotFound for actual 404 errors.
  • Create custom errors, like UserNotFound that are raised in place of NotFound on get_user and get_user_by_username, and do the same for other methods
    • This means you can't do a try-except for NotFound on get_user anymore, which is breaking.
    • Making it a subclass of HTTPException kind of breaks the rules because it's really only for 4xx/5xx HTTP status codes, not for other purposes.
    • Making it a subclass of 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.
    • Only raising it for 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.
  • Live with the inconsistencies.
    • Obviously not ideal. 😔
  • Completely get rid of 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.
    • This makes the methods consistent now but breaks existing code and is not really ideal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.