· 4 years ago · Apr 13, 2021, 09:40 AM
1--[[
2 ROBLOX-HubModule
3 Please do not edit below! This script should be obfuscated to increase security.
4--]]
5
6local URL = ""; -- IP:PORT or Defined URL
7local Key = ""; -- API Key defined in your .env file
8
9--[[ // Functions \\
10 --------------
11 GetStatus() returns true/false (Is it running?)
12 --------------
13 GetUserProducts([User ID]) returns Array[Products]
14 --------------
15 GetVerifyStatus([User ID]) returns 'link'/'complete'
16 --------------
17 GetLinkCode([User ID]) returns Link Code (Returns false if verified)
18 --------------
19 WaitForVerify([User ID]) returns void (Returns when user is verified)
20 --------------
21 GetAllProducts() returns Array[Products]
22 --------------
23 WhitelistUser([Product ID], [User ID]) returns true/false (Did the delivery DM succeed?)
24 --------------
25 RevokeUser([Product ID], [User ID]) returns void
26 --------------
27--]]
28
29local Success,Error = pcall(function()
30 if game.Players.LocalPlayer ~= nil then
31 game.Players.LocalPlayer:Kick("HUB | You must not have this Module stored locally!");
32 end;
33end);
34if not script:IsDescendantOf(game.ServerScriptService) then
35 error("HUB | You must have this Module this in ServerScriptService!");
36end;
37function GetURL(Endpoint)
38 return 'http://'..URL..Endpoint.."?key="..Key;
39end;
40local HttpService = {
41 GetAsync = function(ResURL)
42 local Request = game:GetService('HttpService'):RequestAsync({
43 Url = ResURL;
44 Method = "GET";
45 });
46 if not Request.Success then
47 return nil;
48 else
49 return Request.StatusCode, game:GetService('HttpService'):JSONDecode(Request.Body);
50 end;
51 end;
52};
53local Module = {};
54Module.GetStatus = function(ID)
55 local RetVal = false;
56 local s = pcall(function()
57 local Status, Data = HttpService.GetAsync(GetURL('/'));
58 if not Data then
59 RetVal = false;
60 end;
61 if Data.running == true then
62 RetVal = true;
63 end;
64 end)
65 return RetVal
66end;
67Module.GetUserProducts = function(ID)
68 local RetVal = nil;
69 local s = pcall(function()
70 local Status, Data = HttpService.GetAsync(GetURL('/user/'..ID));
71 RetVal = Data.value.products;
72 end)
73 return RetVal
74end;
75Module.GetVerifyStatus = function(ID)
76 local RetVal = nil;
77 local s = pcall(function()
78 local Status, Data = HttpService.GetAsync(GetURL('/user/'..ID));
79 RetVal = Data.value.verify.status;
80 end)
81 return RetVal
82end;
83Module.GetLinkCode = function(ID)
84 local RetVal = nil;
85 local s = pcall(function()
86 local Status, Data = HttpService.GetAsync(GetURL('/user/'..ID));
87 if Data.value.verify.status == 'link' then
88 RetVal = Data.value.verify.value;
89 else
90 RetVal = false;
91 end;
92 end)
93 return RetVal
94end;
95Module.WaitForVerify = function(ID)
96 local s = pcall(function()
97 while true do
98 local Status, Data = HttpService.GetAsync(GetURL('/user/'..ID));
99 if Data.value.verify.status == 'complete' then
100 break;
101 end;
102 wait(2);
103 end;
104 end)
105end;
106Module.GetAllProducts = function(ID)
107 local RetVal = nil;
108 local s = pcall(function()
109 local Status, Data = HttpService.GetAsync(GetURL('/products'));
110 RetVal = Data.products;
111 end)
112 return RetVal
113end;
114Module.WhitelistUser = function(Product, ID)
115 local RetVal = nil;
116 local s = pcall(function()
117 local Status, Data = HttpService.GetAsync(GetURL('/products/give/'..Product..'/'..ID));
118 RetVal = Data.dm;
119 end)
120 return RetVal
121end;
122Module.RevokeUser = function(Product, ID)
123 local RetVal = nil;
124 local s = pcall(function()
125 local Status, Data = HttpService.GetAsync(GetURL('/products/revoke/'..Product..'/'..ID));
126 end)
127 return RetVal
128end;
129return Module;