@ -157,8 +157,7 @@ Usage
dinv pass <pass I D > < # of seconds>
dinv pass <pass I D > < # of seconds>
Plugin info
Plugin info
dinv version
dinv version [check | update] <confirm >
dinv update confirm
dinv help <command >
dinv help <command >
@ -348,7 +347,7 @@ Feature Wishlist
<alias
<alias
script="inv.cli.version.fn"
script="inv.cli.version.fn"
match="^[ ]*dinv[ ]+version. *$"
match="^[ ]*dinv[ ]+version[ ]*(check|update[ ]+confirm)?[ ] *$"
enabled="y"
enabled="y"
regexp="y"
regexp="y"
send_to="12"
send_to="12"
@ -568,16 +567,6 @@ Feature Wishlist
>
>
</alias>
</alias>
<alias
script="inv.cli.update.fn"
match="^[ ]*dinv[ ]+update[ ]+confirm[ ]*$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
</alias>
<alias
<alias
script="inv.cli.debug.fn"
script="inv.cli.debug.fn"
match="^[ ]*dinv[ ]+debug(.*)$"
match="^[ ]*dinv[ ]+debug(.*)$"
@ -845,6 +834,13 @@ function setPending(msg)
elseif (string.lower(msg) == "quit") then
elseif (string.lower(msg) == "quit") then
dbot.execute.quitIsPending = true
dbot.execute.quitIsPending = true
-- Add a trigger to clear the quitIsPending flag if the quit is cancelled
AddTriggerEx("drlQuitCancelConfirmationTrigger",
"^These items will be lost if you quit. Use .quit quit. if you are sure.$",
"dbot.execute.quitIsPending = false",
drlTriggerFlagsBaseline + trigger_flag.OneShot,
custom_colour.NoChange, 0, "", "", sendto.script, 0)
elseif (string.lower(msg) == "note write") then
elseif (string.lower(msg) == "note write") then
dbot.execute.noteIsPending = true
dbot.execute.noteIsPending = true
@ -1221,8 +1217,8 @@ end -- inv.version.get
function inv.version.display()
function inv.version.display()
dbot.print("\n @y" .. pluginNameAbbr .. " Aardwolf Plugin\n" ..
dbot.print("\n @y" .. pluginNameAbbr .. " Aardwolf Plugin\n" ..
"-----------------------@w")
"------------------------- @w")
dbot.print("@WPlugin Version: @G" ..
dbot.print("@WPlugin Version: @G" ..
inv.version.table.pluginVer.major .. "." ..
inv.version.table.pluginVer.major .. "." ..
inv.version.table.pluginVer.minor .. "@w")
inv.version.table.pluginVer.minor .. "@w")
@ -1479,9 +1475,6 @@ end -- inv.config.new
-- inv.cli.version.fn(name, line, wildcards)
-- inv.cli.version.fn(name, line, wildcards)
-- inv.cli.version.usage()
-- inv.cli.version.usage()
-- inv.cli.version.examples()
-- inv.cli.version.examples()
-- inv.cli.update.fn(name, line, wildcards)
-- inv.cli.update.usage()
-- inv.cli.update.examples()
-- inv.cli.reload.fn(name, line, wildcards)
-- inv.cli.reload.fn(name, line, wildcards)
-- inv.cli.reload.usage()
-- inv.cli.reload.usage()
-- inv.cli.reload.examples()
-- inv.cli.reload.examples()
@ -1535,7 +1528,6 @@ function inv.cli.fullUsage()
dbot.print("\n@C Plugin info@w")
dbot.print("\n@C Plugin info@w")
inv.cli.version.usage()
inv.cli.version.usage()
inv.cli.update.usage()
inv.cli.help.usage()
inv.cli.help.usage()
end -- inv.cli.fullUsage
end -- inv.cli.fullUsage
@ -4391,21 +4383,38 @@ end -- inv.cli.organize.examples
inv.cli.version = {}
inv.cli.version = {}
function inv.cli.version.fn(name, line, wildcards)
function inv.cli.version.fn(name, line, wildcards)
local command = wildcards[1] or ""
local retval = DRL_RET_SUCCESS
dbot.debug("CLI: command=\"" .. command .. "\"")
if (not inv.init.initializedActive) then
if (not inv.init.initializedActive) then
dbot.info("Skipping version request: plugin is not yet initialized (are you AFK or sleeping?)")
dbot.info("Skipping version request: plugin is not yet initialized (are you AFK or sleeping?)")
return inv.tags.stop(invTagsVersion, line, DRL_RET_UNINITIALIZED)
return inv.tags.stop(invTagsVersion, line, DRL_RET_UNINITIALIZED)
elseif (dbot.gmcp.getState() ~= dbot.stateActive) then
elseif (dbot.gmcp.getState() ~= dbot.stateActive) then
dbot.info("Skipping version request: character is not in the active state")
dbot.info("Skipping version request: character is not in the active state")
return inv.tags.stop(invTagsVersion, line, DRL_RET_NOT_ACTIVE)
return inv.tags.stop(invTagsVersion, line, DRL_RET_NOT_ACTIVE)
elseif (command == "") then
retval = inv.version.display()
return inv.tags.stop(invTagsVersion, line, retval)
elseif (command == "check") then
retval = dbot.update.version(drlDbotUpdateCheck, line)
else
dbot.info("Updating plugin: Please do not enter anything until the update completes")
retval = dbot.update.version(drlDbotUpdateInstall, line)
end -- if
end -- if
local retval = inv.version.display()
return retval
inv.tags.stop(invTagsVersion, line, retval)
end -- inv.cli.version.fn
end -- inv.cli.version.fn
function inv.cli.version.usage()
function inv.cli.version.usage()
dbot.print("@W " .. pluginNameCmd .. " version@w")
dbot.print("@W " .. pluginNameCmd .. " version @G[check | update] @Y<confirm > @w")
end -- inv.cli.version.usage
end -- inv.cli.version.usage
@ -4414,37 +4423,25 @@ function inv.cli.version.examples()
inv.cli.version.usage()
inv.cli.version.usage()
dbot.print(
dbot.print(
[[@W
[[@W
You seriously want to read a helpfile about how to get this plugin's version information?!?
The version mode without arguments will tell you the version information for the
Come on peeps, just type "@Gdinv version@W". It's not that hard. :P
plugin and format versions for components of the plugin. You can also check if
]])
you have the latest official plugin release and update to that release if you are
not yet running the latest and greatest version of the plugin.
end -- inv.cli.version.examples
inv.cli.update = {}
function inv.cli.update.fn(name, line, wildcards)
dbot.info("Updating plugin: Please do not enter anything until the update completes")
return dbot.update()
end -- inv.cli.update.fn
function inv.cli.update.usage()
Examples:
dbot.print("@W " .. pluginNameCmd .. " update confirm")
1) Display your current version information
end -- inv.cli.update.usage
"@Gdinv version@W"
2) Compare your plugin version to the version of the latest published release
"@Gdinv version check@W"
function inv.cli.update.examples()
3) Check if you have the latest plugin version. If your version is not the
dbot.print("@W\nUsage:\n")
latest and greatest, download the latest release and install it. You do
inv.cli.update.usage()
not need to log out or restart mush.
dbot.print(
"@Gdinv version update confirm@W"
[[@W
This will compare your version of the plugin with the latest stable release.
If your plugin is out of date, the plugin will download the latest version of
itself and load it.
]])
]])
end -- inv.cli.update .examples
end -- inv.cli.version.examples
inv.cli.help = {}
inv.cli.help = {}
@ -7382,7 +7379,7 @@ function inv.items.searchCR(queryString)
-- If we are in a query and we are at the value location (it goes key then value), then save the value
-- If we are in a query and we are at the value location (it goes key then value), then save the value
else
else
value = element
value = element
dbot.debug("key=\"" .. key .. "\", value=\"" .. value .. "\"")
-- dbot.debug("key=\"" .. key .. "\", value=\"" .. value .. "\"")
-- If we are inverting the key field (e.g., "level" vs. "~level") then we want to temporarily
-- If we are inverting the key field (e.g., "level" vs. "~level") then we want to temporarily
-- strip the "~" from the key, process the remaining key, and then add the "~" back before we
-- strip the "~" from the key, process the remaining key, and then add the "~" back before we
@ -16069,39 +16066,85 @@ end -- dbot.reload
-- Note: This code is derived from a plugin written by Arcidayne. Thanks Arcidayne!
-- Note: This code is derived from a plugin written by Arcidayne. Thanks Arcidayne!
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
function dbot.update()
dbot.update = {}
dbot.update.url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.xml"
dbot.update.protocol = "HTTPS"
dbot.update.pkg = nil
drlDbotUpdateCheck = "check"
drlDbotUpdateInstall = "install"
function dbot.update.version(mode, endTag)
local retval = DRL_RET_SUCCESS
local retval = DRL_RET_SUCCESS
local url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.xml"
if (mode == nil) or ((mode ~= drlDbotUpdateCheck) and (mode ~= drlDbotUpdateInstall)) then
dbot.warn("dbot.update.version: Missing or invalid mode parameter")
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_INVALID_PARAM)
end -- if
if (dbot.update.pkg ~= nil) then
dbot.info("Skipping update request: another update request is in progress")
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_BUSY)
end -- if
-- Pull in the async package if it exists
local asyncOk, async = pcall (require, "async")
local asyncOk, async = pcall (require, "async")
if (not asyncOk) or (async == nil) then
dbot.warn("dbot.update.version: Failed to find \"async\" package, skipping update request")
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_UNSUPPORTED)
end -- if
dbot.update.pkg = {}
dbot.update.pkg.mode = mode
dbot.update.pkg.endTag = endTag
if asyncOk then
-- Make a request to grab the latest plugin file. Newer versions of mush have nice async
async.doAsyncRemoteRequest(url, dbot.updateRaw, "HTTPS")
-- capabilities and we use that if possible. Otherwise, we fall back to an old-style request.
-- Both methods of making the request will call dbot.update.callback upon completion.
if (async.doAsyncRemoveRequest ~= nil) then
async.doAsyncRemoteRequest(dbot.update.url, dbot.update.callback, dbot.update.protocol)
else
else
dbot.warn("dbot.update: Failed to retrieve plugin update")
wait.make(dbot.updateCR) -- Fall back to a co-routine running the old-style async code
retval = DRL_RET_INTERNAL_ERROR
end
end
return retval
return retval
end -- dbot.update
end -- dbot.update
function dbot.updateRaw(retval, page, status, headers, fullStatus, requestUrl)
-- Scan the file we just (hopefully) downloaded and check the file's version. If the user
local currentVersion = GetPluginInfo(GetPluginID(), 19) or 0
-- requested a version check, we report the current and latest available versions. If the
-- user requested an installation of the latest plugin, do the upgrade if everything looks
-- sane.
function dbot.update.callback(retval, page, status, headers, fullStatus, requestUrl)
local retval = DRL_RET_SUCCESS
if (dbot.update.pkg == nil) or (dbot.update.pkg.mode == nil) then
dbot.warn("dbot.update.callback: Missing or invalid update package detected")
return inv.tags.stop(invTagsVersion, "end tag is nil", DRL_RET_INVALID_PARAM)
end -- if
local endTag = dbot.update.pkg.endTag
if (status ~= 200) then
if (status ~= 200) then
dbot.warn("dbot.updateRaw: Failed to retrieve remote plugin version")
dbot.warn("dbot.update.callback: Failed to retrieve remote plugin information")
retval = DRL_RET_INTERNAL_ERROR
else
else
local currentVersion = GetPluginInfo(GetPluginID(), 19) or 0
local remoteVersion = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"')) or 0
local remoteVersion = tonumber(string.match(page, '%s%s+version="([0-9%.]+)"')) or 0
if (remoteVersion == currentVersion) then
if (remoteVersion == currentVersion) then
dbot.info("Your plugin is up-to-date at version " .. currentVersion)
dbot.info("You are running the most recent plugin (v" .. currentVersion .. ")" )
elseif (remoteVersion < currentVersion ) t h e n
elseif (remoteVersion < currentVersion ) t h e n
dbot.warn("Your current plugin (v" .. currentVersion .. ") is reporting that it " ..
dbot.warn("Your current plugin (v" .. currentVersion .. ") " ..
"is newer than the latest official release (v" .. remoteVersion .. ")")
"is newer than the latest official release (v" .. remoteVersion .. ")")
retval = DRL_RET_VER_MISMATCH
else
elseif (dbot.update.pkg.mode == drlDbotUpdateCheck) then
dbot.info("You are running v" .. currentVersion .. ", latest version is v" .. remoteVersion)
elseif (dbot.update.pkg.mode == drlDbotUpdateInstall) then
dbot.info("Updating plugin from version " .. currentVersion .. " to version " .. remoteVersion)
dbot.info("Updating plugin from version " .. currentVersion .. " to version " .. remoteVersion)
local pluginFile = GetPluginInfo(GetPluginID(), 6)
local pluginFile = GetPluginInfo(GetPluginID(), 6)
@ -16109,11 +16152,49 @@ function dbot.updateRaw(retval, page, status, headers, fullStatus, requestUrl)
file:write(page)
file:write(page)
file:close()
file:close()
dbot.reload()
dbot.reload()
else
dbot.error("dbot.update.callback: Detected invalid mode \"@R" .. (dbot.update.pkg.mode or "nil") ..
"@W\"")
end -- if
end -- if
dbot.update.pkg = nil
return inv.tags.stop(invTagsVersion, endTag, retval)
end -- dbot.update.callback
function dbot.updateCR()
local urlThread = async.request(dbot.update.url, dbot.update.protocol)
local updateRet, page, status, headers, fullStatus = -1, nil, -1, nil, nil, dbot.update.url
if (urlThread == nil) then
dbot.warn("dbot.updateCR: Failed to create thread requesting update")
else
local timeout = 10
local totTime = 0
while (urlThread:alive()) do
if (totTime > timeout) then
retval = DRL_RET_TIMEOUT
break
end -- if
wait.time(drlSpinnerPeriodDefault)
totTime = totTime + drlSpinnerPeriodDefault
end -- while
if (retval ~= DRL_RET_SUCCESS) then
retval, page, status, headers, full_status = urlThread:join()
end -- if
end -- if
end -- if
end -- if
end -- dbot.updateRaw
dbot.update.callback(updateRet, page, status, headers, fullStatus)
end -- dbot.updateCR
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
@ -16433,6 +16514,7 @@ DRL_RET_INTERNAL_ERROR = -8
DRL_RET_UNIDENTIFIED = -9
DRL_RET_UNIDENTIFIED = -9
DRL_RET_NOT_ACTIVE = -10
DRL_RET_NOT_ACTIVE = -10
DRL_RET_IN_COMBAT = -11
DRL_RET_IN_COMBAT = -11
DRL_RET_VER_MISMATCH = -12
dbot.retval = {}
dbot.retval = {}
@ -16449,6 +16531,7 @@ dbot.retval.table[DRL_RET_INTERNAL_ERROR] = "internal error"
dbot.retval.table[DRL_RET_UNIDENTIFIED] = "item is not yet identified"
dbot.retval.table[DRL_RET_UNIDENTIFIED] = "item is not yet identified"
dbot.retval.table[DRL_RET_NOT_ACTIVE] = "you are not in the active state"
dbot.retval.table[DRL_RET_NOT_ACTIVE] = "you are not in the active state"
dbot.retval.table[DRL_RET_IN_COMBAT] = "you are in combat!"
dbot.retval.table[DRL_RET_IN_COMBAT] = "you are in combat!"
dbot.retval.table[DRL_RET_VER_MISMATCH] = "version mismatch"
function dbot.retval.getString(retval)
function dbot.retval.getString(retval)