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 -->
<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>
<!-- Aliases -->
<aliases>
<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[
<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>
<!-- Aliases -->
<aliases>
<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"
require "gmcphelper"
local snapshotV = tonumber(extras.PackageVersion())
@ -97,39 +127,35 @@ function addToWindow(lines)
NotesWin:show()
end
function findBoundaries(tbl)
local start_idx = 1
while start_idx<= #tbl and not tbl[start_idx][2]:find("~") and not tbl[start_idx][2]:find("No more new posts") do
start_idx = start_idx + 1
end
local end_idx = #tbl
while end_idx >= 1 and not tbl[end_idx][2]:find("~") and not tbl[end_idx][2]:find("There are no new") do
end_idx = end_idx - 1
end
if start_idx > 1 then
table.remove(tbl, 1)
start_idx = start_idx - 1
end
if end_idx < #tbl then
table.remove(tbl)
end_idx = end_idx - 1
end
for i = end_idx, start_idx, -1 do
table.remove(tbl, i)
end
local lines = {}
for _, entry in ipairs(tbl) do
table.insert(lines, entry[2])
end
return lines
function findBoundaries(lines)
local first_index = nil
local last_index = nil
-- Find the first and last indices with ~ in the text field
for i, v in ipairs(lines) do
if (string.find(v[1].text, "~") or string.find(v[1].text, "No more new posts")) and not first_index then
first_index = i
end
if (string.find(v[1].text, "~") or string.find(v[1].text, "There are no new")) then
last_index = i
end
end
-- Remove all the entries before the first ~ and after the last ~
if first_index and last_index then
for i = #lines, last_index + 1, -1 do
table.remove(lines, i)
end
for i = first_index - 1, 1, -1 do
table.remove(lines, i)
end
end
return lines
end
function hyperlinknotes(lines)
for i,v in ipairs(findBoundaries(lines)) do
if i < 5 or i == #lines then
@ -148,36 +174,29 @@ function hyperlinknotes(lines)
end
function toggleNoteWin(name, line, wildcards)
local noteOpt = wildcards[1]
if noteOpt == "on" then
if wildcards[1] == "on" or wildcards[1] == "show" then
noteShow = "true"
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in window.")
elseif noteOpt == "off" then
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
elseif wildcards[1] == "off" or wildcards[1] == "hide" then
noteShow = "false"
SetVariable("noteShow", noteShow)
ColourNote("white", "blue", "Note Extender: Displaying notes in main output.")
elseif noteOpt == "show" then
NotesWin:fit_contents(850, 500)
NotesWin:show()
elseif noteOpt == "hide" then
NotesWin:hide()
elseif noteOpt == "clear" then
ColourNote("white", "blue", "Toggled Note Window Status: " .. wildcards[1])
elseif wildcards[1] == "clear" then
NotesWin:clear(false)
NotesWin:hide()
elseif noteOpt == "help" then
ColourNote("white", "blue", "Clearing Note Window...")
elseif wildcards[1] == "help" then
onHelp()
end
end
function onHelp()
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("%s-30s - %s", "notewin <show|hide>", "Shows or hides the note window."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin <on|show|off|hide>", "Toggles the display of the note window."))
ColourNote("orange", "", string.format("%-30s - %s", "notewin clear", "Clears the note window of existing content."))
end
]]>
</script>
</script>
</muclient>

Loading…
Cancel
Save