Skip to content

Commit 3759950

Browse files
authored
[Structure] Fixed naming structure of folder
Github doesn't let you edit directory names w/o cloning and then checkout. Too lazy to do that.
1 parent cb32f19 commit 3759950

File tree

6 files changed

+320
-0
lines changed

6 files changed

+320
-0
lines changed

pyblox3/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# __init__.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
__title__ = 'pyblox'
10+
__author__ = 'Sanjay-B'
11+
__license__ = 'MIT'
12+
__copyright__ = 'Copyright 2018 Sanjay-B(Sanjay Bhadra)'
13+
__version__ = '0.2.4'
14+
15+
#Parent Class Modules
16+
from .api.assets import Assets
17+
from .api.http import Http
18+
from .api.friends import Friends
19+
from .api.user import Users
20+
from .api.groups import Groups

pyblox3/api/assets.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# assets.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
from .http import Http
10+
import json
11+
12+
13+
class Assets:
14+
15+
def PackageAsset(assetid):
16+
a = Http.sendRequest("https://www.roblox.com/Game/GetAssetIdsForPackageId?packageId=" + str(assetid))
17+
result = []
18+
for part in a:
19+
i = a.index(part)
20+
b = part
21+
link = "https://www.roblox.com/library/" + str(b)
22+
result.insert(i, link)
23+
return result
24+
25+
# GET https://api.roblox.com/Ownership/HasAsset?userId={userId}&assetId={assetId}
26+
# Returns Boolean
27+
def hasAsset(userid, assetid):
28+
a = Http.sendRequest(
29+
"https://api.roblox.com/Ownership/HasAsset?userId=" + str(userid) + "&assetId=" + str(assetid))
30+
if a == "true" or True:
31+
return True
32+
else:
33+
return False
34+
35+
# GET https://api.roblox.com/Marketplace/ProductInfo?assetId={assetId}
36+
# Returns Table/Array + Attributes
37+
def Asset(assetid):
38+
c = Http.sendRequest("https://api.roblox.com/Marketplace/ProductInfo?assetId=" + str(assetid))
39+
b = c.decode("utf-8")
40+
a = json.loads(b)
41+
global Asset
42+
Asset = lambda: None
43+
Asset.Name = a["Name"]
44+
Asset.Id = a["AssetId"]
45+
Asset.ProductId = a["ProductId"]
46+
Asset.Description = a["Description"]
47+
Asset.AssetTypeId = a["AssetTypeId"]
48+
Asset.CreatorName = a["Creator"]["Name"]
49+
Asset.CreatorId = a["Creator"]["Id"]
50+
Asset.CreatorType = a["Creator"]["CreatorType"]
51+
Asset.CreatorTargetId = a["Creator"]["CreatorTargetId"]
52+
Asset.IconImageAssetId = a["IconImageAssetId"]
53+
Asset.Created = a["Created"]
54+
Asset.Updated = a["Updated"]
55+
Asset.PriceInRobux = a["PriceInRobux"]
56+
Asset.Sales = a["Sales"]
57+
Asset.IsNew = a["IsNew"]
58+
Asset.IsForSale = a["IsForSale"]
59+
Asset.IsPublicDomain = a["IsPublicDomain"]
60+
Asset.IsLimited = a["IsLimited"]
61+
Asset.IsLimitedUnique = a["IsLimitedUnique"]
62+
Asset.Remaining = a["Remaining"]
63+
Asset.MinimumMembershipLevel = a["MinimumMembershipLevel"]
64+
Asset.ContentRatingTypeId = a["ContentRatingTypeId"]
65+
return Asset
66+
67+
# GET https://www.roblox.com/studio/plugins/info?assetId={assetId}
68+
# Returns Table/Array
69+
def AssetVersions(assetid):
70+
a = Http.sendRequest("https://www.roblox.com/studio/plugins/info?assetId=" + str(assetid))
71+
result = []
72+
for part in a:
73+
i = a.index(part)
74+
b = part
75+
result.insert(i, part)
76+
return result

