|
|
@ -669,6 +669,59 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
-- Update
|
|
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Update.initialize()
|
|
|
|
|
|
|
|
AddAlias("alias_update",
|
|
|
|
|
|
|
|
"^ac\\s+update$", "",
|
|
|
|
|
|
|
|
alias_flag.Enabled + alias_flag.IgnoreAliasCase + alias_flag.RegularExpression + alias_flag.Temporary,
|
|
|
|
|
|
|
|
"Update.update"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update.URL = "https://raw.githubusercontent.com/AreiaAard/Areia_Consider/main/areia_consider.xml"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Update.update()
|
|
|
|
|
|
|
|
async_ok, async = pcall (require, "async")
|
|
|
|
|
|
|
|
if async_ok then
|
|
|
|
|
|
|
|
plugin_page = async.doAsyncRemoteRequest(Update.URL, Update.raw_get, "HTTPS")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Utility.plugin_msg("Error. Update failed.")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Update.raw_get(retval, page, status, headers, full_status, request_url)
|
|
|
|
|
|
|
|
local PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
|
|
|
|
|
|
|
|
local PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
|
|
|
|
|
|
|
|
local raw_version = -1
|
|
|
|
|
|
|
|
if (status == 200) then
|
|
|
|
|
|
|
|
raw_version = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"'))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if (raw_version == PLUGIN_VERSION) then
|
|
|
|
|
|
|
|
Utility.plugin_msg(string.format("@Y%s @wis up-to-date with the current version.", PLUGIN_NAME))
|
|
|
|
|
|
|
|
elseif (raw_version > PLUGIN_VERSION) then
|
|
|
|
|
|
|
|
Utility.plugin_msg(string.format("Updating @Y%s @wfrom v%s to v%s.", PLUGIN_NAME, PLUGIN_VERSION, raw_version))
|
|
|
|
|
|
|
|
Utility.print(" Please do not touch anything.")
|
|
|
|
|
|
|
|
local file = io.open(GetPluginInfo(GetPluginID(), 6), "w")
|
|
|
|
|
|
|
|
file:write(page)
|
|
|
|
|
|
|
|
file:close()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if (GetAlphaOption("script_prefix") == "") then
|
|
|
|
|
|
|
|
SetAlphaOption("script_prefix", "\\\\\\")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
Execute(string.format(
|
|
|
|
|
|
|
|
"%sDoAfterSpecial(1, \"ReloadPlugin('%s')\", sendto.script)",
|
|
|
|
|
|
|
|
GetAlphaOption("script_prefix"), GetPluginID()
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
Utility.plugin_msg("Update completed.")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
--------------------------------------------------
|
|
|
|
-- Utility
|
|
|
|
-- Utility
|
|
|
|
--------------------------------------------------
|
|
|
|
--------------------------------------------------
|
|
|
|