parent
ff4b276685
commit
5fc832b68f
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE muclient>
|
||||
<!-- Saved on Monday, April 29, 2024, 11:10 AM -->
|
||||
<!-- MuClient version 5.07-pre -->
|
||||
|
||||
<!-- Plugin "Keycheck" generated by Plugin Wizard -->
|
||||
|
||||
<muclient>
|
||||
<plugin
|
||||
name="Keycheck"
|
||||
author="Crowley"
|
||||
id="233640c875089ec10c96199d"
|
||||
language="Lua"
|
||||
purpose="Displays expiring keys"
|
||||
save_state="y"
|
||||
date_written="2024-04-29 11:09:48"
|
||||
requires="5.07"
|
||||
version="1.0"
|
||||
>
|
||||
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Triggers -->
|
||||
|
||||
<triggers>
|
||||
<trigger
|
||||
enabled="n"
|
||||
group="KeyRingList"
|
||||
match="{keyring}"
|
||||
name="keyStart"
|
||||
omit_from_output="y"
|
||||
script="keyringStart"
|
||||
send_to="12"
|
||||
sequence="100"
|
||||
>
|
||||
</trigger>
|
||||
<trigger
|
||||
group="KeyRingList"
|
||||
match="{/keyring}"
|
||||
name="disableKeys"
|
||||
omit_from_output="y"
|
||||
sequence="100"
|
||||
>
|
||||
</trigger>
|
||||
<trigger
|
||||
group="KeyRingList"
|
||||
match="^(.*)$"
|
||||
name="captureKeys"
|
||||
omit_from_output="y"
|
||||
regexp="y"
|
||||
script="processKey"
|
||||
send_to="12"
|
||||
sequence="100"
|
||||
>
|
||||
</trigger>
|
||||
</triggers>
|
||||
|
||||
<!-- Aliases -->
|
||||
<aliases>
|
||||
<alias
|
||||
enabled="y"
|
||||
group="KeyRingList"
|
||||
match="keycheck"
|
||||
script="keyCheck"
|
||||
sequence="100">
|
||||
</alias>
|
||||
</aliases>
|
||||
|
||||
<!-- Script -->
|
||||
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
dofile(GetInfo(60) .. "aardwolf_colors.lua")
|
||||
require 'themed_miniwindows'
|
||||
require 'tprint'
|
||||
|
||||
local keyringList = {}
|
||||
local fName, fSize = GetAlphaOption("output_font_name"), GetOption("output_font_height")
|
||||
|
||||
|
||||
local keyHeader = "@wKey ID Key Name Expiry@w"
|
||||
local keyBreak = "@G------------ ---------------------------------------- --------------------@w"
|
||||
|
||||
local keyString = "%-12d %s%s"
|
||||
|
||||
function convertTime(totalSeconds)
|
||||
local secondsInADay = 86400
|
||||
local secondsInAnHour = 3600
|
||||
local secondsInAMinute = 60
|
||||
|
||||
local days = math.floor(totalSeconds / secondsInADay)
|
||||
local hours = math.floor((totalSeconds % secondsInADay) / secondsInAnHour)
|
||||
local minutes = math.floor((totalSeconds % secondsInAnHour) / secondsInAMinute)
|
||||
local seconds = totalSeconds % secondsInAMinute
|
||||
|
||||
local dayLabel = days == 1 and "day" or "days"
|
||||
return string.format("%2d", days) .. " " .. dayLabel .. " and " .. string.format("%02d:%02d:%02d", hours, minutes, seconds)
|
||||
end
|
||||
|
||||
function keyCheck()
|
||||
EnableTrigger("keyStart")
|
||||
Send("keyring data")
|
||||
end
|
||||
|
||||
function keyringStart(name, line, wildcards)
|
||||
keyringWin = ThemedTextWindow(
|
||||
"keyring",
|
||||
0, 0, 0, 0,
|
||||
"Expiring Keys",
|
||||
"center",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
fName, fSize, fName, fSize,
|
||||
1000,
|
||||
5,
|
||||
true,
|
||||
false
|
||||
)
|
||||
|
||||
EnableTrigger("captureKeys")
|
||||
EnableTrigger("disableKeys")
|
||||
keyringList = {}
|
||||
end
|
||||
|
||||
function processKey(name, line, wildcards)
|
||||
if line == "{/keyring}" then keyEnd() return end
|
||||
local parts= {}
|
||||
keyNameLen = 0
|
||||
|
||||
for part in line:gmatch("([^,]+)") do
|
||||
table.insert(parts, part)
|
||||
end
|
||||
|
||||
local keyID, keyName, keyExpiry = tonumber(parts[1]), table.concat(parts, ",", 3, #parts-5), (parts[#parts] == "-1" and 0 or tonumber(parts[#parts]))
|
||||
|
||||
if keyExpiry > 0 then
|
||||
table.insert(keyringList, {keyID = keyID, keyName = keyName, keyExpiry = keyExpiry})
|
||||
end
|
||||
end
|
||||
|
||||
function keyEnd()
|
||||
keyringWin:clear(true)
|
||||
|
||||
table.sort(keyringList, function(a, b)
|
||||
return a.keyExpiry < b.keyExpiry
|
||||
end)
|
||||
|
||||
keyringWin:add_text(keyHeader)
|
||||
keyringWin:add_text(keyBreak)
|
||||
|
||||
for _, key in ipairs(keyringList) do
|
||||
keyringWin:add_text(keyString:format(key.keyID, key.keyName .. string.rep(" ", 42-#strip_colours(key.keyName)), convertTime(key.keyExpiry)))
|
||||
end
|
||||
|
||||
keyringWin:fit_contents()
|
||||
keyringWin:set_scroll(1)
|
||||
keyringWin:show()
|
||||
|
||||
EnableTrigger("captureKeys", false)
|
||||
EnableTrigger("disableKeys", false)
|
||||
EnableTrigger("keyStart", false)
|
||||
end
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
||||
</muclient>
|
Loading…
Reference in new issue