pyblox3/api/friends.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# friends.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
from .http import Http
10+
import json
11+
12+
13+
class Friends:
14+
15+
# GET /users/{userId}/friends
16+
# Returns Table/Array containing the Username of all your friends
17+
def friendList(id):
18+
a = Http.sendRequest("https://api.roblox.com/users/" + str(id) + "/friends")
19+
b = a.decode("utf-8")
20+
c = json.loads(b)
21+
result = []
22+
i = 0
23+
for v in c:
24+
u = str(v["Username"])
25+
i = i + 1
26+
result.insert(i, u)
27+
return result
28+
29+
# GET /Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerId={userId}&userId={userId}
30+
# Returns Boolean
31+
def checkFriendship(id1, id2):
32+
a = Http.sendRequest(
33+
"https://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerId=" + str(
34+
id1) + "&userId=" + str(id2))
35+
if a == "true" or True:
36+
return True
37+
else:
38+
return False
39+
40+
# GET /Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerId={userId}&userId={userId}
41+
# Returns Boolean
42+
def checkBestFriendship(id1, id2):
43+
a = Http.sendRequest(
44+
"https://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerId=" + str(
45+
id1) + "&userId=" + str(id2))
46+
if a == "true" or True:
47+
return True
48+
else:
49+
return False
50+
51+
# GET /friends/json?userId={userId}&currentPage=0&pageSize=20&imgWidth=110&imgHeight=110&imgFormat=jpeg&friendsType=BestFriends
52+
# Returns Table/Array containing the Username of all your bestfriends
53+
def bestFriendList(id):
54+
a = Http.sendRequest("https://www.roblox.com/friends/json?userId=" + str(
55+
id) + "&currentPage=0&pageSize=20&imgWidth=110&imgHeight=110&imgFormat=jpeg&friendsType=BestFriends")
56+
b = a.decode("utf-8")
57+
c = json.loads(b)
58+
result = []
59+
i = 0
60+
for v in c:
61+
u = str(v["Username"])
62+
i = i + 1
63+
result.insert(i, u)
64+
return result

pyblox3/api/groups.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#
2+
# group.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
from .http import Http
10+
from bs4 import *
11+
import html5lib
12+
import urllib.request
13+
import json
14+
15+
16+
class Groups:
17+
18+
# GET /users/{userId}/groups
19+
# returns table/array with groups + each group's attributes
20+
def groupList(userid):
21+
a = Http.sendRequest("https://api.roblox.com/users/" + str(userid) + "/groups")
22+
return a
23+
24+
# GET /groups/{groupId}
25+
# Returns Table/Array + Attributes
26+
def getGroup(groupid):
27+
a = Http.sendRequest("https://api.roblox.com/groups/" + str(groupid))
28+
b = a.decode("utf-8")
29+
c = json.loads(b)
30+
global Group
31+
Group = lambda: None
32+
Group.Name = c["Name"]
33+
Group.Id = c["Id"]
34+
Group.Owner = c["Owner"]
35+
Group.Owner.Name = c["Owner"]["Name"]
36+
Group.Owner.Id = c["Owner"]["Id"]
37+
Group.EmblemUrl = c["EmblemUrl"]
38+
Group.Description = c["Description"]
39+
Group.Roles = c["Roles"]
40+
41+
# GET /groups/{groupId}/allies
42+
# Returns Table/Array with each ally's attributes
43+
def getGroupAllies(groupid):
44+
a = Http.sendRequest("https://api.roblox.com/groups/" + str(groupid) + "/allies")
45+
return a
46+
47+
# GET /groups/{groupId}/enemies
48+
# Returns Table/Array with each enemy's attributes
49+
def getGroupEnemies(groupid):
50+
a = Http.sendRequest("https://api.roblox.com/groups/" + str(groupid) + "/enemies")
51+
return a
52+
53+
# GET /groups/{groupId}/roles
54+
# Returns a Table/Array with each role.
55+
def getGroupRoles(groupid):
56+
a = Http.sendRequest("https://groups.roblox.com/v1/groups/" + str(groupid) + "/roles")
57+
return a

