-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupdate-check.lua
More file actions
49 lines (41 loc) · 1.65 KB
/
update-check.lua
File metadata and controls
49 lines (41 loc) · 1.65 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
MapExporter.updateCheck = MapExporter.updateCheck or {
file = MapExporter.dir .. "commits",
url = "https://api.github.com/repos/Delwing/mudlet-map-reader/commits",
storeKey = "MapExporter"
}
function MapExporter.updateCheck:checkNewVersion()
downloadFile(self.file, self.url)
registerAnonymousEventHandler("sysDownloadDone", function(_, file)
self:handle(file)
end, true)
coroutine.yield(self.coroutine)
end
function MapExporter.updateCheck:handle(fileName)
if fileName ~= self.file then
return
end
local mapExporterState = scripts.state_store:get(self.storeKey) or {}
local file, s, contents = io.open(self.file)
if file then
contents = yajl.to_value(file:read("*a"))
io.close(file)
os.remove(self.file)
local sha = contents[1].sha
if mapExporterState.sha ~= nil and sha ~= mapExporterState.sha then
echo("\n")
cecho("<CadetBlue>(skrypty)<tomato>: Plugin mudlet-map-reader posiad nowa aktualizacje. Kliknij ")
cechoLink("<green>tutaj", [[MapExporter.updateCheck:update()]], "Aktualizuj", true)
cecho(" <tomato>aby pobrac")
echo("\n")
end
mapExporterState.sha = sha
scripts.state_store:set(self.storeKey, mapExporterState)
end
end
function MapExporter.updateCheck:update()
scripts.plugins_installer:install_from_url("https://codeload.github.com/Delwing/mudlet-map-reader/zip/master")
end
MapExporter.updateCheck.coroutine = coroutine.create(function()
MapExporter.updateCheck:checkNewVersion()
end)
tempTimer(5, function() coroutine.resume(MapExporter.updateCheck.coroutine) end)