Reverting due to errors

master
AardCrowley 2 years ago committed by GitHub
parent 7580ef6cd9
commit 861ece5d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,24 +6,54 @@
<!-- Plugin "RoomCharWindow" generated by Plugin Wizard --> <!-- Plugin "RoomCharWindow" generated by Plugin Wizard -->
<muclient> <muclient>
<plugin name="NoteWindow" author="Crowley" id="c49e43d9dce931263263088b" language="Lua" purpose="Note output and hyperlinks" save_state="y" date_written="2022-03-09 11:02:09" requires="5.07" version="1.0" sequence="10"> <plugin
name="NoteWindow"
</plugin> author="Crowley"
<!-- Aliases --> id="c49e43d9dce931263263088b"
language="Lua"
<aliases> purpose="Note output and hyperlinks"
<alias match="^(note(?: read(?: \d+| last| again)?)?)$" enabled="y" regexp="y" script="startNoteRead" sequence="100"> save_state="y"
</alias> date_written="2022-03-09 11:02:09"
requires="5.07"
<alias match="^notewin (on|off|show|hide|clear|help)$" enabled="y" regexp="y" ignore_case="y" script="toggleNoteWin" sequence="100"> version="1.0"
</alias> sequence="10"
>
<alias match="^(note\s?(?:list(?:\s\d+)?|unread|to\s\w+|from\s\w+|subj\s.+)?)$" enabled="y" regexp="y" script="startNoteList" sequence="100">
</alias> </plugin>
</aliases> <!-- Aliases -->
<script> <aliases>
<![CDATA[ <alias
match="^(note(?: read(?: \d+| last| again)?)?)$"
enabled="y"
regexp="y"
script="startNoteRead"
sequence="100"
>
</alias>
<alias
match="^notewin (on|off|show|hide|clear|help)$"
enabled="y"
regexp="y"
ignore_case="y"
script="toggleNoteWin"
sequence="100"
>
</alias>
<alias
match="^(note\s?(?:list(?:\s\d+)?|unread|to\s\w+|from\s\w+|subj\s.+)?)$"
enabled="y"
regexp="y"
script="startNoteList"
sequence="100"
>
</alias>
</aliases>
<script>
<![CDATA[
local extras = require "aard_lua_extras" local extras = require "aard_lua_extras"
require "gmcphelper" require "gmcphelper"
local snapshotV = tonumber(extras.PackageVersion()) local snapshotV = tonumber(extras.PackageVersion())
@ -97,39 +127,35 @@ function addToWindow(lines)
NotesWin:show() NotesWin:show()
end end
function findBoundaries(tbl)
local start_idx = 1 function findBoundaries(lines)
while start_idx<= #tbl and not tbl[start_idx][2]:find("~") and not tbl[start_idx][2]:find("No more new posts") do local first_index = nil
start_idx = start_idx + 1 local last_index = nil
end
-- Find the first and last indices with ~ in the text field
local end_idx = #tbl for i, v in ipairs(lines) do
while end_idx >= 1 and not tbl[end_idx][2]:find("~") and not tbl[end_idx][2]:find("There are no new") do if (string.find(v[1].text, "~") or string.find(v[1].text, "No more new posts")) and not first_index then
end_idx = end_idx - 1 first_index = i
end end
if (string.find(v[1].text, "~") or string.find(v[1].text, "There are no new")) then
if start_idx > 1 then last_index = i
table.remove(tbl, 1) end
start_idx = start_idx - 1 end
end
-- Remove all the entries before the first ~ and after the last ~
if end_idx < #tbl then if first_index and last_index then
table.remove(tbl) for i = #lines, last_index + 1, -1 do
end_idx = end_idx - 1 table.remove(lines, i)
end end
for i = first_index - 1, 1, -1 do
for i = end_idx, start_idx, -1 do table.remove(lines, i)
table.remove(tbl, i) end
end end
local lines = {} return lines
for _, entry in ipairs(tbl) do
table.insert(lines, entry[2])
end
return lines
end end
function hyperlinknotes(lines) function hyperlinknotes(lines)
for i,v in ipairs(findBoundaries(lines)) do for i,v in ipairs(findBoundaries(lines)) do
if i < 5 or i == #lines then if i < 5 or i == #lines then
@ -148,36 +174,29 @@ function hyperlinknotes(lines)
end end
function toggleNoteWin(name, line, wildcards) function toggleNoteWin(name, line, wildcards)
local noteOpt = wildcards[1] if wildcards[1] == "on" or wildcards[1] == "show" then
if noteOpt == "on" then
noteShow = "true" noteShow = "true"
SetVariable("noteShow", noteShow) SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in window.") ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
elseif noteOpt == "off" then elseif wildcards[1] == "off" or wildcards[1] == "hide" then
noteShow = "false" noteShow = "false"
SetVariable("noteShow", noteShow) SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in main output.") ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
elseif noteOpt == "show" then elseif wildcards[1] == "clear" then
NotesWin:fit_contents(850, 500)
NotesWin:show()
elseif noteOpt == "hide" then
NotesWin:hide()
elseif noteOpt == "clear" then
NotesWin:clear(false) NotesWin:clear(false)
NotesWin:hide() NotesWin:hide()
elseif noteOpt == "help" then ColourNote("white", "blue", "Clearing Note Window...")
elseif wildcards[1] == "help" then
onHelp() onHelp()
end end
end end
function onHelp() function onHelp()
ColourNote("yellow", "", "Basic commands:") ColourNote("yellow", "", "Basic commands:")
ColourNote("orange", "", string.format("%-30s - %s", "notewin <on|off>", "Toggles where notes are displayed (window or output).")) ColourNote("orange", "", string.format("%-30s - %s", "notewin <on|show|off|hide>", "Toggles the display of the note window."))
ColourNote("orange", "", string.format("%s-30s - %s", "notewin <show|hide>", "Shows or hides the note window."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin clear", "Clears the note window of existing content.")) ColourNote("orange", "", string.format("%-30s - %s", "notewin clear", "Clears the note window of existing content."))
end end
]]> ]]>
</script> </script>
</muclient> </muclient>

Loading…
Cancel
Save