pyblox3/api/http.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# http.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
import logging
9+
import requests
10+
11+
12+
class Http:
13+
14+
# GET Request
15+
# Params: "url" // target url
16+
def sendRequest(url):
17+
payload = requests.get(str(url))
18+
statusCode = payload.status_code
19+
content = payload.content
20+
if statusCode is not 200:
21+
return logging.error(f"[Pyblox][GET] Something went wrong. Error: {statusCode}")
22+
return content
23+
24+
# POST Request
25+
# Params: "url" // target url, payload // {JSON key-value pairs}
26+
def postRequest(url, payload):
27+
payload = requests.post(str(url), data=payload)
28+
statusCode = payload.status_code
29+
content = payload.content
30+
if statusCode is not 200:
31+
return logging.error(f"[Pyblox][POST] Something went wrong. Error: {statusCode}")
32+
return content

pyblox3/api/user.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# user.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2017 Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
from .http import Http
10+
import json
11+
12+
13+
class Users:
14+
15+
# GET https://www.roblox.com/UserCheck/DoesUsernameExist?username={username}
16+
# Returns Boolean
17+
def checkUsernameExists(username):
18+
a = Http.sendRequest("https://www.roblox.com/UserCheck/DoesUsernameExist?username=" + str(username))
19+
b = a.decode("utf-8")
20+
c = json.loads(b)
21+
if c["success"] == "True" or True:
22+
return True
23+
else:
24+
return False
25+
26+
# GET https://api.roblox.com/users/get-by-username?username={username}
27+
# Returns Table/Array + Attributes
28+
def User(username):
29+
a = Http.sendRequest("https://api.roblox.com/users/get-by-username?username=" + str(username))
30+
b = a.decode("utf-8")
31+
c = json.loads(b)
32+
global User
33+
User = lambda: None
34+
User.Id = c["Id"]
35+
User.Username = c["Username"]
36+
User.AvatarUrl = c["AvatarUri"]
37+
User.AvatarFinal = c["AvatarFinal"]
38+
User.IsOnline = c["IsOnline"]
39+
return User
40+
41+
# GET https://www.roblox.com/Asset/BodyColors.ashx?userId={userId}
42+
# Returns Table/Array
43+
def BodyColors(id):
44+
a = Http.sendRequest("https://www.roblox.com/Asset/BodyColors.ashx?userId=" + str(id))
45+
return a
46+
47+
# GET https://www.roblox.com/Asset/AvatarAccoutrements.ashx?userId={userId}
48+
# Returns Table/Array
49+
def AssetsWorn(id):
50+
a = Http.sendRequest("https://www.roblox.com/Asset/AvatarAccoutrements.ashx?userId=" + str(id))
51+
return a
52+
53+
# GET https://www.roblox.com/Asset/CharacterFetch.ashx?userId={userId}&placeId={placeId}
54+
# Returns Table/Array
55+
def AssetVersions(id, placeid):
56+
a = Http.sendRequest(
57+
"https://www.roblox.com/Asset/CharacterFetch.ashx?userId=" + str(id) + "&placeId=" + str(placeid))
58+
return a
59+
60+
# GET https://www.roblox.com/Contests/Handlers/Showcases.ashx?userId={userId}
61+
# Returns Table/Array
62+
def Places(id):
63+
a = Http.sendRequest("https://www.roblox.com/Contests/Handlers/Showcases.ashx?userId=" + str(id))
64+
return a
65+
66+
# GET https://www.roblox.com/badges/roblox?userId={userId}&imgWidth=110&imgHeight=110&imgFormat=png
67+
# Return Table/Array
68+
def Badges(id):
69+
a = Http.sendRequest(
70+
"https://www.roblox.com/badges/roblox?userId=" + str(id) + "&imgWidth=110&imgHeight=110&imgFormat=png")
71+
return a

0 commit comments

Comments
 (0)