Updater file

Contrast_Picker
Arcidayne 9 years ago
parent a884365b03
commit 3fa4204eba

@ -7,7 +7,7 @@
<muclient> <muclient>
<plugin <plugin
name="Updater" name="zzUpdaterzz"
author="Arcidayne" author="Arcidayne"
id="dff6da0f0c8bd7605fe6a5f4" id="dff6da0f0c8bd7605fe6a5f4"
language="Lua" language="Lua"
@ -26,48 +26,31 @@
<script> <script>
<![CDATA[ <![CDATA[
function UpdatePlugin(pid, pfile, pversion, raw) function update_plugin (pid, pfile, pversion, raw)
async_ok, async = pcall (require, "async") async_ok, async = pcall (require, "async")
ColourNote("white", "blue", pfile)
if async_ok then if async_ok then
raw_return = async.request(raw, "HTTPS") plugin_page = async.request(raw, "HTTPS")
end end
retval, page, status, headers, full_status = raw_return:join() retval, page, status, headers, full_status = plugin_page:join()
raw_return = nil plugin_page = nil
if status == 200 then if status == 200 then
raw_version = string.match(page, '%s%s+version="([0-9%.]+)"') raw_version = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"')) -- Pulls version number
print("Raw version: " .. raw_version)
print("Plugin version: " .. pversion)
end end
if tonumber(raw_version) == tonumber(pversion) then if raw_version == pversion then
ColourNote("white", "blue", "You currently have the latest version!") ColourNote("white", "blue", GetPluginInfo(pid, 1) .. " is up-to-date.")
elseif tonumber(raw_version) > tonumber(pversion) then elseif raw_version > pversion then
ColourNote("white", "blue", "Updating from " .. pversion .. " to " .. raw_version .. "!") ColourNote("white", "blue", "Updating from version " .. pversion .. " to " .. raw_version .. ". Do not touch anything.")
UnloadPlugin(pid)
local file = io.open(pfile, "w") local file = io.open(pfile, "w")
file:write(page) file:write(page)
file:close() file:close()
--DoAfterSpecial(3, "LoadPlugin(" .. pid .. ")", 12)
end end
raw_version = nil raw_version = nil
CallPlugin('e6cd5104e883a1dd9c4362e2', "remove_update", GetPluginID())
--UnloadPlugin(GetPluginID())
--os.remove(GetPluginInfo(GetPluginID(), 6))
end
function OnPluginInstall()
CallPlugin('e6cd5104e883a1dd9c4362e2',"update_now")
end end
]]> ]]>
</script> </script>
</muclient> </muclient>

Loading…
Cancel
Save