parent
d4f549c5f0
commit
b0ae796711
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE muclient>
|
||||
<!-- Saved on Wednesday, February 22, 2023, 1:56 PM -->
|
||||
<!-- MuClient version 5.07-pre -->
|
||||
|
||||
<!-- Plugin "FriendAgoSorted" generated by Plugin Wizard -->
|
||||
|
||||
<muclient>
|
||||
<plugin name="FriendAgoSorted" author="Crowley" id="d434e9b635dc35c2ff25e1c9" language="Lua" purpose="Sort Friend Ago" save_state="y" date_written="2023-02-22 13:55:27" requires="4.99" version="1.0">
|
||||
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Triggers -->
|
||||
|
||||
<triggers>
|
||||
<trigger group="friendCheck" match="^\s{0,2}\d+\) - (\w+)\s+\(Offline -\s(.*)\)" regexp="y" script="getStatus" sequence="100" omit_from_output="y">
|
||||
</trigger>
|
||||
<trigger group="friendCheck" match="^\s{0,2}\d+\) - (\w+)\s+\((?:(Online|Private|Missing|Linkdead))\)" regexp="y" script="storeOther" sequence="100" omit_from_output="y">
|
||||
</trigger>
|
||||
<trigger group="friendCheck" match="^$" regexp="y" send_to="12" sequence="100">
|
||||
<send>EnableTriggerGroup("friendCheck", false)
|
||||
returnOutput()
|
||||
</send>
|
||||
</trigger>
|
||||
</triggers>
|
||||
|
||||
<!-- Aliases -->
|
||||
|
||||
<aliases>
|
||||
<alias match="^friend ago$" enabled="y" regexp="y" send_to="12" sequence="100">
|
||||
<send>
|
||||
resetValues()
|
||||
EnableTriggerGroup("friendCheck")
|
||||
Send("friend ago")
|
||||
</send>
|
||||
</alias>
|
||||
</aliases>
|
||||
|
||||
<!-- Script -->
|
||||
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
dofile(GetInfo(60) .. "aardwolf_colors.lua")
|
||||
|
||||
local friendAgo = {}
|
||||
local friendSeconds = {}
|
||||
local friendOther = {}
|
||||
local friendsAlpha = {}
|
||||
local count = 0
|
||||
|
||||
local strForm = "@w%3d) %-12s - @R(Offline %d day%s and %02d:%02d:%02d)\n"
|
||||
local statForm = "@w%3d) %-12s - %s(%s)\n"
|
||||
|
||||
function resetValues()
|
||||
friendAgo = {}
|
||||
friendSeconds = {}
|
||||
friendOther = {}
|
||||
count = 0
|
||||
friendsAlpha = {}
|
||||
end
|
||||
|
||||
function getStatus(name, line, wildcards)
|
||||
local name = wildcards[1]
|
||||
local status = wildcards[2]
|
||||
|
||||
local days, hours, minutes, seconds = 0, 0, 0, 0
|
||||
|
||||
if string.find(status, "day") then
|
||||
days, hours, minutes, seconds = string.match(status, "(%d+) days? and (%d+):(%d+):(%d+)")
|
||||
else
|
||||
hours, minutes, seconds = string.match(status, "(%d+):(%d+):(%d+)")
|
||||
end
|
||||
|
||||
friendAgo[name] = {days = days, hours = hours, minutes = minutes, seconds = seconds}
|
||||
end
|
||||
|
||||
function convertToSeconds(name, days, hours, minutes, seconds)
|
||||
local totSeconds = days*86400 + hours*3600 + minutes*60 + seconds
|
||||
friendSeconds[name] = totSeconds
|
||||
end
|
||||
|
||||
function sortTableByValue(tbl)
|
||||
local sortedTable = {}
|
||||
for k, v in pairs(tbl) do
|
||||
table.insert(sortedTable, {key = k, value = v})
|
||||
end
|
||||
table.sort(sortedTable, function(a, b) return a.value > b.value end)
|
||||
return sortedTable
|
||||
end
|
||||
|
||||
function returnOutput()
|
||||
for i,v in pairs(friendAgo) do
|
||||
convertToSeconds(i, v.days, v.hours, v.minutes, v.seconds)
|
||||
end
|
||||
|
||||
friendSeconds = sortTableByValue(friendSeconds)
|
||||
|
||||
for i,v in pairs(friendSeconds) do
|
||||
local kname = v.key
|
||||
local fTable = friendAgo[kname]
|
||||
local days = fTable.days
|
||||
local hours = fTable.hours
|
||||
local minutes = fTable.minutes
|
||||
local seconds = fTable.seconds
|
||||
local plural = (tonumber(days) == 1 and "" or "s")
|
||||
Simulate(ColoursToANSI(string.format(strForm, i, kname, days, plural, hours, minutes, seconds)))
|
||||
count = i
|
||||
end
|
||||
|
||||
for k in pairs(friendOther) do
|
||||
table.insert(friendsAlpha, k)
|
||||
end
|
||||
|
||||
table.sort(friendsAlpha)
|
||||
|
||||
for _, v in pairs(friendsAlpha) do
|
||||
local vColor = "@G"
|
||||
if friendOther[v] == "Private" or friendOther[v] == "Missing" then
|
||||
vColor = "@Y"
|
||||
elseif friendOther[v] == "Linkdead" then
|
||||
vColor = "@C"
|
||||
end
|
||||
count = count + 1
|
||||
|
||||
Simulate(ColoursToANSI(string.format(statForm, count, v, vColor, friendOther[v])))
|
||||
end
|
||||
end
|
||||
|
||||
function storeOther(name, line, wildcards)
|
||||
friendOther[wildcards[1]] = wildcards[2]
|
||||
end
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
||||
</muclient>
|
Loading…
Reference in new issue