Repository navigation
Expand file tree
/
Copy pathinit.lua
More file actions
126 lines (104 loc) · 3.91 KB
/
Copy pathinit.lua
File metadata and controls
126 lines (104 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--!nocheck
local Licence = { }
Licence.Key = script_key or [[KEY-HERE]]
local cloneref:(<T>(T) -> T) | (<a>(a) -> a) = cloneref or function(Reference: any) return Reference end
local isfile: (string) -> boolean = isfile or function(File: string): boolean
local Success: boolean, Result = pcall(function()
return readfile(File)
end)
return Success and Result
end
local HttpService: HttpService = cloneref(game:GetService("HttpService"))
local EncodingService: EncodingService = cloneref(game:GetService("EncodingService"))
type ContentData = {
sha: string,
content: string,
encoding: string,
path: string
}
type Contents = {files: {ContentData}}
type GotContents = {Success: boolean, Data: Contents}
local CryptHash: (Content: string, Algorithm: string) -> string = (crypt and crypt.hash)
if not CryptHash then
local HashLibrary = loadstring(game:HttpGet('https://api.catvape.dev/download/src/libraries/hash.lua'))()
CryptHash = HashLibrary.sha1
end
local function GetGithubContents(Path: string): GotContents
local Success: boolean, Result: string = pcall(function()
return game:HttpGet("https://api.catvape.dev/contents/src")
end)
if Success then
local SuccessfulJSONDecode, JSON = pcall(HttpService.JSONDecode, HttpService, Result)
return {
Success = SuccessfulJSONDecode,
Data = JSON
}
end
return {
Success = false,
Data = Result
}
end
local function DownloadAsset(FileData: ContentData): ()
if FileData.encoding == "base64" then
FileData.content = buffer.tostring(EncodingService:Base64Decode(buffer.fromstring(FileData.content)))
end
writefile(`catsix/{FileData.path:gsub("src/", "")}`, FileData.content)
end
local function GetCurrentSHA(Path: string): string
local FilePath: string = `catsix/{Path:gsub("src/", "")}`
local FileContents = (isfile(FilePath) and readfile(FilePath))
if FileContents then
return CryptHash(`blob {#FileContents}\0{FileContents}`, "sha1")
end
return ""
end
local function DownloadAssets(Contents: GotContents, NewUser: boolean): boolean
if Contents.Success then
for i: number, v: {content: string, path: string?, sha: string} in Contents.Data.files do
if not NewUser and v.path:find("/profiles/") then
continue
end
local CurrentSHA: string = GetCurrentSHA(v.path)
if CurrentSHA ~= v.sha then
DownloadAsset(v)
end
end
end
return Contents.Success
end
for _, Folder: string in {'catsix', 'catsix/games', 'catsix/profiles', 'catsix/assets', 'catsix/libraries', 'catsix/guis'} do
if not isfolder(Folder) then
makefolder(Folder)
end
end
if not shared.VapeDeveloper then
local Commit: string? = Licence.Commit
if not Commit then
local Success: boolean, Result: string = pcall(function()
return game:HttpGet('https://api.catvape.dev/commit')
end)
if Success then
local SuccessJSON, JSON = pcall(HttpService.JSONDecode, HttpService, Result)
if SuccessJSON then
Commit = JSON.sha
end
end
end
local NewUser: boolean = not isfile('catsix/profiles/commit.txt') or #listfiles('catsix') < 7
if NewUser or readfile('catsix/profiles/commit.txt') ~= Commit then
local Success: boolean = DownloadAssets(GetGithubContents(), NewUser)
if Success and Commit then
warn(`Successfully updated to {Commit}`)
writefile('catsix/profiles/commit.txt', Commit)
else
warn(`Failed to update to {Commit}`)
end
end
end
if not pcall(function()
return loadstring(readfile('catsix/main.lua'), 'main')(Licence)
end) then
writefile("catsix/profiles/commit.txt", "main")
loadstring(game:HttpGet(`https://api.catvape.dev/script?key={Licence.Key}`))(Licence)
end