Advertisement
Kekulator

Untitled

Sep 28th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.20 KB | None | 0 0
  1. local chatUI = script.CustomChat.CustomChat:Clone()
  2. local chatEvent = script.CustomChat.Chatted:Clone()
  3. local chatMain = script.CustomChat.ChatHandler:Clone()
  4.  
  5. local children = script:GetChildren()
  6. script = Instance.new("ModuleScript")
  7. for _, child in pairs(children) do
  8.     child.Parent = script
  9. end
  10. script = nil
  11.  
  12.  
  13. local USERNAME = nil
  14. local PASSWORD = nil
  15. local APIKEY = nil
  16.  
  17.  
  18. local module = {}
  19.  
  20. local http =game:GetService("HttpService")
  21.  
  22. local function Enc(tab)
  23.    
  24.         local dd;
  25.     local suc, mes = pcall(function()
  26. dd = http:JSONEncode(tab)
  27.     end)
  28.     if suc == true then
  29. return dd
  30.  
  31.     else
  32.        
  33.         return mes
  34.         end
  35.    
  36. end
  37.  
  38.  
  39. local function Dec(tab)
  40.     local dd;
  41.     local suc, mes = pcall(function()
  42. dd = http:JSONDecode(tab)
  43.     end)
  44.     if suc == true then
  45. return dd
  46.  
  47.     else
  48.        
  49.         return mes
  50.         end
  51. end
  52.  
  53.  
  54. local getLINK = "https://api.kekulator.com/getdata"
  55. local saveLINK = "https://api.kekulator.com/savedata"
  56.  
  57.  
  58. function GetData(AuthTab)
  59.     local gotten;
  60.    
  61.     if (AuthTab["Username"]) and AuthTab["Password"] and AuthTab["API_KEY"] and AuthTab["Save_Id"] then
  62.        
  63.        
  64.         local toSend = Enc(AuthTab)
  65.        
  66.         if (toSend == nil) then
  67.             return {["status"] = "error", ["info"] = "Went_Wrong", ["data"] = nil}
  68.         end
  69.        
  70.         if (toSend == "Can't parse JSON") then
  71.            
  72.             return {["status"] = "error", ["info"] = "No_JSON", ["data"] = nil}
  73.         end
  74.        
  75.         local get = http:PostAsync(getLINK, toSend)
  76.        
  77.        
  78.         local newtab = Dec(get)
  79.        
  80.         if (newtab == "Can't parse JSON") then
  81.            
  82.             return {["status"] = "error", ["info"] = "No_JSON", ["data"] = nil}
  83.         end
  84.        
  85.         gotten = {["status"] = "success", ["info"] = "Succesfully received the data", ["data"] = newtab}
  86.        
  87.     else
  88.        
  89.         gotten = {["status"] = "error", ["info"] = "Missing_Credentials", ["data"] = nil}
  90.     end
  91.    
  92.     return gotten;
  93.    
  94.    
  95.    
  96. end
  97.  
  98.  
  99.  
  100.  
  101. function SaveData(AuthTab)
  102.     local gotten;
  103.    
  104.     if (AuthTab["Username"]) and AuthTab["Password"] and AuthTab["API_KEY"] and AuthTab["Save_Id"] then
  105.         local toSend = Enc(AuthTab)
  106.        
  107.        
  108.         local toSave = http:PostAsync(saveLINK, toSend)
  109.        
  110.        
  111.         gotten = toSave
  112.        
  113.         if gotten == "MissingAll" then
  114.             return {["info"] = "You have to provide all required assets!", ["status"] = "error"}
  115.         end
  116.        
  117.        
  118.         if gotten == "No_Exist" then
  119.             return {["info"] = "The username you provided doesn't belong to any account!", ["status"] = "error"}
  120.         end
  121.        
  122.         if gotten == "Banned" then
  123.             return {["info"] = "This account is banned from the website!", ["status"] = "error"}
  124.         end
  125.        
  126.        
  127.         if (gotten == "No_Data") then
  128.         --print("Sorry, we couldn't find your data. It seems you haven't saved to us before,or you haven't initiated your disk. Please do this first!")
  129.         return {["data"] = nil, ["info"] = "You need to save or initiate first!", ["status"] = "error"}
  130.     elseif (gotten == "Not_Initiated") then
  131.         --print("You need to initiate, so we can allocate space for your game!")
  132.         return {["data"] = nil, ["info"] = "You need to initiate first", ["status"] = "error"}
  133.     end
  134.    
  135.     if (gotten == "Wrong_Credentials") then
  136.         return {["data"] = nil, ["info"] = "Wrong credentials", ["status"] = "error"}
  137.     end
  138.    
  139.     if (gotten == "Wrong_APIKEY") then
  140.         return {["info"] = "The API key you provided is invalid!", ["status"] = "error"}
  141.     end
  142.    
  143.     if gotten == "Success" then
  144.         return {["info"] = "Succesfully saved data", ["status"] = "success"}
  145.     end
  146.     else
  147.        
  148.         gotten = {["status"] = "error", ["info"] = "Missing_Credentials", ["data"] = nil}
  149.         return gotten
  150.     end
  151. end
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. function GetGroupOwner(id)
  160.     local returned = nil;
  161.     local suc,msg = pcall(function()
  162.     local AuthTab = {}
  163.     AuthTab["GroupId"] = tostring(id);
  164.    
  165.     local var = Enc(AuthTab)
  166.    
  167.    
  168.     local getGroupInfo = http:PostAsync("https://api.kekulator.com/groupinfo", var)
  169.    
  170.     local getDecd = Dec(getGroupInfo)
  171.    
  172.     if getDecd ~= nil then
  173.         returned = getDecd["Owner"]
  174.     else
  175.         returned = nil;
  176.     end
  177.    
  178.     end)
  179.    
  180.    
  181.    
  182.    
  183.    
  184.    
  185.    
  186.    
  187.    
  188.     return returned
  189.    
  190.    
  191.    
  192. end
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. function module:Init(usn, psw, key)
  202.    
  203.    
  204.     USERNAME = usn
  205.     PASSWORD = psw
  206.     APIKEY = key
  207. end
  208.  
  209. function module:GetData(id)
  210.    
  211.     local var;
  212.    
  213.     local AuthTab = {}
  214.    
  215.     AuthTab["Username"] = USERNAME
  216.     AuthTab["Password"] = PASSWORD
  217.     AuthTab["API_KEY"] = APIKEY
  218.     AuthTab["Save_Id"] = tostring(id);
  219.    
  220.     var = GetData(AuthTab)
  221.    
  222.     local toRet = var or {["status"] = "error", ["info"] = "Went_Wrong", ["data"] = nil}
  223.     return toRet
  224. end
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231. function module:SaveData(id, data)
  232.     local var;
  233.    
  234.     local AuthTab = {}
  235.    
  236.     AuthTab["Username"] = USERNAME
  237.     AuthTab["Password"] = PASSWORD
  238.     AuthTab["API_KEY"] = APIKEY
  239.     AuthTab["Save_Id"] = id;
  240.     AuthTab["Data"] = data;
  241.    
  242.    
  243.     var = SaveData(AuthTab)
  244.    
  245.     local toRet = var or {["status"] = "error", ["info"] = "Went_Wrong"}
  246.     return toRet
  247.    
  248. end
  249.  
  250. function module:MakeChat()
  251.     if game:GetService("ReplicatedStorage"):FindFirstChild("Chatted") == nil then
  252.         local eve = chatEvent:Clone()
  253.         eve.Parent = game:GetService("ReplicatedStorage")
  254.        
  255.     end
  256.     if game:GetService("ServerScriptService"):FindFirstChild("ChatHandler") == nil then
  257.         local scr = chatMain:Clone()
  258.         scr.Parent = game:GetService("ServerScriptService")
  259.         scr.Disabled = false
  260.     end
  261.         for i,v in pairs(game.Players:GetPlayers()) do
  262.             if v.PlayerGui:FindFirstChild("CustomChat") == nil then
  263.                 local ui = chatUI:Clone()
  264.                 ui.Parent = v.PlayerGui
  265.                 ui.LocalScript.Disabled = false
  266.                
  267.             end
  268.         end
  269.        
  270.         game.Players.PlayerAdded:Connect(function(Player)
  271.             if Player.PlayerGui:FindFirstChild("CustomChat") == nil then
  272.                 local ui = chatUI:Clone()
  273.                 ui.Parent = Player.PlayerGui
  274.                 ui.LocalScript.Disabled = false
  275.                
  276.             end
  277.         end)
  278. end
  279.  
  280.  
  281.  
  282. function module:GetGroupOwner(id)
  283.     local owner = GetGroupOwner(id);
  284.     if owner == nil then
  285.         return "error"
  286.     end
  287.    
  288.     return owner;
  289.    
  290. end
  291.  
  292.  
  293.  
  294. function module:CheckAccount(username, password, key)
  295.     local getAccount = "https://api.kekulator.com/checkaccount"
  296.     local t = {}
  297.     t["Username"] = username
  298.     t["Password"] = password
  299.     t["API_KEY"] = key;
  300.    
  301.    
  302.     local enus = Enc(t)
  303.     local check = http:PostAsync(getAccount, enus)
  304.    
  305.     print(check)
  306. end
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313. function module:GetUserFriends(idofuser)
  314.     local getFriends = "https://api.kekulator.com/getuserfriends"
  315.     local t = {}
  316.    
  317. end
  318.  
  319.  
  320.  
  321.  
  322.  
  323. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement