-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24eca34
commit 47ed15d
Showing
11 changed files
with
61 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import roblox | ||
import threading | ||
|
||
client = roblox.Client() | ||
for i in range(2000): | ||
try: | ||
user = client.fetch_user(i+1) | ||
print(user.name) | ||
|
||
except roblox.models.ErrorModel.InvalidUser: | ||
print(f"{i+1} ID is not found") | ||
|
||
except roblox.models.ErrorModel.RateLimit: | ||
print(f"Ratelimited") | ||
|
||
user = client.fetch_user(1) | ||
print(user.name) | ||
group = client.fetch_group(1) | ||
print(group.name) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from ..services import UserService | ||
|
||
from ..services import GroupService | ||
|
||
class Client: | ||
|
||
def __init__(self) -> None: | ||
print(f"Client object has been created") | ||
pass | ||
|
||
def fetch_user(self, roblox_id: int): | ||
print(f"Client fetching {roblox_id}") | ||
return UserService.fetch_user(roblox_id=roblox_id) | ||
return UserService.fetch_user(roblox_id=roblox_id) | ||
|
||
def fetch_group(self, group_id: int): | ||
return GroupService.fetch_group(group_id=group_id) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from ..models.GroupModel import GroupModel | ||
from ..models.ErrorModel import InvalidGroup, RateLimit | ||
|
||
|
||
class GroupFactory: | ||
|
||
@staticmethod | ||
def create(response): | ||
if response.status_code == 400: | ||
raise InvalidGroup("Group ID is invalid") | ||
|
||
elif response.status_code == 429: | ||
raise RateLimit("group.roblox.com has ratelimited requests") | ||
|
||
return GroupModel(response.json()) | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
|
||
class GroupModel: | ||
|
||
def __init__(self, data: dict) -> None: | ||
#super().__init__(roblox_id=data["id"]) | ||
self.name = data["name"] | ||
self.id = data["id"] | ||
self.description = data["description"] | ||
self.member_count = data["memberCount"] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from ..http import HttpService | ||
from ..managers.GroupFactory import GroupFactory | ||
|
||
|
||
class GroupService: | ||
|
||
@staticmethod | ||
def fetch_group(group_id: int): | ||
http_client = HttpService().client | ||
response = http_client.send_request(method="GET", link=f"https://groups.roblox.com/v1/groups/{group_id}") | ||
return GroupFactory.create(response) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .UserService import UserService | ||
from .UserService import UserService | ||
from .GroupService import GroupService |